Back to paper library
Paper notesarXiv 2024CVPR 2025

MambaOut

Exit the Mamba

Original paper

MambaOut: Do We Really Need Mamba for Vision?

Paper authors

Weihao Yu · Xinchao Wang

Publication
CVPR 2025Conference
First submitted to arXiv
arXiv:2405.07992
Cite this paper · BibTeX

The citation identifies the linked source version. It cites the original paper and its authors.

@misc{mambamambaout2024,
  title = {{MambaOut: Do We Really Need Mamba for Vision?}},
  author = {Weihao Yu and Xinchao Wang},
  year = {2024},
  eprint = {2405.07992},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.07992}
}
On this page

The dedication page of this paper reads: In memory of Kobe Bryant.

Below it is the line that closed Kobe's 2016 NBA farewell speech: “What can I say, Mamba out.” Black Mamba was Kobe's nickname, and “Mamba out” is the Mamba leaving the stage.

When we read Mamba, we said it marked the beginning of a new era of papers. The vision community did react quickly: Vision Mamba and VMamba appeared one after the other in January 2024, followed by LocalMamba, PlainMamba, and EfficientVMamba, putting Mamba into all kinds of backbones for classification, detection, and segmentation.

Less than half a year later, Weihao Yu and Xinchao Wang of the National University of Singapore wrote this paper, whose title asks directly whether vision really needs Mamba.

If you've read our PoolFormer and CAFormer notes, you'll recognize the first author. He has long been asking the same kind of question, about which component actually deserves the credit when a model performs well.

Defining the Problem

The authors notice that the results of these vision Mamba models often aren't impressive next to the best convolutional or attention models of the time.

So what is Mamba suited for? And do vision tasks fit that profile? The authors first answer these two questions conceptually, then test their answers with a set of models that deliberately leave out the SSM.

Solving the Problem

What Kind of Task Suits Mamba?

Two-column schematic. Left column, Causal attention: at step one the old memory is empty, and after adding x1 the new memory stores k1, v1; at step two the new memory holds two pairs, k1 v1 and k2 v2; at step three it holds three, so memory grows with the number of steps. Right column, RNN-like: at every step the old hidden state h and the new input are fused into a new state of the same size, h0 to h1, h1 to h2, h2 to h3
Figure 2 from the paper, excerpted from page 4 of the v3 PDF. Causal attention is on the left; RNN-like models are on the right.

This figure lays out the two ways of remembering very clearly.

On the left, causal attention adds each token's key and value to memory as it reads. Every position's key and value is kept, at the cost of a memory that keeps growing, so that at step three the new input is computed together with three key–value pairs, and at step one thousand with a thousand.

On the right, RNN-like models, including Mamba's SSM, fuse the old state and the new input into a new state of the same size at every step. The cost of fusing is fixed, but the state's size is limited, so old information is inevitably compressed or dropped.

From this, the authors derive two conditions under which Mamba is a good fit:

  1. The sequence must be long enough. With short sequences, attention isn't expensive yet and still keeps every position's key and value, so the authors argue Mamba has a hard time gaining an edge; only when sequences are long enough does attention's quadratic cost become a burden.
  2. The task needs causal information flow. An SSM's recurrence can by nature only see the past and the present, which suits tasks that generate one token after another.

The second point needs a bit more explanation. The authors divide token mixing into two modes. In causal mode, the tt-th token can only see tokens 1 through tt; in fully-visible mode, every token can see all of them. Attention can do both; add a mask, and it becomes causal. A unidirectional RNN can only accumulate information in the direction it reads; to let each position see the context on both sides, you have to add a separate branch running in the opposite direction and merge the two. After merging, each position does have access to the whole input, but the information still has to pass through two fixed-size states, which is different from attention, where tokens look at each other directly. The authors classify this case as an extension of causal mode as well, and consider it less natural than fully-visible attention.

Image recognition is an understanding task in which the whole image is visible at once, with no need for a causal constraint. In a small experiment, the authors switched ViT's attention to causal mode, and its ImageNet accuracy dropped (Figure 3b in the paper).

Do Images Count as Long Sequences?

The first condition needs a yardstick. The authors use the computation of a Transformer block as the measure. With LL input tokens of DD dimensions each and an MLP expansion ratio of 4,

FLOPs=24D2L+4DL2,rL=4DL224D2L=L6D\text{FLOPs}=24D^2L+4DL^2,\qquad r_L=\frac{4DL^2}{24D^2L}=\frac{L}{6D}

When rLr_L exceeds 1, that is, when L>6DL>6D, the term quadratic in length outweighs the linear term, and the sequence can be considered long.

Let's work it out for the paper's three tasks, all with 16×16 patches. ImageNet classification at 224×224224\times224 has only 196 tokens, giving ViT-S an L/6DL/6D of 0.09, more than ten times below the threshold. COCO detection at 800×1280800\times1280 has 4,000 tokens and ADE20K segmentation at 512×2048512\times2048 has 4,096, putting ViT-S's L/6DL/6D at about 1.7, already past the threshold, and ViT-B's close to it at about 0.9.

So the authors propose two hypotheses:

  • Hypothesis 1: ImageNet classification is neither long nor causal, so it doesn't need an SSM.
  • Hypothesis 2: detection and segmentation aren't causal either, but their sequences are long enough that an SSM might still help.

Removing the SSM

The left panel shows the structure of two blocks: in the Gated CNN block, the input passes through two Linear layers and splits into two branches, one through Conv and the other through an activation function; the two branches are multiplied and then pass through a Linear layer. The Mamba block is the same, except that Conv is followed by an extra activation function and SSM. The right panel is a bubble chart of ImageNet Top-1 accuracy against computation, with the MambaOut curve above VMamba, PlainMamba, and Vision Mamba
Figure 1 from the paper, excerpted from page 1 of the v3 PDF. (a) omits normalization and residual connections; in (b), bubble size represents parameter count.

Look at the left panel: the two blocks are nearly identical. The authors write them as one and the same equation:

Y=(TokenMixer(X′W1)⊙σ(X′W2))W3+XY=\big(\text{TokenMixer}(X'W_1)\odot\sigma(X'W_2)\big)W_3+X

X′X' is the normalized input. One branch goes through the token mixer, the other through an activation function that serves as a gate; the two are multiplied elementwise, then projected back to the original dimension. The only difference is the token mixer:

TokenMixerGated CNN(Z)=Conv(Z),TokenMixerMamba(Z)=SSM(σ(Conv(Z)))\text{TokenMixer}_{\text{Gated CNN}}(Z)=\text{Conv}(Z),\qquad \text{TokenMixer}_{\text{Mamba}}(Z)=\text{SSM}\big(\sigma(\text{Conv}(Z))\big)

A Mamba block is simply a Gated CNN with an SSM appended after the convolution.

So remove the SSM from a Mamba block, and what's left is a Gated CNN. The authors stack it into a family of models named MambaOut:

  • The token mixer is a 7×7 depthwise convolution, following ConvNeXt; for real-world speed, only some of the channels are convolved, following InceptionNeXt.
  • Like ResNet, the network has four stages, with downsampling between them.
  • There are four sizes, from the smallest, Femto, up to Base.

This design is a baseline without an SSM, built to see how far one can get. Still, it differs from the various vision Mambas by more than just an SSM, since the way the convolution is set up, the block design, and the stage configuration all differ. So even if MambaOut does better, strictly speaking it proves that “this level can be reached without an SSM”; how much the SSM itself contributes can only be measured by removing it from the same backbone.

Discussion

ImageNet Classification

Training follows the DeiT recipe, without distillation, at an input size of 224×224. Here are a few groups with similar parameter counts:

Table: Excerpted from Table 1 of the paper.
ModelParams (M)MACs (G)Top-1 (%)
Vim-Ti71.576.1
EfficientVMamba-S111.378.7
MambaOut-Femto71.278.9
VMamba-T225.682.2
LocalVMamba-T265.782.7
MambaOut-Tiny274.582.7
LocalVMamba-S5011.483.7
VMambaV9-S508.783.6
MambaOut-Small489.084.1
VMambaV9-B8915.483.9
MambaOut-Base8515.884.2

At every scale, MambaOut matches or beats the vision Mambas that do have SSMs. Taking Small as an example, MambaOut is 0.4 percentage points above LocalVMamba-S with only 79% of its computation; compared with VMambaV9, however, MambaOut's MACs are slightly higher.

The paper's Table 1 holds another pair of numbers to set side by side. CAFormer-M36 reaches 85.2% with 56M parameters and 13.2G MACs, while VMambaV9-B, with more parameters (89M, 15.4G), gets 83.9%. In other words, to judge whether an SSM is worth using, the strongest convolutional and attention backbones also belong in the comparison.

Detection and Segmentation

Switch to long-sequence tasks, and the result flips. On COCO, with Mask R-CNN and a 1× training schedule:

Table: Excerpted from Table 2 of the paper.
BackboneAP (box)AP (mask)
MambaOut-Tiny45.141.0
VMamba-T46.542.1
LocalVMamba-T46.742.2
VMambaV9-T47.442.7

MambaOut-Tiny trails VMamba-T by 1.4 box AP and 1.1 mask AP. ADE20K semantic segmentation is similar, with MambaOut-Tiny's single-scale mIoU of 47.4 about the same as VMamba-T's 47.3 but below LocalVMamba-T's 47.9 and VMambaV9-T's 48.3.

The authors take this as support for Hypothesis 2, that the SSM may indeed help when sequences are long enough. As with classification, though, the comparison here is between different overall architectures, so this result is better treated as a lead for further research.

Still, they don't have many kind words for vision Mamba either. In both tables, COCO (Table 2, Mask R-CNN) and ADE20K (Table 3, UperNet), the convolution-plus-attention TransNeXt leads vision Mambas of the same class; on ADE20K, for example, TransNeXt-Tiny reaches a single-scale mIoU of 51.1.

The Limits of This Yardstick

The L>6DL>6D threshold measures when a single Transformer block's computation becomes dominated by the quadratic term. It's a convenient rule of thumb, but it can't prove that a given task “necessarily needs” a linear-time model. This note further speculates that detection and segmentation backbones often use window attention or hierarchical downsampling to keep costs down, so the burden of the quadratic term may never actually materialize.

The evidence for Hypothesis 2 is also somewhat weaker than for Hypothesis 1. In the Tiny group above, the detection gaps are 1.4 to 2.3 box AP and 1.1 to 1.7 mask AP, and on segmentation some vision Mambas don't beat MambaOut. The paper makes a strong case that “ImageNet classification doesn't need an SSM”; as for “long-sequence vision tasks need an SSM,” that's closer to “worth further study.”

Conclusion

This paper answers its title with a simple baseline:

  1. The authors argue that Mamba suits long, causal tasks. A fixed-size memory gains nothing on short sequences, and a unidirectional recurrence only accumulates information in the direction it reads.
  2. ImageNet classification meets neither condition. MambaOut, without an SSM, matches or beats vision Mamba at every listed scale; whether its MACs come out higher or lower depends on the comparison.
  3. Detection and segmentation are long-sequence tasks, and there an SSM may help a little. MambaOut loses here to the best vision Mambas, but all the vision Mambas in turn lose to stronger hybrids of convolution and attention.

Vision Mamba's flame had barely caught and was about to roar into a blaze when it was snuffed out, just like that.

Ah, such is life.