Grouped Query Attention
PremiumAdd GQA/MQA support so multiple query heads share KV, reducing KV cache memory.
Get code accessIn previous chapters, we built a full Flash Attention kernel with arbitrary sequence length, multi-dim parallelism, and causal masking. Now we add the final key feature: Grouped Query Attention (GQA).
This is standard in Llama 2/3, Mistral, Falcon, etc. It can reduce KV cache memory by 4–8× with minimal quality loss.
Quick GQA Recap
GQA shares Key/Value heads across multiple Query heads:
Log in to continue reading
This is premium content. Please log in to access the full article.
CookLLM Docs