Profile

Settings

Loading…

← Papers

Help

FAQ

Which features require signing in?

You can read the commentary, paper info, Model Structure and related papers of public papers without signing in. Sign in to manage your account or contact us about your inquiries.

Can I upload a PDF file?

Upload papers with an arXiv or DOI link; the commentary is public to everyone. Papers whose source and terms of use can't be verified, so the commentary can't be made public, can't be uploaded. Uploading PDF files and keeping papers private are for subscribers only, and a paper uploaded as a file is saved as private only. Searching for official info by title runs only when you press the button.

Are the figures and AI commentary accurate?

Figures come only from the original paper, and only those whose terms of use are verified are shown. The commentary is written by AI and may be wrong. Check important claims, numbers and figure context against the evidence in the original paper.

I want to report a copyright issue.

Terms of use and the source of the original paper are on the Paper info tab. If there's a problem, choose "Paper content, figures and copyright" under Contact us and send the paper link, the part in question, and evidence that you hold the rights. Receiving your report doesn't confirm any rights or remove anything right away. You can see the result of the review under My inquiries.

I forgot my password.

If you signed up with email, use Forgot password in the sign-in window to reset it with your verified email. If you signed up with Google, Naver or Kakao, change your password with that service.

What should I include in an inquiry?

Tell us which screen you were on and what you were doing when the problem happened, along with the paper link. Don't include personal information such as passwords, API keys, verification codes or phone numbers. Inquiries and replies are stored in Refivu and you can see them under My inquiries.

How do I delete my account?

In Settings, under My account, press Delete account. Review what will be deleted and complete identity verification to delete your account. For other requests, choose "Account" under Contact us.

Paper commentary

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

  • Problem Autoregressive decoding is bottlenecked by memory bandwidth, because each step reloads decoder weights and every cached attention key and value.
  • Method Mean-pools the key and value heads of a multi-head checkpoint, uptrains it for 5% of the original pre-training steps, and introduces grouped-query attention, which gives each group of query heads one shared key head and value head.
  • Results GQA-8-XXL reached an average dev score of 47.1 against 47.2 for MHA-XXL, with 0.28 s time per sample against 1.51 s.

Figure 2: Overview of grouped-query method. Multi-head attention has H query, key, and value heads. Multi-query
attention shares single key and value heads acr…

Figure 2 : Overview of grouped-query method. Multi-head attention has H query, key, and value heads. Multi-query attention shares single key and value heads across all query heads. Grouped-query attention instead shares single key and value heads for each group of query heads, interpolating between multi-head and multi-query attention.

Original paper · CC BY 4.0 · Joshua Ainslie, James Lee-Thorp, Michiel de Jong, Yury Zemlyanskiy, Federico Lebrón, Sumit Sanghai · GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints · Original paper figure · Extracted the figure area from page 2 of the original PDF.

Why decoder inference is slow

Autoregressive decoding in Transformer models is limited by memory bandwidth, because every decoding step reloads the decoder weights and all cached attention keys and values. Reducing the number of key and value heads shrinks the cached data read at each step, which is the idea behind multi-query attention, where many query heads read from a single key head and value head.

The cost is that multi-query attention can lower quality and make training less stable, and training a separate model only for fast inference may not be practical.

Some language models already use multi-query attention, such as PaLM, while widely used public models such as T5 and LLaMA do not. That gap suggests a route that starts from existing multi-head checkpoints rather than training new multi-query models from scratch. This paper proposes two steps for this route: uptraining multi-head checkpoints into multi-query models, and grouped-query attention as a design between multi-head and multi-query attention.

Converting and uptraining a multi-head checkpoint

Uptraining has two stages: the checkpoint is first converted to the new structure, and then it is pre-trained further so the model can adapt to that structure. Conversion mean-pools the key and value projection matrices of all original heads into a single projection, so the multi-query model keeps one key head and one value head. The authors chose mean pooling over keeping a single original head or initializing new key and value heads at random, and the comparison of these options is covered in the conversion ablation.

The converted model is then pre-trained for a further proportion alpha of its original training steps, using the same recipe and dataset as the original T5 pre-training. Uptrained models start from public T5.1.1 checkpoints, and the Adafactor optimizer is used with the same hyperparameters and learning rate schedule as T5. For alpha equal to 0.05, training of the T5-XXL model took about 600 TPUv3 chip-days.

How grouped-query attention is structured

Grouped-query attention divides the query heads into G groups, and each group shares a single key head and a single value head. The notation GQA-G names the variant with G groups, so GQA-1 has one group and reduces to MQA, while GQA-H, with one group per head, reduces to MHA.

When a multi-head checkpoint is converted to GQA, the key and value head of each group is the mean of the original heads in that group. Going from MHA to MQA cuts the key and value heads from H to one, which reduces the key-value cache and the data loaded per step by a factor of H. Larger models usually have more heads, so the same MQA cut becomes more aggressive as models grow, while GQA keeps a proportional reduction in bandwidth and capacity.

The authors argue that larger models suffer less from attention memory overhead, because the KV-cache grows with model dimension while FLOPs and parameters grow with its square. Standard sharding for large models copies the single key and value head across model partitions, and GQA avoids that duplication.

Models, data and evaluation settings

All models are based on the T5.1.1 architecture and implemented with JAX, Flax and Flaxformer. The main experiments compare T5-Large and T5-XXL with multi-head attention against uptrained T5-XXL models with multi-query and grouped-query attention.

Summarization is evaluated on CNN/Daily Mail, arXiv, PubMed, MediaSum and Multi-News, translation on WMT 2014 English-to-German, and question answering on TriviaQA. The classification benchmark GLUE was not used, because autoregressive inference is less relevant for those tasks.

Accuracy is reported as dev set scores and speed as time per sample, so the two columns measure different things even though they come from the same rows of Table 1.

Quality against inference time

MHA-XXL has an average dev score of 47.2 at 1.51 s time per sample, while the 5% uptrained MQA-XXL scores 46.6 at 0.24 s and the 5% uptrained GQA-8-XXL scores 47.1 at 0.28 s. MHA-Large scores 46.0 average at 0.37 s time per sample.

Against MHA-Large, the uptrained MQA-XXL has a higher average score, 46.6 against 46.0, and is faster, at 0.24 s against 0.37 s. The authors describe a larger uptrained MQA model as a favorable trade-off relative to the multi-head models, as summarized in Figure 3.

GQA-8-XXL sits close to MHA-XXL on average, at 47.1 against 47.2, while its time per sample is 0.28 s against 1.51 s.

These are dev set scores from greedy decoding for the 5% uptrained T5-XXL models, and speed was measured on TPUv4 chips with 8 TPUs. The authors caution that Rouge is an imperfect evaluation for summarization, so the trade-off conclusions drawn from the summarization columns are uncertain.

Choosing how to convert the key and value heads

Figure 4 compares three conversion methods for T5-Large uptrained to MQA with a proportion of 0.05: mean pooling, keeping the first head, and random initialization. Mean pooling gave the highest performance, followed by the first head and then random initialization.

The authors read the ordering as following how much information from the pre-trained model each method keeps. The ablation uses a representative subsample of tasks, namely CNN/Daily Mail, MultiNews and TriviaQA, so the ordering is measured on those three datasets.

How much uptraining is needed

Figure 5 varies the uptraining proportion from 0 to 0.1 for T5 XXL models with MQA and GQA-8, with the multi-head model shown as a reference. GQA reaches reasonable performance directly after conversion, while MQA needs some uptraining before it becomes useful.

Both MQA and GQA gain from uptraining 5% of the original steps, and the gains show diminishing returns from 10%.

Cost of adding key-value groups

Figure 6 plots time per sample for GQA-XXL against the number of GQA groups, from 1 to 64, with input length 2048 and output length 512. Going from 1 group (MQA) to 8 groups adds only modest inference overhead, and the cost rises as more groups are added toward MHA.

The authors explain that for larger models the memory bandwidth overhead from the KV cache is less constraining, while the reduction in key-value size grows with the number of heads.

Where GQA sits among efficiency methods

Shazeer first proposed reducing this overhead through multi-query attention, and follow-up work found it especially helpful for long inputs. Rabe independently developed GQA with a public implementation, and other works grouped attention heads for computational efficiency without focusing on key-value heads.

Flash attention, quantization, model distillation, layer-sparse cross-attention and speculative sampling each target different costs, such as the quadratic attention scores, weight precision, model size, cross-attention layers or sequential token generation. The uptraining procedure is inspired by Komatsuzaki et al., who upcycle standard T5 checkpoints into sparsely activated Mixture-of-Experts models.

Limits of the evidence

Summarization results rely on Rouge, which the authors describe as a flawed evaluation that does not capture everything, so the summarization trade-offs may be uncertain. The evaluation covers only encoder-decoder models, and the expected larger advantage of GQA over MQA for decoder-only models was not measured.

The XXL GQA model was not compared with a model trained from scratch, so the relative performance of uptraining and training from scratch is unknown. The conversion ablation uses T5-Large and the uptraining-proportion ablation uses T5 XXL, so the ablation settings differ in model size from the main comparison.

The work targets the memory bandwidth cost of loading keys and values, which matters most when generating long sequences whose quality is hard to evaluate.

Paper info

Authors
Joshua Ainslie, James Lee-Thorp, Michiel de Jong, Yury Zemlyanskiy, Federico Lebrón, Sumit Sanghai
Venue
arXiv · Preprint
First published
2023-5-22
Added
2026-10-20
Updated
2023-12-23
Version
v3
arXiv
2305.13245
Category
cs.CL · cs.LG
Original paper terms
CC BY 4.0
What we show
Paper info, commentary and permitted figures from the original paper

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

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.

Quote from the paper

Joshua Ainslie, James Lee-Thorp, Michiel de Jong, Yury Zemlyanskiy, Federico Lebrón, Sumit Sanghai (2023). GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints. arXiv:2305.13245v3. https://arxiv.org/abs/2305.13245v3

BibTeX
@misc{ainslie2023training,
  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 = {https://arxiv.org/abs/2305.13245v3}
}

See related papersBrowse other papers

Paper preview
Account security

Connect Google account

If you connect a Google account, you can sign in with it too.

Refivu

Delete account

Refivu
Refivu

Sign up