What inference memory bottleneck motivated multi-query and grouped-query attention?
Last updated
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.