Why does MQA underperform GQA when both share KV across heads?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Multi-query attention (MQA) and grouped-query attention (GQA) both reduce KV cache by sharing K and V across query heads. Yet MQA usually degrades model quality noticeably while GQA does not. Explain the structural reason for that gap, and what knob makes GQA the safer compression point.
MQA collapses all heads onto one K, V, killing lookup-side diversity. GQA preserves group-level K, V diversity via a group-size knob, keeping most quality at almost MQA's cache size.
Imagine a research team of 64 analysts. Multi-head attention gives each analyst their own personal library. MQA fires the librarians and forces all 64 analysts to share one library, much cheaper, but every analyst now looks at the same shelf, so their analyses become similar. GQA splits the analysts into 8 groups of 8 and gives each group its own library, almost as cheap as one shared library but with 8 different views into the source material. The group size is the knob.
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.
5m: why MHA's head diversity matters, how MQA's single shared K, V collapses lookup-side diversity, what GQA's group size G preserves, the convex quality vs G curve, and the production convergence on G in the 4 to 8 range.
| Property | MQA | GQA (G=8) | MHA |
|---|---|---|---|
| KV heads per layer | 1 | 8 | num_heads |
| Cache reduction vs MHA | num_heads x | num_heads / 8 x | 1x (baseline) |
| Lookup-side diversity | None | 8 subspaces | num_heads subspaces |
| Quality vs MHA | Measurable drop | Within noise | Baseline |
| Production usage in 2026 | Rare (legacy) | Default | Encoders, small models |
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 MQA and GQA as the same kind of design with different scales. The granularity of sharing changes a structural property, not just a magnitude; GQA preserves lookup-side diversity that MQA destroys.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.