GQA: Balancing Speed, Memory, and LLM Accuracy

Grouped Query Attention (GQA), used in models like Mistral and Llama 2/3, optimizes transformer efficiency by grouping multiple query heads to share key and value projections. This technique significantly reduces KV cache memory usage and speeds up inference, striking a balance between the high accuracy but high memory of Multi-Head Attention (MHA) and the fast but less accurate Multi-Query Attention (MQA). For example, GQA can make Llama 3 up to five times faster with 99.8% quality retention, and a 4:1 GQA ratio can reduce KV cache size by 75% compared to MHA.

Sources

Open the full topic