NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints

Joshua Ainslie, James Lee-Thorp, Michiel de Jong, Yury Zemlyanskiy, Federico Lebrón, Sumit Sanghai

Introduction

Large Language Models (LLMs) based on the Transformer architecture have revolutionized natural language processing. However, as these models scale, the computational and memory costs of inference become a significant hurdle. Standard Multi-Head Attention (MHA), while high-performing, suffers from memory bandwidth bottlenecks during autoregressive decoding. Multi-Query Attention (MQA) was introduced to alleviate this by sharing a single key and value head across all query heads, but often at the cost of model quality and training stability.

This paper introduces Grouped-Query Attention (GQA), a generalization that bridges the gap between the high quality of MHA and the high speed of MQA. Furthermore, we present an "uptraining" recipe that allows for the conversion of existing MHA checkpoints into GQA models with minimal additional compute.

The Memory Bandwidth Bottleneck

The primary bottleneck in scaling Transformers for real-world applications is often memory bandwidth rather than raw compute. During autoregressive decoding, the model generates text token-by-token. At each step, it must load the "KV cache"—the keys and values for all previous tokens—from memory. As sequence lengths and model sizes grow, the KV cache becomes massive, leading to significant latency.

MQA addresses this by reducing the size of the KV cache, but it can lead to training instability and lower performance. Moreover, most existing state-of-the-art models, such as LLaMA or the original T5, are trained with MHA. Retraining them from scratch to use MQA is prohibitively expensive and often unfeasible for many research teams.

Grouped-Query Attention (GQA)

Grouped-Query Attention (GQA) provides a tunable trade-off between the speed of MQA and the quality of MHA. Instead of a single KV head for all queries (MQA) or a unique KV head for every query (MHA), GQA partitions query heads into groups, where each group shares a single KV head.

Visual comparison of Multi-head, Grouped-query, and Multi-query attention. GQA provides a tunable middle ground by grouping query heads to share key and value heads.

By adjusting the number of groups, developers can optimize for their specific hardware and performance requirements. For instance, GQA-8 (using 8 groups) has been found to be a "sweet spot" for many large-scale models, recovering nearly all the quality of MHA while retaining most of the speed gains of MQA.

Efficient Model Conversion via Uptraining

A key contribution of this work is the method for "uptraining" existing MHA checkpoints. Rather than starting from scratch, we initialize GQA KV heads by mean-pooling the existing projection matrices from an MHA checkpoint.

The mean-pooling process used to initialize GQA/MQA key projections from an existing multi-head checkpoint.

This mean-pooling preserves the aggregate pre-trained information more effectively than random initialization or selecting a single head. Following conversion, the model undergoes a brief period of additional pre-training—typically only 5% of the original training compute—to adapt to the new architecture. This makes upgrading existing models for faster inference highly accessible and sustainable.

Experimental Results

The authors evaluated GQA using the T5 architecture (Large and XXL versions) across various benchmarks, including summarization (CNN/Daily Mail, arXiv, PubMed), translation (WMT), and question answering (TriviaQA).

On the T5-XXL model, GQA-8 achieved an average score of 47.1, nearly matching the MHA baseline of 47.2. Crucially, it achieved an inference time of 0.28s per sample, a roughly 5x speedup over MHA's 1.51s. While MQA was slightly faster at 0.24s, it suffered a more significant drop in quality (46.6). GQA thus provides a significant quality boost over MQA with negligible impact on latency. Furthermore, the scaling benefits are profound: a GQA-XXL model is not only faster than an MHA-Large model but also significantly higher in quality.

Conclusion

Grouped-Query Attention and the associated uptraining recipe offer a practical path forward for deploying high-performance LLMs. By providing a middle ground between MHA and MQA, GQA allows for significant inference speedups without sacrificing the quality of established multi-head models. The efficiency of the uptraining process ensures that existing investments in model training can be leveraged to meet the demands of real-time applications and long-sequence processing.

Summary updated

BibTeX
@inproceedings{ainslie2023gqa,
  author = {Joshua Ainslie and James Lee-Thorp and Michiel de Jong and Yury Zemlyanskiy and Federico Lebrón and Sumit Sanghai},
  title = {{GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  url = {https://openreview.net/forum?id=EANxB80Y9T},
}
Figure