SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2112.05253 · 2021

MAGMA -- Multimodal Augmentation of Generative Models through Adapter-based Finetuning

arXiv · PDF · Open in the Atlas

Code that ran

10 of 15 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 1 violated it and 0 have no contract verdict; 8 failures of our instrument; 5 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2112.05253.json · badge: /api/ran/2112.05253.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
Aleph-Alpha/magma canonical (classifier label)
classifier basis: census
10 ran · 5 no recorded run
FunctionStatusWhere it lives
eval_step Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
Aleph-Alpha/magma/magma/train_loop.py
code served (permissive licence) · get_code("5efa2a11277a7471")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float, ndim 0, dtype family float; no output shape is stated. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from unittest.mock import Mock

torch.manual_seed(0)

# Create a minimal config with required attributes
class Config:
    def __init__(self):
        self.eval_steps = 2
        self.run_blind = False

config = Config()

# Create a minimal model that returns outputs with a loss attribute
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 2)
    
    def forward(self, images, captions):
        # Return an object with a loss attribute
        outputs = Mock()
        outputs.loss = torch.tensor(0.5)
        return outputs

model_engine = MinimalModel()

# Create an eval_loader as an iterator of batches
# Each batch is (images, captions)
eval_loader = iter([
    (torch.randn(2, 4), torch.randint(0, 10, (2, 3))),
    (torch.randn(2, 4), torch.randint(0, 10, (2, 3))),
])

# Mock the reduce_losses function that's called in eval_step
def reduce_losses(tensor):
    return tensor

# Inject reduce_losses into the module namespace for the function
import sys
current_module = sys.modules[__name__]
current_module.reduce_losses = reduce_losses

ARGS = {
    'config': config,
    'eval_loader': eval_loader,
    'model_engine': model_engine,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float — no output shape is stated: observe_signature.py could not observe it (fixture:KeyError)
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_transforms Ran
ran; our contract draft was wrong, not the code
Aleph-Alpha/magma/magma/transforms.py
code served (permissive licence) · get_code("b28f8eba1c7bc3ab")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Compose. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
from PIL import Image

torch.manual_seed(0)

# Create a small test image
def create_test_image(width=128, height=128):
    """Create a simple PIL Image for testing"""
    img_array = np.random.randint(0, 256, (height, width, 3), dtype=np.uint8)
    return Image.fromarray(img_array, mode='RGB')

ARGS = {
    'image_size': 256,
    'encoder_name': 'resnet50',
    'input_resolution': None,
    'use_extra_transforms': False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy, torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Compose — a Compose output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Compose output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_config Ran
ran; our contract draft was wrong, not the code
Aleph-Alpha/magma/magma/config.py
code served (permissive licence) · get_code("ace12fad87592626")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import yaml
import os
from pathlib import Path
import tempfile

# Create a temporary directory and a minimal YAML config file
temp_dir = tempfile.mkdtemp()
config_dir = Path(temp_dir)

# Create a sample config file
config_content = """
model:
  name: test_model
  layers: 3
training:
  epochs: 10
  learning_rate: 0.001
"""

config_file = config_dir / "test_config.yml"
with open(config_file, 'w') as f:
    f.write(config_content)

# Define ARGS with valid arguments for load_config
ARGS = {
    'path': str(config_file),
    'config_dir': config_dir
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
yaml — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_model Ran
ran, honoured the contract we drafted
Aleph-Alpha/magma/magma/utils.py
code served (permissive licence) · get_code("cda91d1c99cf9e9c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned int, ndim 0, dtype family int, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

class MockModelEngine(nn.Module):
    """Mock model engine that implements load_checkpoint method"""
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def load_checkpoint(self, load_dir, load_optimizer_states=True, load_lr_scheduler_states=True):
        """
        Mock implementation of load_checkpoint that returns a load path and state dict
        """
        # Simulate successful checkpoint loading
        load_path = f"{load_dir}/checkpoint.pt"
        state_dict = {
            'global_step': 42,
            'model_state': self.state_dict(),
        }
        return load_path, state_dict

# Create mock model engine
model_engine = MockModelEngine()

# Create load directory path (string, not actual file I/O)
load_dir = "/path/to/checkpoints"

# Arguments for load_model function
ARGS = {
    'model_engine': model_engine,
    'load_dir': load_dir,
    'load_optimizer_states': True,
    'load_lr_scheduler_states': True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
nfresnet50 Ran
ran; our contract draft was wrong, not the code
Aleph-Alpha/magma/magma/image_encoders.py
code served (permissive licence) · get_code("628f0fcc54199efc")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Sequential. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    "device": torch.device("cpu"),
    "pretrained": False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
timm, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Sequential — a Sequential output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
pad_to_size Ran
ran; our contract draft was wrong, not the code
Aleph-Alpha/magma/magma/transforms.py
code served (permissive licence) · get_code("e82e4764f914492f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Image. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

from PIL import Image
import numpy as np

# Create a small PIL Image for testing
# The function expects a PIL Image object with .size attribute
test_image = Image.new('RGB', (100, 150))

ARGS = {
    'x': test_image,
    'size': 256
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Image — a Image output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Image output the recorded ndim 3 and dtype family int describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
pad_to_size_tensor Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
Aleph-Alpha/magma/magma/transforms.py
code served (permissive licence) · get_code("d3af6b05f019b479")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 3, dtype family float, shape (2, 256, 256) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn.functional as F

torch.manual_seed(0)

# Create a small tensor with shape (batch, height, width)
# Using distinct sizes: batch=2, height=4, width=3
x = torch.randn(2, 4, 3)

ARGS = {
    "x": x,
    "size": 256
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (2, 256, 256) — shape (2, 256, 256) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
reduce_losses Ran
ran, violated the contract we drafted
Aleph-Alpha/magma/magma/utils.py
code served (permissive licence) · get_code("4f70ab2c3e38d976")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 1, dtype family float, shape (4,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.distributed as dist

torch.manual_seed(0)

# Create a small tensor of losses
# The function calls .detach() and .clone() on it, so it needs to be a tensor
losses = torch.tensor([1.5, 2.3, 0.8, 1.2], dtype=torch.float32)

ARGS = {
    "losses": losses
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 1, dtype family float, shape (4,) — shape (4,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
remove_tokens_after_eos Ran
ran; our contract draft was wrong, not the code
Aleph-Alpha/magma/magma/sampling.py
code served (permissive licence) · get_code("ba246ce8c9917aba")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create a small tensor with token IDs
# Include some regular tokens, an eos_token, image_token, and tokens after eos
tensor = torch.tensor([101, 102, 103, 104, 105, 0, 102, 103], dtype=torch.long)

# Define token IDs
eos_token = 0      # End-of-sequence token
image_token = 104  # Image token

ARGS = {
    "tensor": tensor,
    "eos_token": eos_token,
    "image_token": image_token,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family int — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
top_k_filter Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
Aleph-Alpha/magma/magma/sampling.py
code served (permissive licence) · get_code("aa8cc3e8f125148a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create logits tensor: batch_size=2, vocab_size=4
logits = torch.randn(2, 4)

# Set k to a valid value less than vocabulary size
k = 2

ARGS = {
    "logits": logits,
    "k": k,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_gptj Not yet run
unverified (harvested, no recorded run)
Aleph-Alpha/magma/magma/language_model.py
code served (permissive licence) · get_code("d4435db67cbbf30d")
How it ran

no invocation recorded.

get_tokenizer Not yet run
unverified (harvested, no recorded run)
Aleph-Alpha/magma/magma/utils.py
code served (permissive licence) · get_code("f057466b39aff113")
How it ran

no invocation recorded.

save_to_jsons Not yet run
unverified (harvested, no recorded run)
Aleph-Alpha/magma/magma/datasets/convert_datasets.py
code served (permissive licence) · get_code("b92f1cee291214f5")
How it ran

no invocation recorded.

train_step Not yet run
unverified (harvested, no recorded run)
Aleph-Alpha/magma/magma/train_loop.py
code served (permissive licence) · get_code("5c7e7dc9d5bdc305")
How it ran

no invocation recorded.

train_step_classification Not yet run
unverified (harvested, no recorded run)
Aleph-Alpha/magma/magma/train_loop.py
code served (permissive licence) · get_code("a2d4cd1429030731")
How it ran

no invocation recorded.

Also present in other papers' code

Of 15 samples lifted from this paper's linked repositories, 15 carry a function identity and 0 do not. Of the 15 distinct functions with an identity, 5 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 5 later) and 10 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
pad_to_size 2 other papers
2 later
2209.15162 (2022-09)
Linearly Mapping from Image to Text Space
2301.13823 (2023-01)
Grounding Language Models to Images for Multimodal Inputs and Outputs
load_config 1 other paper
1 later
2209.15162 (2022-09)
Linearly Mapping from Image to Text Space
pad_to_size_tensor 1 other paper
1 later
2209.15162 (2022-09)
Linearly Mapping from Image to Text Space
remove_tokens_after_eos 1 other paper
1 later
2209.15162 (2022-09)
Linearly Mapping from Image to Text Space
top_k_filter 1 other paper
1 later
2209.15162 (2022-09)
Linearly Mapping from Image to Text Space

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Large-scale pretraining is fast becoming the norm in Vision-Language (VL) modeling. However, prevailing VL approaches are limited by the requirement for labeled data and the use of complex multi-step pretraining objectives. We present MAGMA - a simple method for augmenting generative language models with additional modalities using adapter-based finetuning. Building on Frozen, we train a series of VL models that autoregressively generate text from arbitrary combinations of visual and textual input. The pretraining is entirely end-to-end using a single language modeling objective, simplifying optimization compared to previous approaches. Importantly, the language model weights remain unchanged during training, allowing for transfer of encyclopedic knowledge and in-context learning abilities from language pretraining. MAGMA outperforms Frozen on open-ended generative tasks, achieving state of the art results on the OKVQA benchmark and competitive results on a range of other popular VL benchmarks, while pretraining on 0.2% of the number of samples used to train SimVLM.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2112.05253")
get_code_for_paper("2112.05253")
have("2112.05253")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2112.05253.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2112.05253.svg)](https://syntology.ai/paper/2112.05253)

Connect an agent — have() is free.