How does grouped-query attention differ from multi-head attention and multi-query attention?

Last updated 22 November 2026

  • All keep H query heads and differ in key/value heads: MHA has H, MQA has 1 shared, GQA has G each shared by H/G query heads (G = H is MHA, G = 1 is MQA).

  • MQA shrinks the KV cache H× but can hurt quality and stability. GQA cuts it by H/G with near-MHA quality (Llama 2 70B, Llama 3, Mistral) and can be uptrained from an MHA checkpoint.

  • Attention FLOPs barely change. The win is KV cache size and memory bandwidth during decoding, enabling larger batches and longer contexts.

  • https://www.geeksforgeeks.org/deep-learning/grouped-query-attention-gqa/
  • https://medium.com/@rahularyan786/grouped-query-attention-gqa-the-sweet-spot-between-quality-and-efficiency-in-modern-llms-efaa502ca209
  • https://huggingface.co/papers?q=GQA
All Transformers interview questions