LearnQuestion bank

Compare multi-head, multi-query and grouped-query attention, and latent attention if you know it. Why did most recent open-weight models adopt GQA, and what does it change when you serve the model?

Applied LLMTechnicalMedium

Theme reported publicly: Mistral AI, Speechmatics

Answer it yourself first, out loud or on paper, then compare.

Answer

Model answer, written in a candidate's voice

In short

  • MHA: every query head has its own K/V; MQA: one shared K/V for all query heads; GQA: query heads grouped, each group shares one K/V
  • KV cache size scales with number of KV heads, so GQA cuts cache memory and per-token decode bandwidth
  • MQA is cheapest but can hurt quality; GQA is the quality/efficiency compromise; MHA checkpoints can be up-trained/distilled into GQA
  • MLA/latent attention caches a compressed low-rank latent per token and expands it at compute time, shrinking cache further at the cost of extra projections
  • Serving: smaller cache means more concurrent sequences and longer contexts; under tensor parallelism KV heads must divide across GPUs or be replicated

In full

MHA gives each query head its own K and V, so the KV cache grows with the number of heads; MQA shares one K/V across all query heads, which is very cheap but can degrade quality; GQA sits between them by letting groups of query heads share a K/V, e.g. 32 query heads with 8 KV heads. Most recent open-weight models adopted GQA because it keeps most of MHA quality while cutting KV-cache size and per-step memory traffic enough to serve more concurrent sequences and longer contexts, whereas MQA is often too aggressive and MHA is too memory-hungry; MHA checkpoints can also be up-trained/distilled into GQA rather than retrained from scratch. DeepSeek-style latent attention goes further by caching a compressed low-rank latent per token and expanding it at compute time, shrinking the cache even more but adding projection work and more complex kernels. In serving, GQA changes the bottleneck from cache capacity/bandwidth toward compute and scheduling: you can fit more requests or longer contexts, but you must handle KV-head divisibility across tensor-parallel GPUs or replicate KV heads, and kernels/batching need to match the grouped layout.

Checked against sources by an independent AI reviewer.

What a strong answer covers

  • MHA: K/V per head. MQA: one shared K/V for all query heads. GQA: groups of query heads share K/V (e.g. 32 query heads, 8 KV heads)
  • KV-cache size scales with the number of KV heads, so GQA cuts cache and per-step memory traffic, allowing more concurrent sequences or longer contexts
  • Quality/stability: MQA can hurt quality; GQA is the compromise; MHA checkpoints can be up-trained to GQA
  • Latent attention (DeepSeek-style MLA) caches a compressed low-rank latent per token and expands it at compute time, shrinking the cache further
  • Serving detail: under tensor parallelism, KV heads must divide across GPUs or be replicated

Common mistakes

  • Presenting GQA mainly as a parameter-count saving
  • ignoring the tensor-parallel constraint