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

Joshua Ainslie, James Lee-Thorp, Michiel de Jong, Yury Zemlyanskiy, Federico Lebrón +1 more
5/22/2023
cs.CLcs.LG

No official code found. Best implementation: fkodom/grouped-query-attention-pytorch (194 stars, MIT, last commit 2024-05-09). 1 more below.

Abstract

Multi-query attention (MQA), which only uses a single key-value head, drastically speeds up decoder inference. However, MQA can lead to quality degradation, and moreover it may not be desirable to train a separate model just for faster inference. We (1) propose a recipe for uptraining existing multi-head language model checkpoints into models with MQA using 5% of original pre-training compute, and (2) introduce grouped-query attention (GQA), a generalization of multi-query attention which uses an intermediate (more than one, less than number of query heads) number of key-value heads. We show that uptrained GQA achieves quality close to multi-head attention with comparable speed to MQA.

View on arXivView PDF

Code Implementations(2)

MIT

(Unofficial) PyTorch implementation of grouped-query attention (GQA) from "GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints" (https://arxiv.org/pdf/2305.13245.pdf)

19414PythonJul 19, 20232 years agoMIT
MIT

Combining Grouped-Query Attention (https://arxiv.org/abs/2305.13245) with Deformable Attention (https://arxiv.org/abs/2201.00520) in PyTorch.

10PythonMar 8, 20258 months agoMIT

Similar Papers

Cite this paper

@article{ainslie2023gqa,
  title  = {GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints},
  author = {Joshua Ainslie and James Lee-Thorp and Michiel de Jong and Yury Zemlyanskiy and Federico Lebrón and Sumit Sanghai},
  year   = {2023},
  eprint = {2305.13245},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2305.13245v3}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2305.13245.svg)](https://codeofpaper.com/paper/2305.13245)

Discussion