Vision Mamba

Machine Learning
Introduced by
Li Zhu
Year
2024
Type
Neural network architecture
Family
Deep Learning, State Space Models

What does it do?

Vision Mamba is a state space model approach to image understanding, introduced in 2024, that adapts Mamba, a sequence model with linear complexity in sequence length, to computer vision.

It reformulates an image as a sequence of patch tokens and processes that sequence with state space layers instead of self-attention. The original work reports accuracy competitive with transformers on image classification.

The intuition behind the method

Transformers model global relationships through self-attention, whose cost grows quadratically with the number of tokens. Vision Mamba instead passes patch tokens through state space layers, which keep a hidden state that is updated one patch at a time, so the cost grows linearly with the number of patches. Because a pass in one direction gives earlier patches little access to later ones, the model processes the patch sequence in both directions, so that information from later patches can reach earlier ones. The benefit is that long sequences, such as high-resolution images split into many patches, are cheaper to process than with full attention. The trade-off is that information must pass through a compressed hidden state rather than being compared directly between every pair of patches.

History

Vision Mamba is attributed to L. Zhu and colleagues and dated to 2024, when it was published at the International Conference on Machine Learning (ICML). The work presents state space models as able to achieve accuracy competitive with transformers on image classification. It belongs to a wider line of research seeking efficient alternatives to transformers in computer vision.

When to use it

Choose Vision Mamba when the number of image patches is large, for example for high-resolution inputs, and the cost of quadratic attention is a practical constraint. It is also a candidate when low inference latency matters and a transformer-style backbone is acceptable in principle. Avoid it when the task depends on mature tooling, many pre-trained variants, or well-established transformer baselines, because the ecosystem around it is smaller. It is also a poor first choice when the dataset is small and a well-tuned transformer baseline is already available, since its accuracy on small datasets should be compared directly against that baseline before adoption.

Limitations and considerations

  • Performance on small-scale benchmarks may be weaker than that of well-tuned transformer baselines, so comparisons should be run on the target dataset.
  • The set of pre-trained variants and supporting tools is smaller than for vision transformers, which can make adoption and transfer learning harder.
  • Bidirectional scanning adds design choices, such as whether both directions are used and how the sequence is ordered, that a single forward pass through a sequence does not require.
  • Key design choices, including the number of blocks, the state dimension and the scan setup, must be set for each application. Results on tasks beyond image classification should be checked against the cited paper, which is the reference for the configurations it tested.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Cost grows linearly with the number of patches, which makes high-resolution inputs with many tokens more tractable than with full self-attention.
  • The recurrent state formulation avoids computing and storing an explicit attention map over all patch pairs.
  • The state update for each patch has a fixed cost, so the model suits sequential or streaming processing of patches.
  • Its linear scaling in sequence length is the main advantage over quadratic-complexity attention for long token sequences.

Applications

  • Image classification on edge or mobile devices where latency and memory budgets are tight (a candidate use, not established by the cited work).
  • Video or frame-by-frame processing where the per-frame cost must stay low (a candidate use, not established by the cited work).
  • Analysis of high-resolution images, such as remote sensing scenes, where the number of patches is large (a candidate use, not established by the cited work).
  • Streaming vision tasks where low-latency processing is required, such as perception in autonomous driving (a candidate use, not established by the cited work).

How it works

How it works

1

The input image is divided into patches, and each patch is linearly embedded to form the initial token sequence.

2

The patch tokens are processed by state space layers that maintain a recurrent hidden state, which is updated as each patch is read, so no explicit pairwise attention matrix is computed.

3

The flattened patch sequence is processed in both directions, so that each patch's representation can incorporate context from patches on both sides of it in the sequence.

4

The final hidden states are projected to class logits or to feature representations for downstream tasks.

Common pitfalls

  • Flattening the two-dimensional patch grid into a sequence removes explicit two-dimensional adjacency, so the way spatial position is encoded matters and should be checked when the scan order is changed.
  • The state space parameters affect training stability, so their initialization should be treated as a design choice to verify rather than a default.
  • Comparisons with transformer baselines are only meaningful when pretraining data, input resolution and training schedule match; check these against the cited paper before drawing conclusions.

Frequently asked questions

How do state space models process images without attention?

A state space model keeps a hidden state that is updated as each patch is processed, using learned state matrices. Information from earlier patches is carried forward in this state rather than being compared directly with every other patch. Because the sequence is processed in both directions, patches that are far apart in one scan order can still influence each other through the accumulated state. Attention, by contrast, explicitly computes interactions between all pairs of tokens.

Why is bidirectional scanning necessary?

A one-directional scan gives patches near the end of the sequence more accumulated context than patches at the start, because earlier information has to pass through the state to reach later positions. Processing the sequence in both directions lets each patch's representation draw on context from both sides. The exact scan configuration should be checked against the cited paper before reuse.

How does Vision Mamba achieve linear complexity?

Attention requires O(N²) operations to compute similarities between all pairs of N tokens. A state space model instead performs a recurrent state update per patch, so the total cost grows as O(N) in the number of patches. This is why the approach is more practical than attention for long sequences and high-resolution images.

Related methods

Sources

  1. Zhu, L., Liao, B., Zhang, Q., Wang, X., Liu, W., & Wang, X. (2024). Vision Mamba: Efficient state space models for image understanding. In International Conference on Machine Learning.

    Open publication reference