# Grouped-Query Attention

> Grouped-query attention (GQA) is a transformer attention variant in which groups of query heads share a single key head and value head, using more key-value heads than multi-query attention but fewer than standard multi-head attention, to shrink the key-value cache and speed up decoding.

- Identifier: PTL-0255
- Category: Foundations
- Canonical URL: https://protologue.com/t/grouped-query-attention/
- Also known as: GQA, multi-query attention, MQA
- Introduced: 2023

## Description

Multi-query attention, which uses one key-value head for all query heads, decodes much faster than multi-head attention but can lose quality. Ainslie et al. proposed GQA in 2023 as an intermediate setting and showed how to convert ("uptrain") an existing multi-head checkpoint to it using about 5% of the original pre-training compute. They reported that uptrained GQA came close to multi-head quality at a speed comparable to multi-query attention. Because the KV cache grows with the number of key-value heads, the savings matter most for long contexts and large batches.

## Related terms

- [KV Cache](https://protologue.com/t/kv-cache/)
- [FlashAttention](https://protologue.com/t/flashattention/)
- [PagedAttention](https://protologue.com/t/pagedattention/)
- [Context Window](https://protologue.com/t/context-window/)

## Comparisons

- [Grouped-Query Attention vs Multi-Head Latent Attention](https://protologue.com/compare/multi-head-latent-attention-vs-grouped-query-attention/)

## Sources

- Ainslie et al. (2023). GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints. https://arxiv.org/abs/2305.13245

## Cite this entry

Protologue. (2026). Grouped-Query Attention. In Protologue: A Taxonomy of Prompting and LLM Techniques (v1.9.1, PTL-0255). https://protologue.com/t/grouped-query-attention/

License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
