Why does MQA underperform GQA when both share KV across heads?
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.
Detailed answer & concept explanation~6 min readEverything 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. 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.
- Llama-3 70B uses GQA with 8 KV heads per 64 query heads.
- Llama 4 Maverick continues the G=8 pattern as the production default.
- Claude Opus 4.7 and Gemini 3.1 Pro both use GQA at similar group counts.
- Mistral Large 3 uses GQA combined with a sliding-window and full-attention layer hybrid.
- The Ainslie et al. 2023 GQA paper empirically swept group sizes from 1 (MQA) to num_heads (MHA) and showed the convex quality curve.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy is the quality vs G curve convex rather than linear?
QHow would you choose G for a deployment with a fixed memory budget?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
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.
Same topic, related formats. Practice these next.