MQA: Pioneering Memory Savings in LLMs

Multi-Query Attention (MQA) significantly reduces memory bandwidth and KV cache storage by sharing a single key and value head across all attention heads, potentially offering 10-100x smaller KV cache and 12x faster decoder inference, though sometimes at the cost of accuracy.

The top 3

  1. MQA's Genesis: Pioneered by Google's Noam Shazeer: Multi-Query Attention (MQA) was first introduced in the 2019 paper "Fast Transformer Decoding: One Write-Head is All You Need" by Google's Noam Shazeer, aiming to dramatically reduce memory bandwidth during Transformer decoding.
  2. KV Cache Savings: Up to 32x Memory Reduction: MQA dramatically shrinks the Key-Value (KV) cache by having all query heads share a single Key and Value record, leading to memory savings proportional to the number of heads—for example, a 32-head model can see a 32x reduction in KV cache size. This enables larger batch sizes and longer contexts.
  3. MQA's Evolution: Paving the Way for Grouped-Query Attention (GQA): MQA served as a crucial stepping stone for Grouped-Query Attention (GQA), which acts as a hybrid between MQA and traditional Multi-Head Attention (MHA). GQA uses an intermediate number of KV heads, balancing MHA's quality with MQA's efficiency, and is now widely adopted in models like LLaMA, Mistral, and Gemma.

Sources

Open the full topic