Source: Ximo Guanter (three.dev), "How the memory for a million tokens shrank 150,000 times" (2026-11-24). Found via TLDR Dev 2026-11-25. A good teaching piece: one running number, seven steps.
The chain
GPU memory to hold one million tokens of context, excluding model weights:
| Step | Model | Memory | What changed |
|---|---|---|---|
| 1 | Llama 1 65B, standard attention | 130.5 TB | 128 TB of attention scores plus 2.5 TB of KV cache, about 1,700 H100s |
| 2 | + FlashAttention | 2.5 TB | Never materialise the score table; exact same output. The only free step |
| 3 | Llama 2 70B, grouped-query attention | 320 GB | 8 KV head groups share keys and values |
| 4 | DeepSeek-V3, multi-head latent attention | 68.6 GB | Cache a 512-number latent plus 64 position numbers per token; fits one H100 |
| 5 | DeepSeek-V3.2, 8-bit cache + sparse attention indexer | 46.9 GB | Quantisation gives ~39 GB; the indexer that picks 2,048 tokens adds ~8 GB back |
| 6 | DeepSeek-V4-Flash, merged tokens | 3.4 GB | Alternate layers merge every 4 tokens or every 128 tokens into one entry |
| 7 | DeepSeek-V4.1-Flash, cross-layer sharing + 4-bit cache | 890 MB | 40 layers read 4 caches; trained with the 4-bit cache in place |
The headline 150,000x is 130.5 TB over 890 MB; the cache alone shrank about 2,900x.
What each step costs
GQA and MQA lose some diversity across heads.
MLA must be trained in; it cannot be retrofitted onto a finished model, and it costs extra arithmetic per cached token (DeepSeek reports it beats full multi-head attention anyway).
8-bit cache loses very little; 4-bit a marginal amount, per DeepSeek.
Merging tokens throws away exact detail of older text.
Sharing caches across layers means 20 layers read one shared view.
Not counted: the uncompressed window of the last 128 tokens kept by every V4 layer, about 3 MB per conversation.
Other families (GLM-5, Kimi K2 and Mistral Large 4 with MLA; Gemma's sliding-window hybrids; linear attention in Qwen3-Next and Kimi Linear) are out of scope.
Why it matters for a staff engineer
Long context is now a memory-design choice, not a fixed cost. At 890 MB per million tokens, one GPU can hold many long-context sessions at once, which is what makes cheap million-token agents and large prompt caches viable. But most of the savings from step 4 on are lossy and trained into the model, so the KV layout is tied to the model and the serving kernels, and old context is held less precisely than new. Two practical consequences: check that your serving stack has kernels for the model's cache format (see R283 on Hy4 and R271 on decode tuning), and do not assume a model recalls exact text from deep in a long context as well as it recalls recent text.