SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2410.15091 · ICLR · 2025

Spatial-Mamba: Effective Visual State Space Models via Structure-Aware State Fusion

Lei Zhang, Deyu Meng, Minghan Li, Chaodong Xiao, Zhengqiang Zhang

arXiv · PDF · Open in the Atlas

Code that ran

9 of 14 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; 2 honoured the contract we drafted, 1 violated it and 0 have no contract verdict; 6 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/2410.15091.json · badge: /api/ran/2410.15091.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
edwardchasel/spatial-mamba canonical (classifier label)
classifier basis: census
8 ran · 5 no recorded run
EdwardChasel/Spatial-Mamba canonical (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
FunctionStatusWhere it lives
auto_resume_helper Ran
ran; our contract draft was wrong, not the code
edwardchasel/spatial-mamba/classification/utils/utils.py
code served (permissive licence) · get_code("1f9f75e583e2169e")
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 os
import torch
import tempfile
import shutil

torch.manual_seed(0)

# Create a temporary directory with test checkpoint files
temp_dir = tempfile.mkdtemp()

# Create a valid checkpoint file
valid_checkpoint = {
    'model_state_dict': torch.randn(2, 4),
    'optimizer_state_dict': torch.randn(3, 5),
    'epoch': 1
}
valid_ckpt_path = os.path.join(temp_dir, 'checkpoint_001.pth')
torch.save(valid_checkpoint, valid_ckpt_path)

# Create an invalid checkpoint file (will fail to load)
invalid_ckpt_path = os.path.join(temp_dir, 'checkpoint_002.pth')
with open(invalid_ckpt_path, 'w') as f:
    f.write('invalid checkpoint content')

# Create another valid checkpoint file (newer, should be picked first)
valid_checkpoint_2 = {
    'model_state_dict': torch.randn(2, 4),
    'epoch': 2
}
valid_ckpt_path_2 = os.path.join(temp_dir, 'checkpoint_003.pth')
torch.save(valid_checkpoint_2, valid_ckpt_path_2)

# Ensure checkpoint_003 is newer than checkpoint_001
os.utime(valid_ckpt_path_2, None)

ARGS = {
    'output_dir': temp_dir
}
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 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
build_optimizer Ran
ran; our contract draft was wrong, not the code
edwardchasel/spatial-mamba/classification/utils/optimizer.py
code served (permissive licence) · get_code("00fc7f0336e999a0")
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 AdamW. 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
from torch import optim
from unittest.mock import MagicMock

torch.manual_seed(0)

# Create a minimal model with parameters
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear1 = nn.Linear(4, 3)
        self.bn = nn.BatchNorm1d(3)
        self.linear2 = nn.Linear(3, 2)
    
    def forward(self, x):
        x = self.linear1(x)
        x = self.bn(x)
        x = self.linear2(x)
        return x

model = SimpleModel()

# Create a config object with all required attributes
class Config:
    class Train:
        class Optimizer:
            NAME = 'adamw'
            MOMENTUM = 0.9
            EPS = 1e-8
            BETAS = (0.9, 0.999)
        
        OPTIMIZER = Optimizer()
        BASE_LR = 0.001
        WEIGHT_DECAY = 0.0001
    
    TRAIN = Train()

config = Config()

# Create a mock logger
logger = MagicMock()
logger.info = MagicMock()

ARGS = {
    'config': config,
    'model': model,
    'logger': logger
}
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 AdamW — a AdamW output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a AdamW 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
build_scheduler Ran
ran; our contract draft was wrong, not the code
edwardchasel/spatial-mamba/classification/utils/lr_scheduler.py
code served (permissive licence) · get_code("0fbdf3257aea9bcc")
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 LinearLRScheduler. 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
import torch.optim as optim
from types import SimpleNamespace

torch.manual_seed(0)

# Create a minimal model for the optimizer
model = nn.Linear(4, 3)

# Create an optimizer
optimizer = optim.SGD(model.parameters(), lr=0.1)

# Create a minimal config object with all required attributes
config = SimpleNamespace(
    TRAIN=SimpleNamespace(
        EPOCHS=10,
        WARMUP_EPOCHS=2,
        WARMUP_LR=0.0,
        MIN_LR=0.00001,
        LR_SCHEDULER=SimpleNamespace(
            NAME='linear',
            DECAY_EPOCHS=5,
            DECAY_RATE=0.1,
            GAMMA=0.1,
            WARMUP_PREFIX=False,
            MULTISTEPS=[3, 6, 9]
        )
    )
)

# n_iter_per_epoch parameter
n_iter_per_epoch = 100

ARGS = {
    'config': config,
    'optimizer': optimizer,
    'n_iter_per_epoch': n_iter_per_epoch
}
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 LinearLRScheduler — a LinearLRScheduler output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a LinearLRScheduler 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
check_keywords_in_name Ran
ran, violated the contract we drafted
edwardchasel/spatial-mamba/classification/utils/optimizer.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from leaplabthu/inline, is pointer only (licence: NONE) · get_code("b0a5beb34716d5a6")
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 leaplabthu/inline, 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.

create_logger Ran
ran; our contract draft was wrong, not the code
edwardchasel/spatial-mamba/classification/utils/logger.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from ghrua/seqpe, is pointer only (licence: NONE) · get_code("80450600f7f09b0a")
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 ghrua/seqpe, 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.

flops_selective_scan_fn Ran
ran, honoured the contract we drafted
edwardchasel/spatial-mamba/classification/models/utils.py
code served (permissive licence) · get_code("d1a00af9c7447534")
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

torch.manual_seed(0)

ARGS = {
    "B": 2,
    "L": 256,
    "D": 768,
    "N": 16,
    "with_C": True,
    "with_D": True,
    "with_Z": False,
    "with_complex": 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 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
get_grad_norm Ran
ran, honoured the contract we drafted
edwardchasel/spatial-mamba/classification/utils/utils.py
code served (permissive licence) · get_code("eec1e7cba51d5e8e")
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) and returned float, ndim 0, dtype family float, 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)

# Create a simple model with parameters that have gradients
model = nn.Linear(4, 3)

# Forward pass to create some gradients
x = torch.randn(2, 4)
y = model(x)
loss = y.sum()
loss.backward()

# Now model.parameters() have gradients attached
parameters = list(model.parameters())

ARGS = {
    "parameters": parameters,
    "norm_type": 2
}
Setup block drafted by
a language model, Claude Haiku 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 float, ndim 0, dtype family float, 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
import_abspy Ran
ran; our contract draft was wrong, not the code
EdwardChasel/Spatial-Mamba/detection/model.py
code served (permissive licence) · get_code("5315806d8b42f938")
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) and returned module. 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 os
import sys
import tempfile
import importlib.util

# Create a temporary directory structure for testing
temp_dir = tempfile.mkdtemp()
classification_dir = os.path.join(temp_dir, 'classification')
os.makedirs(classification_dir, exist_ok=True)

# Create a simple models.py module in the classification directory
models_file = os.path.join(classification_dir, 'models.py')
with open(models_file, 'w') as f:
    f.write("""
# Dummy models module
class DummyModel:
    pass

def dummy_function():
    return "models module loaded"
""")

# Create __init__.py to make it a package
init_file = os.path.join(classification_dir, '__init__.py')
with open(init_file, 'w') as f:
    f.write("")

ARGS = {
    'name': 'models',
    'path': classification_dir
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type module — a module output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a module 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
set_weight_decay Ran
ran; our contract draft was wrong, not the code
edwardchasel/spatial-mamba/classification/utils/optimizer.py
code served (permissive licence) · get_code("2d5473f673967c35")
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 as nn

torch.manual_seed(0)

# Create a small model for testing
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        # Add parameters with different shapes
        self.linear1 = nn.Linear(4, 3)
        self.linear2 = nn.Linear(3, 2)
        self.bn = nn.BatchNorm1d(3)
        self.embedding = nn.Embedding(5, 4)
    
    def forward(self, x):
        return x

model = SimpleModel()

# Create skip_list with a parameter name that exists in the model
skip_list = ('embedding.weight',)

# Create skip_keywords with common keywords to skip (e.g., 'bias', 'norm')
skip_keywords = ('norm',)

ARGS = {
    'model': model,
    'skip_list': skip_list,
    'skip_keywords': skip_keywords,
}
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
get_config Not yet run
unverified (harvested, no recorded run)
edwardchasel/spatial-mamba/classification/config.py
code served (permissive licence) · get_code("3760f0a84c81308d")
How it ran

no invocation recorded.

load_checkpoint_ema Not yet run
unverified (harvested, no recorded run)
edwardchasel/spatial-mamba/classification/utils/utils.py
code served (permissive licence) · get_code("c3565ec7e9c7f4df")
How it ran

no invocation recorded.

selective_scan_flop_jit Not yet run
unverified (harvested, no recorded run)
edwardchasel/spatial-mamba/classification/models/utils.py
code served (permissive licence) · get_code("994608c8957905d6")
How it ran

no invocation recorded.

selective_scan_state_flop_jit Not yet run
unverified (harvested, no recorded run)
edwardchasel/spatial-mamba/classification/models/utils.py
code served (permissive licence) · get_code("2cbc0f8f150c8aae")
How it ran

no invocation recorded.

update_config Not yet run
unverified (harvested, no recorded run)
edwardchasel/spatial-mamba/classification/config.py
code served (permissive licence) · get_code("13920ae73055d5cf")
How it ran

no invocation recorded.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 14 distinct functions with an identity, 11 are also present in other papers whose code we hold (7 with at least one paper dated earlier, 0 the same month, 11 later) and 3 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
get_config 51 other papers
39 dated earlier, 8 later, 4 same year, order not determinable
2103.14030 (2021-03)
Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
2106.03650 (2021-06)
Shuffle Transformer: Rethinking Spatial Shuffle for Vision Transformer
2106.03746 (2021-06)
Efficient Training of Visual Transformers with Small Datasets
and 48 more not named here
create_logger 35 other papers
29 dated earlier, 4 later, 2 same year, order not determinable
2104.13840 (2021-04)
Twins: Revisiting the Design of Spatial Attention in Vision Transformers
2106.03650 (2021-06)
Shuffle Transformer: Rethinking Spatial Shuffle for Vision Transformer
2106.03746 (2021-06)
Efficient Training of Visual Transformers with Small Datasets
and 32 more not named here
check_keywords_in_name 31 other papers
24 dated earlier, 5 later, 2 same year, order not determinable
2103.14030 (2021-03)
Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
2106.03650 (2021-06)
Shuffle Transformer: Rethinking Spatial Shuffle for Vision Transformer
2106.03746 (2021-06)
Efficient Training of Visual Transformers with Small Datasets
and 28 more not named here
get_grad_norm 23 other papers
17 dated earlier, 4 later, 2 same year, order not determinable
1910.13616 (2019-10)
Multimodal Model-Agnostic Meta-Learning via Task-Aware Modulation
2103.14030 (2021-03)
Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
2106.03650 (2021-06)
Shuffle Transformer: Rethinking Spatial Shuffle for Vision Transformer
and 20 more not named here
build_scheduler 3 other papers
2 dated earlier, 1 later
2407.10240 (2024-07)
xLSTMTime : Long-term Time Series Forecasting With xLSTM
2407.19394 (2024-07)
Depth-Wise Convolutions in Vision Transformers for Efficient Training on Small Datasets
import_abspy 3 other papers
2 dated earlier, 1 later
2403.09977 (2024-03)
EfficientVMamba: Atrous Selective Scan for Light Weight Visual Mamba
2407.18559 (2024-07)
VSSD: Vision Mamba with Non-Causal State Space Duality
set_weight_decay 2 other papers
1 dated earlier, 1 later
2404.07794 (2024-04)
DGMamba: Domain Generalization via Generalized State Space Model
auto_resume_helper 1 other paper
1 later
Xie_PVMamba_Parallelizing_Vision_Mamba_via_Dynamic_State_Aggregation_ICCV_2025_paper (2025 (year only))
PVMamba: Parallelizing Vision Mamba via Dynamic State Aggregation
build_optimizer 1 other paper
1 later
Xie_PVMamba_Parallelizing_Vision_Mamba_via_Dynamic_State_Aggregation_ICCV_2025_paper (2025 (year only))
PVMamba: Parallelizing Vision Mamba via Dynamic State Aggregation
load_checkpoint_ema 1 other paper
1 later
Xie_PVMamba_Parallelizing_Vision_Mamba_via_Dynamic_State_Aggregation_ICCV_2025_paper (2025 (year only))
PVMamba: Parallelizing Vision Mamba via Dynamic State Aggregation
update_config 1 other paper
1 later
Xie_PVMamba_Parallelizing_Vision_Mamba_via_Dynamic_State_Aggregation_ICCV_2025_paper (2025 (year only))
PVMamba: Parallelizing Vision Mamba via Dynamic State Aggregation

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

Selective state space models (SSMs), such as Mamba (Gu & Dao, 2023), highly excel at capturing long-range dependencies in 1D sequential data, while their applications to 2D vision tasks still face challenges. Current visual SSMs often convert images into 1D sequences and employ various scanning patterns to incorporate local spatial dependencies. However, these methods are limited in effectively capturing the complex image spatial structures and the increased computational cost caused by the lengthened scanning paths. To address these limitations, we propose Spatial-Mamba, a novel approach that establishes neighborhood connectivity directly in the state space. Instead of relying solely on sequential state transitions, we introduce a structure-aware state fusion equation, which leverages dilated convolutions to capture image spatial structural dependencies, significantly enhancing the flow of visual contextual information. Spatial-Mamba proceeds in three stages: initial state computation in a unidirectional scan, spatial context acquisition through structure-aware state fusion, and final state computation using the observation equation. Our theoretical analysis shows that Spatial-Mamba unifies the original Mamba and linear attention under the same matrix multiplication framework, providing a deeper understanding of our method. Experimental results demonstrate that Spatial-Mamba, even with a single scan, attains or surpasses the state-of-the-art SSM-based models in image classification, detection and segmentation. Source codes and trained models can be found at https://github.com/EdwardChasel/Spatial-Mamba.

For agents

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

get_harvested_code_for_paper("2410.15091")
get_code_for_paper("2410.15091")
have("2410.15091")

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

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

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

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

Connect an agent — have() is free.