Topic · Efficiency

Systems programming

Everything on this site about systems programming, 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
  2. Project

The figures these pages use

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

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).

Tags that go with it

State space models 2Efficient attention 1Language models 1