Attention

Grouped-query attention (GQA)

Several query heads share one key/value head, shrinking the KV cache several-fold with little quality loss.

First page of GQA: Training Generalized Multi-Query Transformer Models from Multi-Head CheckpointsIntroduced inMay 2023GQA: Training Generalized Multi-Query Transformer Models from Multi-Head CheckpointsAinslie et al. · arXiv 2305.13245 ↗
Multi-head: 8 Q → 8 KVGQA: 8 Q share 2 KVMHA cacheGQA cachesame tokens,4× less memory

In classic multi-head attention every head has its own keys and values, and all of them must be cached for every generated token. GQA keeps many query heads but lets groups of them share a single key/value head. With one shared KV head this becomes multi-query attention. Since KV-cache size is what limits batch size and context length at inference time, nearly every recent LLM uses it.

Adoption over time

Share of new models that have included GQA over time.

51%2022202320242025202651%20222023202420252026

See it in real models

Open any of these on hfviewer to find this block in the interactive architecture graph.

Qwen/Qwen3-0.6B architecture graphQwen/Qwen3-0.6Btext-generation · ↓ 29.9M · ♡ 2kOpen in visualizer Comfy-Org/MiniMax-H3 architecture graphComfy-Org/MiniMax-H3↓ 23.3M · ♡ 2kOpen in visualizer Qwen/Qwen3-4B architecture graphQwen/Qwen3-4Btext-generation · ↓ 11.6M · ♡ 761Open in visualizer Qwen/Qwen2.5-7B-Instruct architecture graphQwen/Qwen2.5-7B-Instructtext-generation · ↓ 9.7M · ♡ 2kOpen in visualizer Qwen/Qwen3-8B architecture graphQwen/Qwen3-8Btext-generation · ↓ 9.4M · ♡ 2kOpen in visualizer Qwen/Qwen3-Embedding-0.6B architecture graphQwen/Qwen3-Embedding-0.6Bfeature-extraction · ↓ 8.7M · ♡ 1kOpen in visualizer Qwen/Qwen3.5-9B architecture graphQwen/Qwen3.5-9Bimage-text-to-text · ↓ 8.6M · ♡ 2kOpen in visualizer Qwen/Qwen2.5-0.5B-Instruct architecture graphQwen/Qwen2.5-0.5B-Instructtext-generation · ↓ 8.5M · ♡ 631Open in visualizer google/gemma-4-31B-it architecture graphgoogle/gemma-4-31B-itimage-text-to-text · ↓ 8.3M · ♡ 4kOpen in visualizer Qwen/Qwen3-14B architecture graphQwen/Qwen3-14Btext-generation · ↓ 7.7M · ♡ 507Open in visualizer Qwen/Qwen3.8-27B architecture graphQwen/Qwen3.8-27Bimage-text-to-text · ↓ 7.5M · ♡ 19kOpen in visualizer Qwen/Qwen2.5-1.5B-Instruct architecture graphQwen/Qwen2.5-1.5B-Instructtext-generation · ↓ 7.4M · ♡ 841Open in visualizer

View 4,291 catalog matches for Grouped-query attention (GQA) →

Related concepts

hfviewer renders the full architecture of 12,800+ Hugging Face models as interactive graphs. Hover any block to see what it does, with this model’s real numbers.

Browse all model graphs →