Topic · Mechanisms

State space models

Everything on this site about state space models, in the order to read it: a page is listed after the pages it builds on. The figures below are the ones those pages use to explain it; each is live: move a slider and it recomputes.

In reading order

  1. Paper

The figures these pages use

Pulled from the pages above. Move a slider and the figure recomputes, exactly as on its page.

From Mamba — Selective State Spaces, Step by Step › 3. S4: Fixed Weights, So a Convolution

-1.01 / 4 · −1
One step of the memory. One channel, B = C = 1. Left: Ā (old state kept) and B̄ (new input written) against the step Δ. Right: the weight an input still has k steps later, the kernel of a fixed model. "As a gate" sets Δ = softplus(z) with A = −1, so Ā = 1 − σ(z) and B̄ = σ(z) (Theorem 1), with the paper's rule.

From Mamba — Selective State Spaces, Step by Step › 4. Selection: Let the Token Choose

0.52.00.011 / 2 · the 6-step check
A fixed filter against a choosing one. A toy with one channel (A = −1, B = C = 1). Filled squares are data tokens, empty ones noise. The fixed model uses one Δ everywhere, so every row is the row above shifted by one: a convolution. The choosing model takes a large Δ on data and a small one on noise, so its state holds between data tokens.

From Mamba — Selective State Spaces, Step by Step › 5. No Convolution, So How Is It Fast?

1 / 4 · the pairs
for what is kept
2 / 2 · 2560 (2.8B)11
How a recurrence runs in parallel. Eight steps of h_t = a_t · h_(t−1) + b_t with toy values, each a pair (a_t, b_t). Each round combines every slot with the one 1, 2, then 4 places to its left; after three rounds every slot holds h_t, the same as the loop on top. "What is kept": the values one layer holds while generating. Mamba's state does not grow with the length; a Transformer layer's K and V cache does.

From Mamba-2 — When a State Space Model Is a Masked Attention Matrix › 2. The Whole Layer Is One Matrix

0.91 / 3 · none2 / 3 · 3
The matrix behind the layer. The whole layer as one 9 × 9 matrix, a toy at the size of the paper's chunk example (T = 9, state size N = 2; the decays, B and C are my numbers). Row j is an output step, column i an input step. Blue cells are positive, rust negative, darker is larger. The mask L holds the decays, the scores hold C·B, and the layer's matrix M is the two multiplied cell by cell. The lines cut it into chunks; every block below the diagonal has rank at most 1 in L and at most N = 2 in M.

From Mamba-2 — When a State Space Model Is a Masked Attention Matrix › 4. Chunks: Matrix Multiplies Inside, a Scan Between

4 / 4 · states into outputs2 / 3 · 3
Four steps, one answer. A toy at the size of the paper's chunk example (my numbers): nine steps cut into chunks, a state of 2 × 2 numbers. Step through the four parts of the chunked algorithm. The bars are the outputs it has so far (blue: from inside the chunk; rust: from the state handed in), the dashed outlines the outputs computed step by step. After step 4 they are the same numbers. Chunks of 1 are the plain recurrence, one chunk of 9 is the plain matrix form.

From Mamba-2 — When a State Space Model Is a Masked Attention Matrix › 5. Why More Arithmetic Is Faster

3 / 4 · 1281 / 2 · 643 / 3 · 25611
FLOPs, not time. Arithmetic for one head as the sequence grows: the attention form (the whole T × T matrix), the plain scan, and the chunked algorithm (SSD). Counts, not time: SSD does about three times the scan's arithmetic and still runs faster, because it is all matrix multiplies. The dashed rule is the paper's measurement.

From Mamba-3 — A Better Step, a Turning State, More Work per Byte › 1. A Better Step

0.51 / 5 · Δ = 0.4
Hold one end or average both. A toy, h′ = −h + sin 3t. Left: one step's area; λ = 1 keeps the right end (Mamba-2), λ = ½ averages both ends. Right: the error at t = 4 as the step shrinks. Measured gain: Tab. 8, 15.81 → 15.72 perplexity.

From Mamba-3 — A Better Step, a Turning State, More Work per Byte › 2. A State That Can Turn

1 / 4 · sequence A0.910
Turning instead of shrinking. A toy, not a trained model. The arrow is a two-number state. Shrinking never changes its direction; turning by an input-set angle counts the ones, a fixed angle counts the steps. Measured (Tab. 5b): parity 100.00 with input angles, 1.56 fixed, 2.27 none.

From Mamba-3 — A Better Step, a Turning State, More Work per Byte › 3. More Work per Byte

Same memory traffic, more work. Left, from the formulas of Tab. 2: FLOPs per byte of one decode step as R grows, against an H100 matrix multiply (about 295, p. 9). Even R = 16 sits far below it. Right, measured: one decode step of the 1.5B models (Tab. 6, BF16, state size 128).

From VMamba — Scanning an Image Four Ways › 1. Why One Scan Is Not Enough

3 / 3 · four (cross-scan)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.

From VMamba — Scanning an Image Four Ways › 3. The VSS Block: What Is Left of Mamba?

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.

From VMamba — Scanning an Image Four Ways › 5. MambaOut: Do We Even Need the Scan?

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.

From Mamba in RT-DETRv4 — What Could Make It Faster › 1. What v4 Runs, and Where the Work Goes

1 / 5 · v11 / 8 · whole pipeline
One pipeline, five versions. The RT-DETR pipeline for a 640 × 640 image, block by block. Step through the stages to see each block's output shape; switch the version to see which blocks it changes (rust outline), and switch to training to see the dashed parts that exist only while the model learns and are removed at inference.

From Mamba in RT-DETRv4 — What Could Make It Faster › 2. The Core Fact: AIFI Is Already Cheap

6406 / 6 · E
Where the encoder spends its attention. Counts: how many attention scores one encoder layer computes as the input grows, if every token of the three maps attended to every other, if each map attended only to itself, or if only the 20 × 20 map did (AIFI); the rust line is what a deformable encoder samples instead. These are counts, not time. Measured: the paper's own walk from variant A to E, AP against latency.

From Mamba in RT-DETRv4 — What Could Make It Faster › 4. What We Can Do, Ranked

1 / 6 · as deployed1 / 4 · S
Where a scan could save time. My placements, not measured on RT-DETRv4. Costs are my multiply-add counts at 640 × 640: what each change adds (+) or saves (−), next to the nearest timing someone published. Start at "as deployed" to see where the encoder's work goes; the dashed parts exist only in training, and F5 is the map the teacher is aligned to.

Tags that go with it

Efficient networks 2Language models 2Systems programming 2Backbone design 1Edge deployment 1Efficient attention 1Object detection 1Vision transformers 1