VMamba — Scanning an Image Four Ways

  1. 1Mamba — Selective State Spaces, Step by Step
  2. 2Mamba-2 — When a State Space Model Is a Masked Attention Matrix
  3. 3Mamba-3 — A Better Step, a Turning State, More Work per Byte
  4. 4VMamba — Scanning an Image Four Ways
  5. 5Mamba in RT-DETRv4 — What Could Make It Faster

Summary

A scan reads one token after another, and an image has no first pixel. VMamba reads every feature map four ways, across and down, forwards and backwards, and adds the answers. This post shows which pixels one, two and four scans let a pixel see, the released VSS block with its state of size one, VMamba's results, and MambaOut's check of whether vision needs the scan at all.

Table of Contents

  1. 1. Why One Scan Is Not Enough2
  2. 2. SS2D: Four Routes, One Sum2
  3. 3. The VSS Block: What Is Left of Mamba?3
  4. 4. Results3
  5. 5. MambaOut: Do We Even Need the Scan?3
  6. 6. Conclusion3
  7. 7. References3
  8. 8. Connections3
TrivediInformational[Page 1]
S. TrivediOct 2026

The selective scan of Mamba — Selective State Spaces, Step by Step is causal: token t only hears the tokens before it. Fine for text. A flattened image has no order, and the pixel just above you sits a whole row back.

Think of a crossword. Read only the "across" clues and you never meet the letters running "down", even though they share your squares. VMamba [LIU24] reads every grid across and down, forwards and backwards, and lets each square keep all four readings.

Brush up ;)

Width is D here (VMamba writes C, but C is already the scan's read-out), state size N, expansion ratio r.

1. Why One Scan Is Not Enough

Take a 4 × 4 grid flattened row by row, and the pixel at row 2, column 2:

  • One scan (rows, left to right): it hears 6 of 16 pixels. Nothing below it.
  • Two scans (rows, both ways): 16 of 16.
  • Four scans (rows and columns, both ways): still 16 of 16, but the pixel above is now 1 step away instead of 4.

So two directions give reach; four give nearness in both axes.

1 / 3 · one (rows)4100
Toy
0.2
Four ways to read a grid. Each small grid is one route, numbered in the order the scan reads it; the rust dashes are the jumps back to the start of the next row or column, as in the released code. Drag the ring to pick a pixel. In the reach view the shaded cells are the ones whose information can arrive at it; the nearness view is a toy with one fixed decay per step (the real step size depends on the input), and the measured version is Tab. 10.

The shaded cells are what the ringed pixel can hear. Press "two scans", then "four scans", and watch the step count to the pixel above.

Vim [ZHU24] was the two-way answer: ViT patches, and each block scans forwards and backwards with its own conv and S6, then adds the two. Its ablation (Tab. 4, tiny model): a backward scan with its own conv moves ImageNet top-1 from 73.2 to 73.9 and ADE20K mIoU from 32.3 to 35.9. The gain shows most on segmentation.

2. SS2D: Four Routes, One Sum

VMamba's module is SS2D, the 2-D selective scan. On a 3 × 3 map:

  • route 1, rows: 1, 2, 3, 4, 5, 6, 7, 8, 9;
  • route 2, columns: 1, 4, 7, 2, 5, 8, 3, 6, 9;
  • routes 3 and 4: the same two, reversed.

NOTE: these are raster orders, not snakes. At the end of each row the scan jumps back to the start of the next (Fig. 2, and the released code).

Each route gets its own S6; unscan folds it back onto the grid, and the four are summed:

y=∑k=14unscank(S6k(scank(x)))(1)
  • Four routes, four sets of S6 weights (Δ, B, C projections and A).
  • The merge is a plain sum, no learned weights, then a LayerNorm.

How near is near? A toy: give every step the same decay aΔ and see how much of each pixel survives to the ring.

3 / 3 · four (cross-scan)7100
Toy
0.2
Four ways to read a grid. Each small grid is one route, numbered in the order the scan reads it; the rust dashes are the jumps back to the start of the next row or column, as in the released code. Drag the ring to pick a pixel. In the reach view the shaded cells are the ones whose information can arrive at it; the nearness view is a toy with one fixed decay per step (the real step size depends on the input), and the measured version is Tab. 10.

At aΔ = 0.2 on 7 × 7, the pixel to the left keeps 0.819 with any route. The pixel above keeps 0.247 with one or two scans, 0.819 with four. Diagonals stay far. In the real model Δ depends on the input, so this is a picture, not a measurement. The measurement is Tab. 10:

Scantop-1, with DWConvtop-1, withoutimg/s
Rows, one way82.2680.881682
Rows, both ways82.4981.801687
Rows, then columns82.4281.71998
Four routes82.6082.251686

Table. 1 Scan patterns on VMamba-T, with and without the 3 × 3 depthwise conv; throughput with the conv (Tab. 10 of [LIU24]).

  • With the conv, four routes buy +0.34 over one; without it, +1.37. The 3 × 3 conv already carries much of the 2-D picture.
  • Four routes side by side cost almost nothing over one. Chaining rows into columns costs 41 % of the throughput.
TrivediInformational[Page 1]
S. TrivediOct 2026

3. The VSS Block: What Is Left of Mamba?

The released block is two residual halves, like a Transformer block:

x←x+SS2D(LN(x))x←x+FFN(LN(x))(2)
LNlineardepthwise convSiLUSS2DLNgate branchlinearSiLUlinear(c) the first VSS blockLNSS2DblockLNFFN(d) the released VSS blocklinear D → rDdepthwise convSiLUSS2Dfour routes,summedLNlinear rD → D
Fig. 1 The first VSS block (left, Fig. 3 (c) of [LIU24]) and the released one (right, Fig. 3 (d)): the gate goes, an FFN arrives.
  • The gate is gone. The authors say the selectivity of SS2D already does its job (§4.1).
  • No position embeddings (§4.1).
  • State N = 1, against Mamba's 16. Tab. 12 (at r = 2): N = 1 / 2 / 4 gives 82.49 / 82.50 / 82.51 top-1 while throughput falls. So the memory is one decaying running sum per channel per route; the selection (Δ, B, C from the token) stays.

The first block was closer to Mamba: state 16, the gate, no FFN. Tab. 5 walks from it to the released one, one change at a time:

12 / 12 · (g) released
From the first block to the released one. VMamba-T, one change at a time, each on top of the last: images per second against ImageNet top-1, as printed in Tab. 5 (A100, batch 128). Steps (a)–(c) are faster code for the same network, so their accuracy does not move. Press play and watch where the speed comes from.
  • 426 → 1,686 img/s (3.96×) for +0.43 top-1 (82.17 → 82.60).
  • The biggest single jump is state 16 → 1: +778 img/s for −0.44. Later width and depth changes win the accuracy back.

4. Results

The layout is Swin's: four stages at strides 4, 8, 16 and 32, VSS blocks inside. Throughput on one A100.

ModelParamsimg/sImageNet top-1COCO box APADE20K mIoU
Swin-T28 M124481.342.744.5
ConvNeXt-T29 M119882.144.246.0
VMamba-T30.2 M168682.647.347.9
VMamba-S50.1 M87783.648.750.6
Swin-B88 M45883.546.948.1
VMamba-B88.6 M64683.949.251.0

Table. 2 ImageNet at 224², COCO with Mask R-CNN [HE17] 1× schedule, ADE20K with UperNet single scale (Tabs. 1, 2 and 4 of [LIU24]; Swin [LIU21] and ConvNeXt [LIU22] as it quotes them).

  • VMamba-T beats Swin-T by 1.3 top-1 and 4.6 box AP.
  • VMamba-B beats Swin-B and runs 646 against 458 img/s.
  • Trained at 224 and tested at 768 with no fine-tuning, VMamba-T keeps 74.66 top-1 against DeiT-S's [TOUV21] 60.98 (Tab. 9). Its cost grows with the pixel count, not its square.

5. MambaOut: Do We Even Need the Scan?

MambaOut [YU24] deletes the SSM from the Mamba block. What is left is a Gated CNN [DAUP17] with a 7 × 7 depthwise conv.

  • Its rule: a sequence is long when L > 6D, where a Transformer block's L² term passes its linear ones.
  • Its claim: the SSM is not needed for ImageNet (short sequences), but may still help detection and segmentation (long ones).

A hierarchical backbone is long early. L / 6D per VMamba-T stage, my arithmetic:

  • 224 × 224: 5.44, 0.68, 0.09, 0.01;
  • 800 × 1280 (COCO): 111, 13.9, 1.74, 0.22.

Stage 1 is already "long" at 224². On a COCO image three of the four stages are.

3 / 7 · VMamba-T stage 3224
RT-DETRv4 only
Tokens, cost and MambaOut's line. Multiply-adds, not time, on a log scale: one token mixer (or one whole block, with its feed-forward layer) at each place, for VMamba's scan, global attention and 7 × 7 windows. The shaded places are the ones MambaOut would call long, L > 6D, its line for a block with a feed-forward layer of 4D. My count; for the whole VMamba-T it lands within 1 % of the paper's.

Press "VMamba-T at 640" and look at stage 1: global attention there is 126.8 G multiply-adds for one mixer, SS2D 0.73 G.

Now MambaOut against the final VMamba (its own tables quote earlier versions):

SizeImageNet: MambaOutVMambaCOCO box: MambaOutVMambaADE20K SS: MambaOutVMamba
Tiny82.782.645.147.347.447.9
Small84.183.647.448.749.550.6
Base84.283.947.449.249.651.0

Table. 3 Tabs. 1–3 of [YU24] against Tabs. 1–2 of [LIU24]. The Tiny pairing is mine.

  • ImageNet: MambaOut ahead at every size, by 0.1 to 0.5.
  • COCO and ADE20K: VMamba ahead, by 1.3 to 2.2 box AP and 0.5 to 1.4 mIoU.

Both of MambaOut's hypotheses hold: no scan needed on ImageNet, and a real gap on the dense tasks, where most stages are long.

6. Conclusion

  • A causal scan on a flattened image only hears what came before, and the pixel above is a row away.
  • VMamba reads each map along four raster routes and sums them: every pixel is reached, and its four neighbours are one step away.
  • The released block keeps the selection, drops the gate, adds an FFN and shrinks the state to N = 1, for 3.96× the first block's speed.
  • MambaOut wins ImageNet with no scan and loses COCO and ADE20K.

Next: does any of this belong in a real-time detector? Mamba in RT-DETRv4 — What Could Make It Faster works it out. Stay tuned.

7. References

  1. [LIU24] Liu et al. VMamba: Visual State Space Model. NeurIPS 2024, arXiv 2401.10166 (v4).
  2. [ZHU24] Zhu et al. Vision Mamba: Efficient Visual Representation Learning with Bidirectional State Space Model. ICML 2024, arXiv 2401.09417.
  3. [YU24] Yu, Wang. MambaOut: Do We Really Need Mamba for Vision? arXiv 2405.07992.
  4. [GU23] Gu, Dao. Mamba: Linear-Time Sequence Modeling with Selective State Spaces. arXiv 2312.00752.
  5. [DAUP17] Dauphin et al. Language Modeling with Gated Convolutional Networks. ICML 2017, arXiv 1612.08083.
  6. [DOSO20] Dosovitskiy et al. An Image is Worth 16x16 Words. arXiv 2010.11929.
  7. [TOUV21] Touvron et al. Training data-efficient image transformers & distillation through attention. arXiv 2012.12877.
  8. [LIU21] Liu et al. Swin Transformer. arXiv 2103.14030.
  9. [LIU22] Liu et al. A ConvNet for the 2020s. arXiv 2201.03545.
  10. [HE17] He, Gkioxari, Dollár, Girshick. Mask R-CNN. arXiv 1703.06870.

8. Connections

What this page builds on, cites or links to, and what points back at it. A plain box is a “builds on”; “cited” and “linked in the text” are the lighter links. Hover a box for a preview.

POINTS AT THIS PAGEREADMamba in RT-DETRv4 — What Could Make ItFasterREAD · CITEDVision Transformers Today — May 2022 toOctober 2026, Year by YearPAPER · LINKED IN THE TEXTMamba-3 — A Better Step, a TurningState, More Work per ByteThis pageTHIS PAGE POINTS ATREADVision Transformers Today — May 2022 toOctober 2026, Year by YearPAPERAn Image Is Worth 16×16 Words — ViT,Patch by PatchPAPERSwin Transformer — Windows, Shifts and aPyramid for Dense PredictionPAPERMamba — Selective State Spaces, Step byStepPAPERMamba-3 — A Better Step, a TurningState, More Work per BytePAPER · CITEDDeiT — Training a Vision Transformer onImageNet AloneREFERENCE · CITEDA ConvNet for the 2020sREFERENCE · CITEDMambaOut: Do We Really Need Mamba forVision?REFERENCE · CITEDVision Mamba: Efficient VisualRepresentation Learning withBidirectional State Space ModelREFERENCE · CITEDMask R-CNNREFERENCE · CITEDLanguage Modeling with GatedConvolutional NetworksREAD · LINKED IN THE TEXTMamba in RT-DETRv4 — What Could Make ItFaster

Related

Go deeper

  1. Start with
    Read
  2. Paper
  3. Paper
  4. Paper
  5. Paper
  6. Read
  7. Read
  8. Paper
  9. Read
  10. Paper
  11. Paper
  12. Paper
  13. Paper
  14. Paper
  15. Read
  16. Paper
  17. Paper
  18. Read
  19. Paper
  20. Paper
  21. Paper
  22. You are here
    VMamba — Scanning an Image Four Ways
    Paper
  23. Then
    Read

Go broader

<- Older [Page 3]