41What are Multi-Query (MQA) and Grouped-Query Attention (GQA), and why do they exist?▼hardGoogleMetaMistral2 replies◆ premiumMQA and GQA shrink the KV cache, the thing that bottlenecks LLM serving. The signal is understanding they share key/value heads across query heads to trim memory and bandwidth, with GQA as the quality-preserving middle ground. Here is the answer.Open full answer →
102Implement multi-head attention from scratch with a KV cache for decoding, then extend it to grouped-query attention.▼expertOpenAIAnthropicDatabricks◆ premiumPlain multi-head attention is rarely the whole exercise: the usual extension is to chain it into KV-cached decoding and GQA in one sitting. The locked answer walks the NumPy implementation, the equivalence check that proves your cache is correct, and the reshape bugs that silently corrupt attention.Open full answer →