Mamba
You can discretise state space models by hand, build Mamba-2's masked attention matrix, write Mamba-3's improved step rule, trace what pixels VMamba's scans reach, and locate where a scan fits in RT-DETRv4 with its cost.
-
Mamba — Selective State Spaces, Step by Step
- Attention keeps everything; Mamba compresses context into a small state where each token decides how much to write via a step size Δ.
- No fixed kernel anymore, so a fused parallel scan on GPU computes the recurrence fast: 7× faster than FlashAttention-2 at 32K tokens, 4–5× generation throughput.
-
Mamba-2 — When a State Space Model Is a Masked Attention Matrix
- Mamba-2 makes the state matrix a scalar per step so the whole layer becomes masked linear attention without softmax.
- Chunked computation runs matrix multiplies inside chunks and a short scan between them, doing 3.2x more arithmetic but up to 8x faster on A100.
- Swapping 6 of 48 layers for attention in a 350M model gives the best perplexity at 8.26, while pure Mamba-2 scores 8.60.
-
Mamba-3 — A Better Step, a Turning State, More Work per Byte
- Replaces Mamba-2's rectangle step with a learned trapezoid rule, adding a faded previous-input term; λ=1 recovers Mamba-2 exactly.
- MIMO (R=4) raises decode arithmetic intensity from 2.40 to 7.34 FLOPs/byte by batching inputs while keeping state size fixed.
- At 1.5B/100B tokens, Mamba-3 SISO beats Mamba-2 on zero-shot average; MIMO adds +1.2 points but trains ~2× slower.
-
VMamba — Scanning an Image Four Ways
- One scan on a flattened 4x4 grid lets a pixel see only 6 of 16 pixels; two scans reach all 16, and four scans make the pixel above just 1 step away instead of 4.
- SS2D runs four independent S6 scans (rows forward/back, columns forward/back) and sums the results with a plain addition and LayerNorm, no learned merge weights.
- The released VSS block drops Mamba's gate and position embeddings, shrinks state size to N=1 (from 16), and adds an FFN, gaining 3.96x speed for +0.43 top-1 accuracy.
- VMamba-T hits 82.6 top-1 at 1686 img/s, beating Swin-T by 1.3 points and 4.6 box AP; MambaOut matches ImageNet scores without scans but falls 1.3-2.2 box AP behind on COCO.
-
Mamba in RT-DETRv4 — What Could Make It Faster
- Not a paper but an idea still to be implemented; suggestions go to contact@shreejal.ai.
- At 640 × 640 AIFI sees only 400 tokens, so a scan cannot make it meaningfully cheaper in arithmetic.
- Try first a slimmer scan fusion block at P3, about 16 % less work for v4-S by my count.
- The one timed AIFI → scan swap ran 0.8–1.1 ms faster on an RTX 3090, but it moves the map the teacher trains on.
Other series
- 5 parts
- 11 parts
- 12 parts
- 5 parts
- 5 parts · VisionWizard