6.1.11 · D2Scaling & Efficient Architectures

Visual walkthrough — State-space models (Mamba, S4)

1,975 words9 min readBack to topic

Before any symbol appears, meet the cast in plain words.


Step 1 — One box that remembers: the recurrence

WHAT. We draw a single "memory box". Each tick it does exactly two things: it shrinks the old bag a little, then adds a splash of the new input.

WHY. This is the smallest possible machine with memory. "Shrink then add" is the entire mechanic of an RNN too (see RNNs and LSTMs); an SSM is this box with a particularly clean shrink rule, which is what lets us do the magic in later steps.

PICTURE.

The one governing line, term by term:

Then we read out the bag through a lens :

is just which mixture of the bag's numbers we report. (We set the skip term , as the parent did.)


Step 2 — Start empty, take one step

WHAT. We commit to starting with an empty bag: . Then we run the box for exactly one tick.

WHY. Starting from zero removes any "initial condition" clutter, so every number in the bag can be traced back to some specific input. That traceability is the whole trick.

PICTURE.

Read the arrows in the figure: the old bag was empty, so all of is fresh input scaled by . Nothing else could contribute — there was nothing to shrink.


Step 3 — Take a second step: the past starts fading

WHAT. Feed in . Now the box shrinks the previous bag (which held ) and adds fresh .

WHY. This is the first moment memory shows up: is still present, but multiplied by once — it has aged one tick.

PICTURE.

  • The term is the echo of , dimmed by one factor of .
  • is the newcomer, at full strength.

Look at the two coloured contributions in the picture: same shape, different age.


Step 4 — The pattern locks in: powers of

WHAT. Take one more step and watch the ages stack.

WHY. After three steps the rule is undeniable: the older an input, the more times it got multiplied by . Age exponent.

PICTURE.

Each input carries a power of equal to how many ticks ago it entered:

input ticks ago at step 3 weight it carries
2
1
0

The staircase in the figure is the point: decay is geometric — each older step is another rung down.


Step 5 — Read out, and a kernel is born

WHAT. Push through the lens . Do it for the general step .

WHY. Applying to the sum-of-aged-inputs turns the state recurrence into a formula for the output directly in terms of past inputs. The list of weights that appears is the kernel.

PICTURE.

  • The sum runs over every past input (from the very first up to now).
  • The exponent is the age: how many ticks between when arrived () and now ().
  • Each weight is one number — how loudly an input of age still speaks in today's output.

Collect those weights by age and you get one fixed list, the SSM kernel:


Step 6 — The two views are the same picture

WHAT. Recognise the sum in Step 5 as a convolution: slide the kernel across the input and take weighted sums.

WHY. This is the payoff. A convolution can be computed with the FFT in time and — crucially — all outputs at once, in parallel. The recurrence (Step 1) is sequential and slow to train; the convolution is parallel and fast. Same numbers, two speeds.

PICTURE.

The convolution view is exactly the same fixed-filter idea you meet in Convolutional Neural Networks — except here the filter's shape () is derived from the decay rather than learned as raw weights.


Step 7 — Edge & degenerate cases (never let the reader fall through)

WHAT / WHY / PICTURE for the corners the smooth story skips.

Each strip in the figure shows the same kernel machinery with a different : dying, flat, exploding, ringing. One rule, every regime.


Step 8 — Where Mamba departs

WHAT. In Steps 1–6 the weights were frozen — the same for every token — which is exactly what let us collect them into one fixed kernel .

WHY it matters. Mamba makes those weights depend on the current input (, , ). The moment the weight for age changes with , you can no longer collect one fixed list — the convolution collapses, and you must run the recurrence (Step 1) directly. This is the same "content-dependent mixing" spirit as Linear Attention.

PICTURE.

The picture contrasts a fixed comb (S4: one kernel for all) with a per-token comb (Mamba: the filter reshapes at each step). The price is losing FFT parallelism; the prize is choosing what to remember.


The one-picture summary

Read it left to right: an empty bagshrink-and-add each tick → each input aged by a power of read out with → the ages line up into the kernel → the same numbers are a convolution. That single chain is S4.

Recall Feynman retelling — say it back in plain words

Imagine a bucket. Each second you pour out a fixed fraction of what's in the bucket (that's , the forgetting), then pour in a splash of whatever's arriving now (that's ). You read the water level through a tinted glass (). Because you always pour out the same fraction, an input from seconds ago has been diluted exactly times — that's the power . So today's reading is just every past input, each dimmed by its age. Line those age-weights up into a list and you've got a filter you can slide across the whole input in one shot — that's the convolution, and it's why training is fast. Mamba's twist: let the pour-out fraction change per token, so the bucket can decide to hold onto a name and dump a filler word. That flexibility costs you the "one-shot slide", so Mamba runs the bucket step by step with clever GPU code instead.

Recall Quick self-test

Why does an input carry the factor at output step ? ::: Because between arriving (step ) and being read (step ) it survived shrink operations, each multiplying by . What single object are the recurrent and convolutional views both computing? ::: The kernel / impulse response . Why can't Mamba use one fixed kernel? ::: Its weights depend on the input, so the "weight for age " changes with position and can't be collected into a single fixed list. What happens to the kernel if ? ::: It becomes — the model is memoryless, output depends only on the current input.