Mamba-ND: Selective State Space Modeling for Multi-dimensional Data

Shufan Li, Harkanwar Singh, Aditya Grover

Introduction: Overcoming the Transformer Scaling Wall

The deep learning landscape is currently witnessing a surge of interest in Mamba, a selective State Space Model (SSM) that offers the performance of Transformers with the efficiency of linear scaling. While Transformers have dominated computer vision and video modeling, they face a significant "scaling wall" due to the quadratic complexity ($O(L^2)$) of the self-attention mechanism. This means that as image resolution or video length increases, computational costs grow exponentially.

Mamba addresses this for 1D sequences by achieving linear complexity ($O(L)$). However, extending Mamba to multi-dimensional (ND) data like images and videos is non-trivial because these data types lack a single "natural" sequence order. Researchers from UCLA have introduced Mamba-ND, a framework designed to bring the benefits of selective SSMs to arbitrary multi-dimensional data.

The Mamba-ND Framework

The core innovation of Mamba-ND is its Alternating-Directional design. Rather than developing a complex multi-dimensional selective kernel, the authors utilize the standard 1D Mamba layer as a fundamental building block and focus on the data scanning strategy.

Architecture of the Mamba-ND framework and the underlying 1D-SSM block.

The process involves three main steps:

  1. Flattening and Scanning: Multi-dimensional inputs (e.g., 3D video volumes) are flattened into 1D sequences.
  2. Alternating Orders: To capture spatial and temporal relationships comprehensively, the model alternates scanning directions across successive layers. For 2D images, layers alternate between horizontal ($H+, H-$) and vertical ($W+, W-$) scans. For 3D data, temporal scans ($T+, T-$) are added.
  3. Block-Level Integration: The researchers found that simply stacking these 1D layers with different orderings is more effective than "layer-level" designs that attempt to process multiple directions within a single layer. This simplicity allows for a deeper computation graph, which is beneficial for learning complex features.

Experimental Evaluation

Mamba-ND was evaluated across a diverse set of multi-dimensional tasks, including 2D image classification (ImageNet-1K), 3D video action recognition (HMDB-51, UCF-101), 3D scientific data (ERA5 weather forecasting), and 3D medical imaging (BTCV segmentation).

Key Results

The empirical results demonstrate that Mamba-ND consistently outperforms popular Transformer models like ViT and Swin while being significantly more parameter-efficient.

Performance comparison between Mamba-ND and Transformer baselines across various multi-dimensional benchmarks.
  • ImageNet-1K: Mamba-2D-S achieved 81.7% accuracy with 24M parameters, outperforming a standard ViT-B (77.9% accuracy, 86M parameters).
  • Video Action Recognition: On HMDB-51, Mamba-3D reached 60.9% accuracy, surpassing Video-Swin-S (58.1%) with fewer parameters.
  • Weather Forecasting: On the ERA5 benchmark, Mamba-3D reduced the Root Mean Squared Error (RMSE) from 467 to 433 compared to the Transformer-based Cli-ViT, while using 44.5% fewer parameters.
  • Medical Segmentation: On the BTCV dataset, Mamba-3D-UNETR-B outperformed the standard UNETR by +3.3 DICE points, highlighting its effectiveness in high-precision 3D spatial tasks.

Insights and Future Directions

A key insight from this work is that simplicity often wins; the alternating 1D approach outperformed more complex multi-directional kernels. Furthermore, Mamba-ND provides a global receptive field in every layer, allowing it to relate distant pixels or frames in a single pass, unlike traditional CNNs.

Despite its successes, challenges remain. The current implementation of parallel scans can be memory-intensive, suggesting a need for more optimized CUDA kernels. Future work will also explore "scan factorization" to reduce memory overhead without sacrificing accuracy and investigate the performance of Mamba-ND at the scale of billions of parameters.

Summary updated

BibTeX
@inproceedings{li2024mamba,
  author = {Shufan Li and Harkanwar Singh and Aditya Grover},
  title = {{Mamba-ND: Selective State Space Modeling for Multi-dimensional Data}},
  booktitle = {European Conference on Computer Vision},
  year = {2024},
  doi = {10.1007/978-3-031-73414-4\_5},
}
Figure