What inference memory bottleneck motivated multi-query and grouped-query attention?

Last updated 22 November 2026

  • The bottleneck is the KV cache (stored keys/values) in autoregressive decoding: each step reads all cached K/V from HBM for one query, so arithmetic intensity is about 1 and decoding is memory-bandwidth-bound.

  • Cache size is 2 × layers × n_kv_heads × d_head × seq_len × batch × bytes, e.g. about 10.7 GB for one 4k fp16 sequence on an 80-layer, 64-head model, which caps batch size and context length.

  • MQA/GQA share K/V heads to cut bytes read and memory used (8 KV heads drops the example to about 1.3 GB). Related fixes include KV quantization, PagedAttention, sliding windows and latent attention.

  • https://medium.com/@mustafa.gencc94/transformers-llms-part-8-sharing-attention-heads-99873706e0fb
  • https://medium.com/@saeed.mehrang/understanding-grouped-query-attention-a-practical-guide-with-pytorch-implementation-9e3f9f26bb79
  • https://arxiv.org/html/2601.14053v1
All Transformers interview questions