Grouped-query attention / MQA

Transformer components · component · 2019 · text

What it is

Share one key/value projection across groups of query heads, shrinking the KV cache by 4–8x at almost no quality cost.

When to use it

Serving any large model: the difference between fitting a long context in VRAM or not.

Caveats

Sharing key and value heads reduces capacity, and going all the way to a single shared head (MQA) can cost quality. The saving is in the KV cache and memory traffic at inference, not in training compute.

Key ideas

  • MHA to MQA to GQA is a memory-bandwidth optimization, not a quality trade
  • Now standard in Llama, Mistral, Qwen and essentially every open model

Related architectures

Original paper

Fast Transformer Decoding: One Write-Head is All You Need (2019, arXiv)

Lessons that cover it

Browse all 198 architectures

The architecture landscape, in one place.

Two things get called “ML architecture”: the classical statistical model families, and the neural network wirings. Both are here, tagged by what they are and what data they eat.

Start from your problem

Architectures

0 shortlisted