HomeAI & Machine LearningGrouped-Query Attention: Shrinking the KV Cache

Grouped-Query Attention: Shrinking the KV Cache

Interactive 3D visualiser for Grouped-Query Attention (GQA): watch query heads share a handful of key/value heads, tune the head count and group count live, and see exactly how much GPU memory the KV cache saves versus full multi-head attention.

AI & Machine Learning3DAdvanced60 FPS📱 Mobile-adapted⇄ 2D version
velyki-movni-modeli-llm-explained ↗ Open standalone

Every large language model has to keep a running cache of key and value vectors for every token it has already generated, and in plain multi-head attention that cache grows with the number of attention heads. Grouped-Query Attention (GQA) — used in LLaMA-2/3, Mistral, Gemma and most modern serving stacks — lets many query heads share one key/value head instead of owning their own, cutting the cache size (and the memory bandwidth needed to read it every token) by a large, tunable factor. This simulator renders the head-sharing topology in 3D: an outer ring of query heads, an inner ring of shared KV heads, and live attention-flow particles connecting each group, while you tune the head count, the group count, the cached sequence length and the model depth and watch the real KV-cache-size formula update in real time.

⚙ Under the hood

Interactive 3D visualiser for Grouped-Query Attention: watch query heads share a handful of key/value heads, tune the head count and group count live, and see exactly how much GPU memory the KV cache saves versus full multi-head attention.

transformersattentionllm-inferencekv-cachegpu-memoryneural-networks

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)