← All questions
Inference & ServingMedium· Attention Mechanisms· KV Cache

What is the difference between MQA, GQA, and MHA? When...

Multi-Head Attention (MHA) provides maximum expressiveness but requires the most cache. Multi-Query Attention (MQA) uses a single KV head, which minimizes cache but often results in quality loss at scale. Grouped Query Attention (GQA) strikes the best balance by grouping queries to share KV pairs, making it the default choice for modern production models. MQA is largely considered obsolete for large models, while MHA is reserved for legacy or small-scale architectures.

Code playground (Python)