Command Palette
Search for a command to run...
Multi-Query Attention
Multi-Query Attention (MQA) is an attention variant that shares keys and values across all attention heads and keeps only multi-head queries. Standard multi-head attention needs to cache the keys and values of each step during autoregressive generation; the cache size grows linearly with the number of heads, so incremental decoding is therefore limited by memory bandwidth. MQA lets all heads share the same keys and values, compressing the cache to 1/h of the original and significantly reducing memory access overhead during decoding.
The method was proposed by Noam Shazeer of Google in 2019 in the technical report Fast Transformer Decoding: One Write-Head is All You Need. The paper was not published at a formal conference, but experiments showed that decoding speed could be greatly improved, with only a slight drop in quality relative to the baseline. Since then, models such as PaLM, Falcon, and StarCoder have adopted MQA; Grouped-Query Attention (GQA) strikes a compromise between it and standard multi-head attention by dividing attention heads into several groups and sharing keys and values within each group, becoming a more common choice in current large models.
Build AI with AI
From idea to launch — accelerate your AI development with free AI co-coding, out-of-the-box environment and best price of GPUs.