SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2405.21060 · ICML · 2024

Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality

Albert Gu, Tri Dao

arXiv · PDF · Open in the Atlas

Code that ran

9 of 13 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; 0 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 8 failures of our instrument; 4 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/2405.21060.json · badge: /api/ran/2405.21060.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
radarFudan/mamba canonical (classifier label)
classifier basis: census
5 ran · 1 no recorded run
state-spaces/mamba canonical (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
rorschach1989/transformer-for-gmm community (classifier label)
classifier basis not recorded on the link
1 ran · 3 no recorded run
copy not recorded community
not in the paper's declared repositories
1 ran · 0 no recorded run
tommyip/mamba2-minimal community (classifier label)
classifier basis not recorded on the link
1 ran · 0 no recorded run
FunctionStatusWhere it lives
all_gather_raw Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
radarFudan/mamba/mamba_ssm/distributed/distributed_utils.py
code served (permissive licence) · get_code("0f2196b3902caf16")
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 tuple. 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
from torch.distributed import ProcessGroup
from unittest.mock import MagicMock

torch.manual_seed(0)

# Create a mock ProcessGroup
mock_process_group = MagicMock(spec=ProcessGroup)

# Create a small input tensor
input_tensor = torch.randn(2, 4, dtype=torch.float32)

# Mock torch.distributed functions to make this work without actual distributed setup
original_get_world_size = torch.distributed.get_world_size
original_all_gather_into_tensor = torch.distributed.all_gather_into_tensor

def mock_get_world_size(group=None):
    return 2

def mock_all_gather_into_tensor(output, input_, group=None, async_op=False):
    # Simulate gathering by repeating the input
    output[:input_.shape[0]] = input_
    output[input_.shape[0]:] = input_
    mock_handle = MagicMock()
    mock_handle.wait = MagicMock()
    return mock_handle

torch.distributed.get_world_size = mock_get_world_size
torch.distributed.all_gather_into_tensor = mock_all_gather_into_tensor

ARGS = {
    'input_': input_tensor,
    'process_group': mock_process_group,
    'async_op': False
}
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 tuple — a tuple 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
gen_name_from_cfg Ran
ran on a synthesized input
rorschach1989/transformer-for-gmm/tgmm/utils/configuration.py
code served (permissive licence) · get_code("2ef6cf3e9fce8a55")
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 str. 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 types import SimpleNamespace

torch.manual_seed(0)

# Create a config object with all required nested attributes
cfg = SimpleNamespace()

# Task configuration - testing the first branch (Gaussian Mixture)
cfg.task = SimpleNamespace()
cfg.task.type = 'IsotropicGaussianMixture'
cfg.task.n_components = 3
cfg.task.dim = 4
cfg.task.a_s = [0.5, 1.0, 1.5]
cfg.task.b = 0.1234

# Model configuration - transformer variant
cfg.model = SimpleNamespace()
cfg.model.model_type = 'transformer'
cfg.model.n_embd = 64
cfg.model.n_layer = 2
cfg.model.hidden_size = 32  # for non-transformer fallback
cfg.model.num_hidden_layers = 1  # for non-transformer fallback

# Training configuration
cfg.train = SimpleNamespace()
cfg.train.batch_size = 16
cfg.train.n_sample = 1000

# Evaluation configuration
cfg.eval = SimpleNamespace()
cfg.eval.n_sample = 500
cfg.eval.ood_perturbation_scale = 0.5

ARGS = {
    'cfg': cfg
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
heavy_tail_activation Ran
ran; our contract draft was wrong, not the code
state-spaces/mamba/mamba_ssm/modules/mamba3.py
code served (permissive licence) · get_code("5c853f3f04ddb483")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Sonnet 4.5, prompt python_fixture_v1) 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 a small tensor with both positive and negative values
# to test both branches of the heavy_tail_activation function
x = torch.tensor([[-1.5, -0.5, 0.5, 1.5],
                  [0.0, -0.2, 0.8, -0.9]])

ARGS = {
    "x": x
}
Setup block drafted by
a language model, Claude Sonnet 4.5, prompt python_fixture_v1
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
reduce_scatter_raw Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
radarFudan/mamba/mamba_ssm/distributed/distributed_utils.py
code served (permissive licence) · get_code("2d002bb9a87211b8")
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 tuple. 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
from torch.distributed import ProcessGroup
from unittest.mock import MagicMock

torch.manual_seed(0)

# Create a mock ProcessGroup since we can't actually initialize distributed training
# The function only calls torch.distributed.get_world_size() and passes it to reduce_scatter_tensor
mock_process_group = MagicMock(spec=ProcessGroup)

# Create input tensor: batch dimension must be divisible by world_size
# Using world_size=2 for simplicity, so batch size = 4
input_tensor = torch.randn(4, 3, dtype=torch.float32, device='cpu')

# Mock torch.distributed functions to work without actual distributed setup
def mock_get_world_size(process_group):
    return 2

def mock_reduce_scatter_tensor(output, input_tensor, group, async_op=False):
    # Return a mock handle
    mock_handle = MagicMock()
    return mock_handle

# Patch the distributed functions
torch.distributed.get_world_size = mock_get_world_size
torch.distributed.reduce_scatter_tensor = mock_reduce_scatter_tensor

ARGS = {
    'input_': input_tensor,
    'process_group': mock_process_group,
    'async_op': False
}
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 tuple — a tuple 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
segsum Ran
ran; our contract draft was wrong, not the code
radarFudan/mamba/mamba_ssm/modules/ssd_minimal.py
code served (permissive licence) · get_code("ef936c81f5d4c41c")
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 4, dtype family float, shape (2, 4, 3, 3) 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
from einops import rearrange, repeat

torch.manual_seed(0)

# The function takes a single parameter 'x' which should be a tensor
# Looking at the function body:
# - x.size(-1) is called, so x must be a tensor
# - repeat() is used on x with pattern '... d -> ... d e'
# - masked_fill, cumsum operations are performed
# - The tensor should have at least 2 dimensions (based on dim=-2 usage)

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

ARGS = {
    "x": x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 4, dtype family float, shape (2, 4, 3, 3) — shape (2, 4, 3, 3) 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
segsum_unstable Ran
ran; our contract draft was wrong, not the code
radarFudan/mamba/mamba_ssm/modules/ssd_minimal.py
code served (permissive licence) · get_code("f641b66c642a2908")
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, 4, 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 a small tensor for testing
# The function expects x to be a tensor with a last dimension T
# x_cumsum will have shape [..., T]
# x_segsum will have shape [..., T, T]
# The function uses x.size(-1), x.device, x.cumsum, masked_fill operations
x = torch.randn(2, 4)  # batch size 2, sequence length 4

ARGS = {
    "x": x
}
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, 4, 4) — shape (2, 4, 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
selective_scan_ref Ran
ran; our contract draft was wrong, not the code
this paper's copy was not recorded; identical code first harvested from state-spaces/mamba
pointer only · get_code("ba7b868fec181b57")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

silu Ran
ran; our contract draft was wrong, not the code
tommyip/mamba2-minimal/mamba2.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from human9000/nd-mamba2-torch, is pointer only (licence: NONE) · get_code("8558535d4b8ed416")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from human9000/nd-mamba2-torch, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

ssd_minimal_discrete Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
radarFudan/mamba/mamba_ssm/modules/ssd_minimal.py
code served (permissive licence) · get_code("f5c3ef656ef76878")
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 tuple. 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.functional as F
from einops import rearrange, repeat

torch.manual_seed(0)

# Define dimensions (using distinct sizes)
batch = 2
length = 8
n_heads = 3
d_head = 4
d_state = 5
block_len = 4

# Create tensors with proper shapes and dtypes
X = torch.randn(batch, length, n_heads, d_head, dtype=torch.float32)
A = torch.randn(batch, length, n_heads, dtype=torch.float32)
B = torch.randn(batch, length, n_heads, d_state, dtype=torch.float32)
C = torch.randn(batch, length, n_heads, d_state, dtype=torch.float32)

# initial_states is optional, set to None to test default behavior
initial_states = None

ARGS = {
    'X': X,
    'A': A,
    'B': B,
    'C': C,
    'block_len': block_len,
    'initial_states': initial_states,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple 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
all_reduce_raw Not yet run
unverified (harvested, no recorded run)
radarFudan/mamba/mamba_ssm/distributed/distributed_utils.py
code served (permissive licence) · get_code("a06d70b09eb46b60")
How it ran

no invocation recorded.

concat_task_sample Not yet run
unverified (harvested, no recorded run)
rorschach1989/transformer-for-gmm/tgmm/task.py
code served (permissive licence) · get_code("389b08cfb8b3130b")
How it ran

no invocation recorded.

concat_task_sample_hf Not yet run
unverified (harvested, no recorded run)
rorschach1989/transformer-for-gmm/tgmm/task.py
code served (permissive licence) · get_code("f23bd7f5b8889fa3")
How it ran

no invocation recorded.

concat_task_sample_instruct Not yet run
unverified (harvested, no recorded run)
rorschach1989/transformer-for-gmm/tgmm/task.py
code served (permissive licence) · get_code("32968cc3a1d4a2e0")
How it ran

no invocation recorded.

Also present in other papers' code

Of 13 samples lifted from this paper's linked repositories, 13 carry a function identity and 0 do not. Of the 13 distinct functions with an identity, 8 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 1 the same month, 8 later) and 5 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
selective_scan_ref 13 other papers
4 dated earlier, 1 the same month, 8 later
2101.03961 (2021-01)
Switch Transformers: Scaling to Trillion Parameter Models with Simple and Efficient Sparsity
2402.05608 (2024-02)
Scalable Diffusion Models with State Space Backbone
2403.16899 (2024-03)
State Space Models as Foundation Models: A Control Theoretic Overview
and 10 more not named here
all_gather_raw 2 other papers
2 later
2412.08160 (2024-12)
DG-Mamba: Robust and Efficient Dynamic Graph Structure Learning with Selective State Space Models
2502.18886 (2025-02)
On Pruning State-Space LLMs
all_reduce_raw 2 other papers
2 later
2412.08160 (2024-12)
DG-Mamba: Robust and Efficient Dynamic Graph Structure Learning with Selective State Space Models
2502.18886 (2025-02)
On Pruning State-Space LLMs
reduce_scatter_raw 2 other papers
2 later
2412.08160 (2024-12)
DG-Mamba: Robust and Efficient Dynamic Graph Structure Learning with Selective State Space Models
2502.18886 (2025-02)
On Pruning State-Space LLMs
silu 2 other papers
1 dated earlier, 1 later
2312.00752 (2023-12)
Mamba: Linear-Time Sequence Modeling with Selective State Spaces
2505.24244 (2025-05)
Mamba Knockout for Unraveling Factual Information Flow
segsum 1 other paper
1 later
2502.18886 (2025-02)
On Pruning State-Space LLMs
segsum_unstable 1 other paper
1 later
2502.18886 (2025-02)
On Pruning State-Space LLMs
ssd_minimal_discrete 1 other paper
1 later
2502.18886 (2025-02)
On Pruning State-Space LLMs

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

While Transformers have been the main architecture behind deep learning's success in language modeling, state-space models (SSMs) such as Mamba have recently been shown to match or outperform Transformers at small to medium scale. We show that these families of models are actually quite closely related, and develop a rich framework of theoretical connections between SSMs and variants of attention, connected through various decompositions of a well-studied class of structured semiseparable matrices. Our state space duality (SSD) framework allows us to design a new architecture (Mamba-2) whose core layer is an a refinement of Mamba's selective SSM that is 2-8× faster, while continuing to be competitive with Transformers on language modeling. * Alphabetical by last name.

For agents

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

get_harvested_code_for_paper("2405.21060")
get_code_for_paper("2405.21060")
have("2405.21060")

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

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

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

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

Connect an agent — have() is free.