Grouped Query Attention › Key Parameters

Michael BrenndoerferUpdated August 6, 20251 min read
Language AI HandbookAll chapters
Part 29 of 67Modern Decoder Models
Chapter 209Grouped Query Attention › Key Parameters
Reading section 12 of 14 · Key Parameters · 1 minSection 12 of 14 · 1 min

Section 12 of 14 · 1 min read

Grouped Query Attention › Key ParametersSection view · Sections in this chapter12 / 14 ↓
Reading tools Definitions, links & notes

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Notes & comments

When implementing or configuring GQA, the following parameters have the most significant impact on behavior:

  • num_heads (h): The number of query heads. Determines query diversity and must be divisible by num_kv_heads. Common values: 32 (7B models), 64 (70B models). More heads enable more diverse attention patterns but require proportionally more query projection parameters.

  • num_kv_heads (g): The number of key-value groups. Controls the memory-quality trade-off. Must divide num_heads evenly. Common values: 8 for large models (GQA-8), 1 for MQA, equal to num_heads for MHA. Lower values reduce KV cache memory but may impact quality on complex reasoning tasks.

  • head_dim (d_k): Dimension per attention head, computed as d_model // num_heads. Typical values: 64 or 128. Affects the expressiveness of each attention head and determines the KV cache size per head.

  • d_model: Model dimension, must be divisible by num_heads. Standard values: 4096 (7B), 8192 (70B). Larger dimensions increase model capacity but also increase memory requirements.

  • Query-to-KV ratio (num_heads // num_kv_heads): Determines how many query heads share each KV head. A ratio of 8:1 (GQA-8) has emerged as the industry standard. This provides 8x memory reduction with minimal quality impact.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy