grouped query attention gqa
**Grouped Query Attention (GQA)** is **the attention mechanism that shares key and value projections across groups of query heads, interpolating between multi-head attention (MHA) and multi-query attention (MQA)** — reducing KV cache size by 4-8× while maintaining 95-99% of MHA quality, used in Llama 2, Mistral, and other modern LLMs to enable efficient long-context inference within memory constraints.
**GQA Architecture:**
- **Head Grouping**: divides H query heads into G groups; each group shares single K and V head; group size H/G typically 4-8; example: Llama 2 70B uses 64 query heads with 8 KV heads (8 groups of 8 queries each)
- **Projection Dimensions**: query projection Q has dimension d_model → H×d_head; key and value projections K, V have dimension d_model → G×d_head where G<
Go deeper with CFSGPT
Get AI-powered deep-dives, save terms, and run advanced simulations — free account.
Create Free Account