Mamba: From Intuition to Proof
How delta-gated state-space models challenge the Transformer — from the intuition of selective memory to the parallel-scan proof.
Efficient Hybrid Models
I research the architectures that break through it — state-space models, linear attention, hybrids, and latent-reasoning loops that could make long-document AI affordable for hospitals, labs, and researchers who don't own a GPU cluster.
Every new token, replayed vs. remembered
Both models read the same sentence. Self-attention re-reads every previous token, every step. A selective SSM asks one question per token — worth remembering? — writes “keys” into its fixed-size state, and lets “the” pass straight through.
The problem
Self-attention compares every token with every other token, so compute grows with the square of context length — and the key–value cache it keeps grows linearly on top of that. Pick a model and drag the slider out to a million tokens: the numbers below are computed live from each model's published configuration, against a Mamba-2-class model whose recurrent state never grows at all.
Inference memory vs. context length
Cache memory of the selected model vs. the fixed recurrent state of a Mamba-2-class 7B model, one sequence, batch 1. Context axis is logarithmic, 1K to 1M tokens. Hover, tap or focus the chart for values (arrow keys move along it); the marker tracks the slider.
KV-cache per token = 2 (K and V) × attention layers × KV heads × head-dim × 2 bytes (BF16),
read from each model's published config.json:
Llama-3-8B — 32 layers × 8 KV heads × 128 = 128 KiB/token;
Llama-3-70B — 80 layers × 8 KV heads × 128 = 320 KiB/token
(both use grouped-query attention; head-dim = hidden size ÷ attention heads);
Nemotron-H-8B — only 4 of its 52 layers are attention
(8 KV heads × 128) = 16 KiB/token, plus a fixed state in its 24 Mamba-2 layers of
24 × 128 heads × 64 head-dim × 128 state-dim × 2 bytes = 48 MiB (convolution buffers add ≈2 MiB).
The Mamba-2-class reference: ≈64 layers × 8192 inner-dim × 128 state-dim × 2 bytes ≈ 128 MiB,
independent of context length. GB here means 230 bytes. Attention scores: N² comparisons
per layer-head pass. Sources:
Llama-3-8B ↗,
Llama-3-70B ↗,
Nemotron-H-8B-Base-8K config ↗.
Weights, activations and serving overheads are excluded; this is the part that grows with context.
The lines are memory arithmetic, not a claim about quality: Llama-3 ships with an 8K window and
that Nemotron-H checkpoint with 8K, so the curves past that show what the cache would cost.
And even with the compute…
Even when a document fits in the context window, retrieval accuracy dips sharply when the relevant passage sits in the middle — the lost-in-the-middle failure documented by Liu et al. (2023). In clinical records, legal texts, and dense academic literature, the middle is where the evidence lives. My research plan measures exactly where this degradation begins, then tests whether selective state-space models can avoid it.
Retrieval accuracy vs. position of the relevant passage
Measured, not illustrative: GPT-3.5-Turbo (0613) on multi-document QA with 20 retrieved documents (~4K tokens), the answer-bearing document moved from first to last. Values from Table 6 of Liu et al. (2023), arXiv:2307.03172 ↗; the dashed line is the same model answering with no documents at all (closed-book, Table 1). Hover, tap or tab to the points.
The pragmatic answer
Pure SSMs are cheap but fuzzy at verbatim recall; pure attention recalls perfectly but pays the quadratic tax on every layer. Production models now split the difference — a thin slice of real attention for precise, needle-in-haystack lookups, riding on a linear-state backbone that does the bulk of the work. Hover or tap the stacks (or tab to one and use the arrow keys): orange layers are the only ones that keep a KV-cache.
Where the attention actually is
Layer-by-layer composition, drawn to each model's real layer counts. The hybrid recipe: replace almost every attention layer with a constant-memory Mamba-2 layer, keep a few for high-fidelity recall.
NVIDIA's PostNAS ran six linear operators head-to-head — RWKV-7, RetNet, Mamba-2, GLA, DeltaNet, Gated DeltaNet — inside a frozen Transformer. Gated DeltaNet won; they built JetBlock on top of it.
My deep-dive: Inside Jet-Nemotron →Four months later, the same lab bet its flagship open models — Nano, Super, and the 550B Ultra — on Mamba-2, not Gated DeltaNet, not JetBlock. What wins a 2B-scale search isn't what gets trusted at 550B.
My deep-dive: Nemotron 3's Mamba-MoE engine →Same lab. Same year. Two different winners. The field agrees on the hybrid recipe but not on the linear operator inside it — or where the attention layers belong, or whether any of it holds at the next order of magnitude. Nobody has a settled theory yet. That open question is precisely where my 24-month research plan and survey sit: put the operators under one notation, then measure — at kernel level — what the state actually remembers.
The third answer
Hybrids delete most attention layers and hand the work to a recurrent state. DeepSeek-V4 takes a different route: keep attention in every layer, but let most of what it reads be compressed. Each layer attends over a short local window at full resolution and a long history at reduced resolution, concatenated into a single softmax. Two new layer kinds do this — CSA with light compression and a learned indexer that keeps only the top-scoring entries, and HCA with heavy compression and no indexer at all.
swa — local onlyA causal sliding window and nothing else. Cheap bootstrap layers that resolve local structure; anything older is simply invisible to them.
csa — compressed sparseLight compression, overlapping blocks, and a Lightning Indexer that ranks the pool and keeps the top-k. It ranks after the causal mask, so its selection is always a subset of what dense attention would have seen.
hca — heavily compressedAggressive non-overlapping compression, every closed block visible, no indexer to train. Only complete blocks are emitted — a partial one would summarise fewer tokens than its siblings and make the entries incomparable.
Two ways to compress the past
Schematic. Sixteen past tokens and one new query (right). On the left, every token was written into one fixed state and the query can only read that state. On the right, blocks of four tokens become one compressed key each, and the query can still jump to any of them.
Why this matters for the hybrid debate. A Mamba-2 or KDA layer buys constant memory by compressing the past into a fixed-size state and giving up random access to it. A CSA or HCA layer compresses the past into fewer keys and keeps random access over them. Those are genuinely different bets about what long-context memory is for. QUANTA asks the neighbouring question under identical ternary weights: one fixed-state stack (GDN-2), with a dense or a sparse global read on top.
Read further: the fixed-state side is the gated recurrence St = Gt ⊙ St−1 + kt⊤vt that the survey uses as its unifying notation; the production layer schedules that mix exact attention with a cheaper memory live in the Hybrids node of the Atlas.
The map so far
Decoding is mostly memory traffic: every forward pass streams the active weights and the whole cache. To a first order, bytes moved per answer ≈ forward passes × (active params × bytes per weight + context × KV bytes per token). Every idea on this page shrinks one factor of that product, which is why they can stack.
1
bytes held per token of context
2
what each parameter costs to store and stream
3
how much of the model runs each step
4
how many times the big model runs
Dot colour = Atlas phase (Phase 1 · Phase 2 · Phase 3); grey = an engineering lever, not a separate Atlas node.
Two other levers
Replacing attention with a fixed-size state is only one way to make long-context AI affordable. Three Atlas nodes attack the cost from completely different directions: 1-bit models shrink what a weight costs to store and multiply, while multi-token prediction and diffusion language models shrink how many forward passes an answer costs to produce. All three are in the survey; none needs a bigger GPU.
1-bit / MatMul-free is a Phase-1 node in the Atlas. Deep-dive on the ternary side: How BitNets Run a Transformer With (Almost) No Multiplication →
NVIDIA's Nemotron 3.5 Lightning (August 2026) is the clearest production case. It is a 30B mixture-of-experts with just 3B active parameters, on the same interleaved Mamba-2 + MoE backbone with a few attention layers — and its headline “up to 4× the output speed of similar-sized models” is credited to what happens around the backbone, not to the backbone itself: speculative decoding — multi-token prediction trained in (with a dedicated MTP-boosting phase), plus two draft models, DSpark and DFlash — and an NVFP4 quantized checkpoint. NVIDIA doesn't say how much of the 4× each one contributes. There is no technical report on arXiv yet; the details are from the NVIDIA announcement ↗. Multi-token prediction is a Phase-2 node in the Atlas, and I wrote about it in Why Your LLM Should Be Guessing ↗. The race below shows why guessing ahead works.
Why Lightning is fast: guess four, check once
Schematic. Both lanes decode the same sentence. Autoregression pays one full forward pass per token. Speculative decoding lets a tiny draft model propose four tokens, then the big hybrid verifies them all in a single pass — wrong guesses get thrown out and redrafted, and it still finishes ~3× sooner.
Diffusion language models pull the same lever harder: they drop strict left-to-right decoding and refine many positions in each forward pass — a Phase-3 node in the Atlas.
All three are tracked in the survey's coverage map.
Putting it together
Four slots, rebuilt by different labs on separate timelines — and, until 2026, almost never in the same model.
Step back from the individual papers and something odd shows up. The 2017 Transformer block has four swappable slots — a token mixer, a channel mixer, the precision the weights are stored in, and the residual pathway that carries information between layers. NVIDIA's Mamba-2 hybrids, Moonshot's delta attention, DeepSeek's compressed attention and Qwen's Gated DeltaNet have all been rebuilding the first. Mixture-of-experts rebuilt the second. BitNet rebuilt the third. They are largely orthogonal upgrades, and the fourth slot went nine years untouched — then got three incompatible replacements in a single year.
The original block — and its four slots
Vaswani et al. (2017). Every model on this page is still this diagram with one or two slots replaced. Slot 4 — the residual stream and Add & Norm skeleton — went unchanged for nine years, which is why it is drawn dashed. It is no longer empty: three labs moved it in 2026, in three different directions.
| Model | 1 · Token mixer | 2 · Channel mixer | 3 · Precision | 4 · Residual | Slots left original |
|---|---|---|---|---|---|
| Transformer 2017 | Multi-head attention | Dense FFN | FP16/FP32 | Add & Norm | 4 of 4 |
| BitNet b1.58 2025 | Full attention + RoPE | Dense FFN (squared ReLU) | Ternary, 1.58-bit | Add & Norm | 3 of 4 |
| Nemotron-H / 3 2025 | Mamba-2 hybrid (6 of 52 attn; 1M ctx) | Sparse MoE (23 of 52 layers) | FP/BF16 | Add & Norm | 2 of 4 |
| Kimi Linear 2025 | KDA 3:1 hybrid (delta rule) | Sparse MoE (3B of 48B active) | FP/BF16 | Add & Norm | 2 of 4 |
| DeepSeek-V4 2026 | SWA + CSA + HCA (local window kept in every layer) | Sparse MoE (61 layers) | FP8/FP4 storage | mHC (manifold-constrained hyper-connections) | 0 of 4 |
| Qwen3.8-Flash-Next 2026 | GDN 3:1 QSA (fixed state + block-indexed sparse retrieval) | Sparse MoE (multimodal) | FP/BF16 | Gated Residual (4 branches, read/write gated) | 1 of 4 |
| Kimi K3 2026 | KDA + global MLA (joint language/vision context) | Sparse MoE | FP/BF16 | Attention Residuals (softmax over depth) | 1 of 4 |
| QUANTA this work · pre-registered | GDN-2 3:1 Gated MLA or GDN-2 3:1 QSA (vs softmax, each with an FP twin) | Dense | Ternary, 1.58-bit (MLP-only, W1.58A16) | R0 baseline + five residual families — bypass, GR, mHC, single-pass mHC, AttnRes; exploratory | 1 of 4 |
In 2026 the empty corner got occupied, from three sides at once. DeepSeek-V4 was first to move all four slots together: a three-way hybrid attention schedule, sparse MoE, FP8/FP4 storage, and manifold-constrained hyper-connections in place of plain Add & Norm. Within months Qwen3.8-Flash-Next and Kimi K3 did the same thing with different answers in every slot — Qwen with Gated DeltaNet plus block-indexed sparse retrieval and a four-branch gated residual, Kimi with delta attention plus global MLA and a residual that attends over depth. Between them the “can these compose?” question is settled at frontier scale and in the affirmative. But each answer arrives by changing everything simultaneously, so none of them can tell you which slot bought which gain — and none was tried at low precision. That is the gap QUANTA works in: the same components, one at a time, at the ~596M Qwen3-0.6B scale where an ablation is affordable.
One honest correction, because it changes the argument. It's tempting to say BitNet's FFN is “the old part” — but BitNet ternarizes every linear layer, FFN included. The slot it actually left untouched is the token mixer: BitNet b1.58 2B4T still runs full softmax attention with RoPE, and its own technical report names extending sequence length and “investigating efficient attention mechanisms suitable for low-bit models” as future work. So the gap isn't a stale FFN — it's that the cheapest weights in the field are still attached to the most expensive sequence mixer, and the FFN, while ternary, is still dense.
That is what makes the corner interesting rather than merely unbuilt. The shipped savings multiply against different bottlenecks — ternary weights cut memory and bandwidth per parameter, hybrid and compressed attention cut the cache that grows with context, MoE cuts how many parameters run per token (the four cost axes above). Whether they actually compose at low precision, or interfere, is still an experimental question: no frontier model has taken the ternary route, ternary experts may not specialize, and a compressed recurrent state may not survive 1.58-bit weights.
Slot 4 is now a crowded slot, not an empty one — and that is the more interesting problem. Nine years with one fixed addition, then three incompatible replacements in a single year. Qwen widens the stream and gates the reads. DeepSeek widens it too but pins the mixing matrix to the doubly-stochastic manifold so it keeps behaving like an identity map. Kimi leaves the stream alone and instead lets a layer run softmax attention over the outputs of every layer beneath it. Those are three different mechanisms — widening, constraining, and reaching along depth — routinely lumped together as “better residuals.” QUANTA treats them as an R0 baseline + five residual families with separate predicted signatures, because a win for one implies nothing at all about the others. The background — from static skips to hyper-connections — is in my piece Why Residual Connections? ↗
Every block above except the 2026 three still moves information between layers the way it did in 2017 — one addition, from the layer directly beneath:
That is a write, not a read. Layer 20 sees layer 19's output and nothing else; anything layer 4 computed has to survive sixteen rounds of being overwritten to still be there. In a full-precision network that is usually fine. Under ternary weights, every one of those sixteen transformations is lossy by construction — which is exactly why this slot becomes worth reopening at 1.58 bits and not before.
Attention residuals make the pathway a retrieval instead of an addition. A layer attends back over the earlier states in the stack and pulls what it needs — which is exactly what Kimi K3 shipped in 2026:
The hypothesis: if ternary transformations shed information layer by layer, letting a layer read earlier states directly may recover some of it — at a cost, since those states have to be kept and attended over. Toggle slot 4 in the builder above to see the pathway change. Three shipped mechanisms now occupy this slot and they are not variants of one idea: DeepSeek's mHC and Qwen's Gated Residual widen the stream, and only Kimi's AttnRes retrieves over depth. QUANTA sweeps them — R0 baseline + five residual families — at ternary precision, where none has been tried.
Research direction I · proposal
A 24-month empirical program: map the exact degradation curve of Transformer long-context retrieval, then test whether Mamba-2-class architectures can match it at a fraction of the memory — with hardware-level profiling on dedicated HPC infrastructure, and falsifiable success criteria fixed in advance.
Twenty-four months, three phases
Phase 1 · months 1–6 · quantify the degradation, fix the baselines
Phase 2 · months 7–15 · deploy and optimise the Mamba-2 challenger
Phase 3 · months 16–24 · A/B validation at the hardware level
Want the full formal proposal, or to collaborate on this direction? Email [email protected] or reach me on LinkedIn ↗.
Research direction II · pre-registered design · November 2026
A separate line of work. Ternary weights make a language model much smaller but cost quality. QUANTA (Quantized Architectures for Neural Token-flow Analysis) uses them as a controlled lesion: only the MLP (feed-forward) weights go ternary, and everything else stays at full precision. The question is how the rest of the network adapts, and whether a standard transformer or a hybrid — mostly Gated DeltaNet-2 recurrent layers with an attention layer every fourth layer — pays less for the damage. Every model is trained from scratch at the Qwen3-0.6B size on 1B tokens. The tests and what counts as a result were frozen before the first run; no study run has started yet.
What it tests. How much the lesion costs the transformer; whether each hybrid pays less, measured against its own full-precision twin; whether the damaged models lean more on their attention layers and recurrent memory; and whether the lesion hurts most on tokens the context cannot predict, as it should if the MLPs hold stored knowledge. A second, exploratory stage — reported in a separate paper — tries five alternative residual-stream designs on whichever hybrid looks more promising. The earlier, broader plan (Mamba-2, DeepSeek, Kimi K3 and Qwen3.8 lines, multi-token prediction, mixture-of-experts) stays implemented but untrained.
Deliberately kept apart from the survey work. Direction I and the survey ask whether the sequence mixer can be replaced. This one leaves that open and asks a different question at a different precision. Different hypotheses, different baselines, no shared claims — and any result from one does not transfer to the other.
Research direction III · experiments running · November 2026
MnemoRoute (Topic-Routed Recurrent–Episodic Memory for Long-Horizon Conversational Agents) takes the recurrent state from the architecture work up one level, to an agent's memory across turns. A controller routes each turn to a topic and picks one action — continue, create, revisit, cross-link, retrieve, update, compact, or defer; a Gated DeltaNet-style state holds each topic's working context; an append-only episode log and a temporal fact index keep the exact values, every correction, and where each came from. It also asks how to find the right existing record without a vector-first assumption, and when a new claim should change it. First development results are in: on a benchmark with gold memory slots, corrections fail mainly at addressing (finding the right record), not at the update decision.
Built to be falsified, and already narrowed. The learned memory pipelines tie with plain hybrid retrieval end to end. The best one, MR-LB3, is +1.9 points over the tuned baseline, which is not significant. So Paper 1 measures where memory fails, and the recurrent state waits until that is understood.
Research direction IV · first verdict in · November 2026
AMTR-KV (Adaptive Multi-Timescale Recurrent KV compression) works on the memory a pretrained transformer uses while it reads a long input: the KV cache, which stores a key and a value for every token in every layer. Most ways of shrinking it without retraining keep a layer's cache in full or throw away everything older than a recent window. AMTR-KV adds a third option, fold: compress a layer's old tokens into a small bank of Gated DeltaNet-2 memories with short, medium and long horizons. A measured profile of each layer decides which of the three modes it gets under a memory budget; the model itself stays frozen. First measurements on Qwen3-0.6B: most KV heads need their old context, but only in aggregate.
Not proven yet. The pre-registered go/no-go test first said no: with each memory trained on its own layer, folding six layers did no better than spending the same bytes on a longer window. Training the six folded layers together turned that around (loss on the tokens that need long context: 1.56 against 1.79 nats). Both runs used a small 256-token window, so a test at a 2,048-token window, with its rules written down before any result, now decides. If the fold fails there, it is declared dead.
Collaborate
For the full formal research proposal, collaboration on either direction, or notes on anything in the Atlas — email is the fastest way to reach me.
The Architecture Atlas
Every post-Transformer architecture answers a specific failure of the one before it. The Atlas maps that evolutionary chain from LSTM (1997) to Meta's Context Language Models (2026) — each node with its motivation, key equation, complexity, and the paper behind it.
Replace the KV-cache with a fixed-size state — RNNs, 1-bit LLMs, linear attention, hybrids, and Mamba.
Spend adaptive test-time compute inside a latent state — TTT, multi-token prediction, HRM, TRM, recursive LMs, and context LMs that edit their own window.
Abandon next-token prediction — energy-based Transformers, diffusion LLMs, variational autoencoders, normalizing flows, flow matching, JEPA, world models, and typed System One models.
Writing
Selected articles — the full list, mapped to Atlas nodes, is on the Writing page.
How delta-gated state-space models challenge the Transformer — from the intuition of selective memory to the parallel-scan proof.
The missing link for long-context AI: fusing Mamba's forgetting with DeltaNet's precise memory writes.
How a 7M-parameter network with recursion beats models a thousand times its size on hard reasoning puzzles.
In preparation
A survey organizing the nineteen Atlas architectures into their three evolutionary phases, under a single unified state-update notation — in preparation for arXiv (cs.CL / cs.LG). The Atlas is its living companion — and every one of the nineteen gets its own published deep-dive first.