Match MLA, GQA and MQA to their mechanisms, cache reduction and quality posture
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
MQA shares one KV head, GQA shares KV heads per group, and MLA stores a learned low-rank latent that reconstructs K and V on demand: three ways to shrink the KV cache.
Picture a library where every reader carries a full set of reference notes. That is multi-head attention: lots of duplicated notes, huge shelves. MQA says everyone share one single set of notes, cheapest but coarse. GQA says split readers into a few teams and give each team one shared set, a sensible middle ground. MLA says do not store the bulky notes at all, store a tiny compressed summary, then unpack the details only when a reader actually needs them. The summary fits in a drawer instead of a shelf. Unpacking costs a little extra work each time, but the storage savings are enormous, which is exactly the trade modern serving systems want.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 min: place all three on the compression spectrum, contrast store and share (MQA, GQA) with compress and reconstruct (MLA), cover MLA's up-projection and decoupled RoPE, then map each to its 2026 model.
| Method | What is stored | Cache reduction | Quality posture | Runtime catch |
|---|---|---|---|---|
| MHA | Full K and V per head | 1x baseline | Reference quality | Largest cache, decode is bandwidth-bound |
| MQA | One shared K and V head | n_heads x | Regresses on hard tasks | Coarsest single history view |
| GQA | One K and V head per group | G x (G=8 typical) | Near full quality | None beyond standard attention |
| MLA | Low-rank latent per token | ~10x | Matches GQA | Up-projection matmul, decoupled RoPE |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Treating MLA as just aggressive GQA. MLA stores a low-rank latent and reconstructs K and V at runtime; GQA stores real shared heads with no reconstruction step.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.