Before you start: words you need#
| Word | Plain meaning |
|---|---|
| KV cache | The keys and values of every earlier token, kept so they are not recomputed (12.e). It grows by one entry per token per layer. |
| GQA / MLA | Ways to store fewer bytes per token: several query heads share one key/value head (GQA), or keys and values are squeezed into one small “latent” vector (MLA) (12.g). |
| Sparse attention | Each new token looks at only a chosen subset of earlier tokens instead of all of them. |
| Indexer | A small, cheap scoring layer that picks which earlier tokens (or blocks of tokens) a query should attend to. |
| Linear attention | A family of layers that replace the growing KV cache with a fixed-size “state” updated once per token. Gated DeltaNet, Kimi Delta Attention (KDA) and Mamba-2 are 2026 examples. |
| Hybrid model | A model that mixes many linear-attention layers with a few normal (full) attention layers. |
| Attention sink | The habit of models to put lots of attention on the first few tokens, which then must never be dropped. |
| Prefill / decode | Processing the prompt in one pass (compute-heavy) / generating one token per step (memory-heavy) (12.c). |
1. What is it?#
Attention has two costs. In prefill, compute grows with the square of the prompt length. In decode, every new token reads the whole KV cache, which grows with every token. All attention research attacks one of these, in five ways:
| Line of work | Idea | Status, November 2026 |
|---|---|---|
| Exact, IO-aware kernels | Same maths, fewer trips to memory (FlashAttention, 13.l) | ESTABLISHED |
| Fewer bytes per token | GQA, MLA, shared K and V | ESTABLISHED |
| Trained sparse attention | An indexer picks which tokens or blocks to read | ESTABLISHED in frontier open models in 2026; serving support still maturing |
| Linear and hybrid attention | Most layers keep a fixed-size state; a few keep full KV | ESTABLISHED in several model families; not yet the default everywhere |
| Approximate attention (low-rank, hashing, kernel tricks) | Approximate the softmax | Largely abandoned for LLMs |
Facts checked on 12 November 2026.
The big change since 2024: two lines that were “research” are now in the models engines optimise for. DeepSeek, GLM and MiniMax ship trained sparse attention; Qwen, Kimi and NVIDIA ship hybrids.
2. Why does it matter?#
Contexts of 128k to 1M tokens, and long agent sessions, make the KV cache the thing that limits how many users fit on a GPU (12.f). The attention design of a model now decides its serving cost more than almost any engine setting. A 2026 engine also has to manage several cache types in one model (17.i): full KV for some layers, compressed latent KV, an indexer’s cache, recurrent state.
3. Simple analogy#
You are answering a question using a huge pile of notes.
- Full attention re-reads every note for every word you write.
- GQA / MLA rewrites the notes in shorthand, so the pile is smaller.
- Sparse attention keeps an index card box. For each word, you check the index and pull only the 2,000 most relevant notes.
- Linear attention keeps one running summary sheet and updates it after every note. The sheet never grows, but details can be lost.
- A hybrid keeps the running summary for most of the work and checks the full pile every fourth step, so exact details can still be found.
4. Tiny example: one 128k-token conversation#
A 48-layer model with 32 query heads of size 128, cache in BF16:
| Design | Cache for one 128k-token sequence |
|---|---|
| Full attention, 32 KV heads (MHA) | 96 GiB: more than a whole H100 |
| GQA, 8 KV heads | 24 GiB |
| MLA | 6.8 GiB |
| Hybrid, 3 linear layers per full layer | 6.1 GiB, and most of it never grows |
Section 6 prints these numbers and the 1M-token versions.
5. Technical explanation#
Exact kernels: settled#
FlashAttention (2022), FlashAttention-2 (2023), FlashDecoding (2023), FlashAttention-3 for Hopper (2024) and FlashAttention-4 for Blackwell (March 2026, about 1.6 PFLOP/s BF16 on B200) plus libraries such as FlashInfer and FlashMLA cover what practitioners need (13.l). The remaining work is kernel engineering: new hardware, unusual head sizes and masks, and attention in low precision.
Low-precision attention is still EMERGING. FP8 attention is in engines; FP4 attention kernels exist in research (SageAttention3). Attention is harder to quantize than a matrix multiply because the softmax exponentiates small errors in the scores.
Fewer bytes per token: settled, still being pushed#
GQA is universal. MLA spread from DeepSeek to Kimi, GLM and Mistral models. DeepSeek-V4 (April 2026) goes further: keys and values share one tensor, and most layers store compressed tokens, where one cache entry summarises several tokens. vLLM reports that this makes V4’s cache at 1M tokens about 9.6 GiB per sequence in BF16, about 8.7x smaller than a V3.2-style stack of the same depth.
Cross-layer sharing (adjacent layers reuse one KV cache; CLA, YOCO) remains EMERGING: sound results, no major 2026 family built around it.
Trained sparse attention: the 2024 verdict reversed#
The 2024 view, which this lesson used to give, was “learned sparsity is not adopted: irregular reads waste tensor cores, and silently missing a token hurts quality”. Two things changed:
- Sparsity is trained in, not bolted on. DeepSeek Sparse Attention (DSA, in V3.2-Exp and V3.2, late 2025) adds a small FP8 “lightning indexer” that scores past tokens; each query attends to the top 2,048. The indexer is trained to imitate dense attention, then the whole model is trained to work with the sparsity. Because the model learned with it, a skipped token is a design choice, not a silent failure.
- Blocks, not single tokens. Reading whole blocks of keys keeps memory reads regular. MiniMax-M3 (June 2026) scores 128-token blocks and attends to the best ones. GLM-5.3 uses sparse MLA with one indexer shared by every four layers.
Where 2026 models stand:
| Model (2026) | Attention design |
|---|---|
| DeepSeek-V4 Pro / Flash | Compressed attention at about 4x (with a top-k indexer) and about 128x, plus a 128-token sliding window, 1M context |
| GLM-5.3 | Sparse MLA, indexer shared across four layers |
| MiniMax-M3 | Block-sparse attention over 128-token blocks, 1M context |
| Mistral Large 4 | Sparse MLA (DeepSeek lineage) |
What is still open (EMERGING): the indexer’s own cache still grows with context; offloading the unselected KV to CPU memory while keeping it fetchable (vLLM’s Hybrid HiSparse ran GLM-5.3 at 1M tokens on 8× H200 this way); and checking quality at long range. A November 2026 preprint already proposes “coverage-verified” sparse attention, a closed-loop check that the selection did not miss needed tokens. That is the open problem, stated plainly.
Linear and hybrid attention: now in the models#
Linear attention replaces softmax over all past tokens with a fixed-size state matrix that each token updates. Pure linear models are weaker at exact recall (“what was the order number on page 40?”). Hybrids fix that by keeping a few full-attention layers:
| Family | Mix |
|---|---|
| Qwen3-Next, Qwen3.5 | Gated DeltaNet and gated full attention, 3:1 |
| Kimi Linear (Oct 2025), Kimi K3 (July 2026) | Kimi Delta Attention with periodic full attention; Kimi Linear reported up to 75% less KV cache and up to 6x decode throughput at 1M context |
| NVIDIA Nemotron 3 | Mostly Mamba-2 layers with a few attention layers, MoE |
| Jamba, Zamba, Samba (2024) | The first production hybrids |
The counter-evidence matters too. MiniMax trained M2 (October 2025) as a full-attention model and said why: hybrids that matched full attention at small scale fell behind at scale on tasks the benchmarks did not catch, the tooling was immature, and linear attention was sensitive to numerical precision. Others argued the tests were unfair. MiniMax’s next model, M3, chose sparse attention instead. When strong teams disagree in public like this, the honest label is: hybrids are ESTABLISHED in several families and the question “do they match full attention at the top” is still open.
Gated attention (a sigmoid gate on the attention output; Qwen team, NeurIPS 2025 best paper) removes most attention-sink behaviour and is used in the Qwen hybrids. It is a quality fix that also makes caches easier to handle.
Diffusion LLMs: attention changes again#
Diffusion language models refine a whole block of tokens at once, with bidirectional attention inside the block. Their keys and values change between refinement steps, so ordinary caching is not exact. 2026 papers attack this with sparse attention per step (Step-dLLM, NeurIPS 2026). See 24.e and 24.j.
6. Under the hood: cache size per design#
// attncache.go — cache memory for ONE sequence under four attention designs.
// Reference model: 48 layers, 32 query heads, head size 128, cache in BF16 (2 bytes).
package main
import "fmt"
const (
layers = 48
headDim = 128
bf16 = 2
)
// perToken returns cache bytes added per token; fixed returns bytes that do not grow.
type design struct {
name string
perToken float64
fixed float64
}
func main() {
gqaLayer := 2.0 * 8 * headDim * bf16 // K and V, 8 KV heads
designs := []design{
{"MHA (32 KV heads)", layers * 2 * 32 * headDim * bf16, 0},
{"GQA (8 KV heads)", layers * gqaLayer, 0},
{"MLA (576 values/layer)", layers * 576 * bf16, 0},
// 3 linear-attention layers per full-attention layer: 12 GQA layers keep a KV cache,
// 36 linear layers keep a fixed state of 32 heads × 128 × 128 numbers in FP32.
{"Hybrid 3:1 linear/full", 12 * gqaLayer, 36 * 32 * headDim * headDim * 4},
}
fmt.Printf("%-24s %10s %12s %12s\n", "design", "KiB/token", "128k tokens", "1M tokens")
for _, d := range designs {
at := func(tokens float64) float64 { return (d.perToken*tokens + d.fixed) / (1 << 30) }
fmt.Printf("%-24s %10.0f %9.1f GiB %9.1f GiB\n", d.name, d.perToken/1024, at(131072), at(1048576))
}
}Output:
design KiB/token 128k tokens 1M tokens
MHA (32 KV heads) 768 96.0 GiB 768.0 GiB
GQA (8 KV heads) 192 24.0 GiB 192.0 GiB
MLA (576 values/layer) 54 6.8 GiB 54.0 GiB
Hybrid 3:1 linear/full 48 6.1 GiB 48.1 GiBHow to read it:
- The hybrid’s fixed state is only about 72 MiB per sequence (36 layers × 2 MiB); everything else is the 12 full-attention layers. Use MLA or GQA in those layers and the hybrid shrinks further.
- Sparse attention does not show up here, because it shrinks what is read per step, not what is stored. DeepSeek-V4 does both: it stores compressed tokens and reads only the top-k.
- The fixed state changes engine design: prefix caching must save state snapshots at block boundaries, and a block of state cannot be shared the way KV pages can (17.i).
7. Performance implications#
- Decode: cache bytes read per token set the decode cost at long context. Sparse reads and hybrid layers cut this by large factors; GQA and MLA cut what is stored and read.
- Prefill: sparse and linear layers remove most of the quadratic compute at 128k+ tokens. This is where DeepSeek-V3.2-Exp’s reported 6–7x cheaper long inputs came from.
- Kernels decide the real gain. A FLOP cut that does not map to regular memory access is not a speedup (22.c). That is why 2026 designs read blocks and run the indexer in FP8.
- The indexer is not free. It has its own cache and its own kernel; vLLM runs DeepSeek-V4’s indexer on a separate CUDA stream to hide it.
8. Production implications#
- Read the config before you size the cluster. Cache bytes per token now range from tens of KiB to hundreds per token, and some layers add fixed state. The single formula in 12.f no longer covers every model.
- Expect cache-manager changes in every engine release. Hybrid and sparse models have driven much of the vLLM and SGLang memory-manager work in 2026 (17.i).
- Disaggregation must move new state types. Prefill/decode transfer for hybrids has to send SSM state as well as KV blocks (vLLM added this for Nemotron hybrids in April 2026; Gated DeltaNet support was on its roadmap then).
- Test long-range recall yourself. For sparse and hybrid models, run your own retrieval and multi-hop tests at your real context lengths (24.g).
9. Common mistakes#
- Repeating the 2024 verdict that learned sparse attention “never gets adopted”. Trained sparsity is in DeepSeek, GLM and MiniMax models today.
- Assuming hybrids are a solved win. Strong teams disagree; test your own task.
- Counting FLOP savings without wall-clock measurements.
- Using one “KV bytes per token” number for a hybrid or sparse model.
- Forgetting the indexer cache and the recurrent state when sizing memory.
- Taking advertised 1M context as usable 1M context (24.g).
10. Hands-on exercise#
- Run
attncache.go. Change the hybrid’s full-attention layers to MLA (576 values per layer). What is the cache at 1M tokens now? - Download the
config.jsonof Qwen3.5, a Kimi model and DeepSeek-V4-Flash. For each, list every kind of cache it needs and estimate bytes per token. - Run a needle-in-a-haystack test and a multi-hop test at 32k and 128k on one hybrid and one full attention model of similar size. Does the hybrid fall behind on either?
- Apply 24.a’s seven questions to one 2026 sparse-attention paper. Does it report wall-clock time at batch sizes above 1?
11. Interview questions#
- Which attention research lines are settled, and which are still moving?
- Why did trained sparse attention succeed in 2025–26 where earlier sparse attention did not?
- How does a hybrid linear/full model change KV-cache sizing and prefix caching?
- Why did MiniMax-M2 go back to full attention, and what does that tell you about benchmarks?
- Sparse attention shrinks bytes read, GQA shrinks bytes stored. Why does the difference matter?
- Why is attention harder to run in FP4 than a matrix multiply?
12. Further reading#
Checked on 12 November 2026.
- DeepSeek V4 in vLLM: efficient long-context attention (vLLM blog, April 2026)
- DeepSeek-V3.2: DeepSeek Sparse Attention (arXiv 2512.02556)
- GLM-5.3 Part 1: Hybrid HiSparse offloading (vLLM blog, September 2026)
- MiniMax M3 in vLLM: 1M-token serving (vLLM blog, June 2026)
- Kimi Linear: an expressive, efficient attention architecture (arXiv 2510.26692)
- Why did MiniMax M2 end up as a full attention model? (MiniMax)
- Gated attention for LLMs (arXiv 2505.06708, NeurIPS 2025)
- NVIDIA Nemotron 3: hybrid Mamba-Transformer MoE (arXiv 2512.20856)
- Disaggregated serving for hybrid SSM models in vLLM (April 2026)
- Sebastian Raschka: hybrid attention architectures
- SageAttention3: FP4 attention (arXiv 2505.11594)
- Step-dLLM: sparse attention for diffusion LLM inference (arXiv 2611.01320)
- FlashAttention-3 (arXiv 2407.08608)