Which config token names the count of parallel attention heads in a layer?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
n_heads (or num_attention_heads in HuggingFace configs, h in papers) names the number of parallel (Q, K, V) projection slices in one attention layer.
Imagine the model's config file as a recipe card. One line says how many separate burners the attention kitchen runs in parallel. That number is n_heads, the count of independent attention paths through a single layer. Modern recipes also have a second number for how many shared sauce pots feed all those burners (num_kv_heads under GQA), but the burner count itself is n_heads.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
3m: the canonical names (n_heads, num_attention_heads, h), what they control vs do not control, the split into num_kv_heads under GQA, and concrete production examples like Llama 4 Maverick's 64 query heads with 8 KV heads.
| Token | Where it appears | What it counts |
|---|---|---|
| n_heads | Papers, casual usage | Parallel attention heads per layer |
| num_attention_heads | HuggingFace config.json | Same as n_heads |
| num_heads | Some libraries (PyTorch nn.MultiheadAttention) | Same as n_heads |
| h | Math notation in papers | Same as n_heads |
| num_key_value_heads | HuggingFace config.json (GQA/MQA models) | Number of distinct K, V heads in the cache |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Confusing n_heads (query side) with num_kv_heads (cache side). Under MHA they are equal; under GQA or MQA they differ and conflating them gives wrong cache math.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.