What is the quality-versus-memory trade-off among MHA, GQA, and MQA?

Last updated 22 November 2026

  • The variants differ only in the number of key/value (KV) heads: MHA has one per query head (best quality, largest KV cache), MQA shares one across all heads (smallest cache, some quality loss and less stable training).

  • GQA uses G groups of shared KV heads, shrinking the cache by H/G (Llama 2 70B: 64 query heads, 8 KV heads). It gets near-MHA quality at near-MQA speed and is the modern default.

  • Smaller caches matter because decoding is memory-bandwidth bound: fewer KV heads means faster tokens/s and room for bigger batches or longer contexts.

  • https://arxiv.org/html/2512.20650
  • https://kgptalkie.com/tutorials/transformers/day-26-mha-mqa-gqa
  • https://medium.com/@rahularyan786/grouped-query-attention-gqa-the-sweet-spot-between-quality-and-efficiency-in-modern-llms-efaa502ca209
All Transformers interview questions