For a 64-Q-head model with GQA group size G=8, how many K/V heads exist and what is the cache reduction vs MHA?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
A transformer has 64 query heads. It uses GQA with group size G=8. How many K and V heads does it have? What is the KV-cache reduction factor relative to plain MHA at the same head_dim and sequence length? Does it cost extra FLOPs at inference time?
K and V heads equal 64/8 = 8, so the KV cache shrinks by exactly the group size G = 8x versus MHA, with zero extra inference FLOPs.
Picture 64 readers in a library, each needing a reference book. Under plain attention every reader gets a private copy, so the shelf holds 64 books. GQA arranges the readers into 8 teams of 8, and each team shares one book. Now the shelf holds only 8 books, eight times less storage. The readers still read independently and ask their own questions, so no reader does extra work. The only change is that teammates look at the same shared book instead of personal copies. You keep the same number of readers and the same reading effort, but you slash the shelf space. That shelf is the KV cache, and shrinking it is what lets you serve long contexts without running out of memory.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
3 min: do the 64/8 division, derive the cache reduction from the formula, confirm no FLOP penalty, then explain the HBM bandwidth win on decode.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Claiming GQA reduces query heads or adds inference FLOPs. Q heads stay at 64 and arithmetic is unchanged; only the count of cached K and V heads drops.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.