Glossary · Attention

QK-norm

Also: query-key normalizationq_normk_norm

Read it at the depth you need: one sentence · a paragraph · the math · in the models here

1In one sentence

An extra RMSNorm applied to queries and keys before their dot product, which keeps attention scores from blowing up during training.

2In a paragraph

If queries and keys grow large, their dot products grow quadratically and the softmax collapses onto a single token, which destabilizes training. QK-norm normalizes q and k (usually per head) before scoring them, so the logits stay in range. It costs almost nothing: two small weight vectors per layer.

3The math, shapes and parameters

score = RMSNorm(q)·RMSNorm(k) / √h

Qwen3 and Gemma 3 normalize each head with a shared weight of size h: q_norm and k_norm, [h] each, so 2h parameters per layer. OLMo 2 normalizes across all heads at once ([H·h] and [K·h]). Llama 4 uses a plain L2 norm with no weights at all.

Term by term on Notation Decoder, the sister site: RMSNorm, decoded

4In the 96 models on this site

25 models here: Gemma 3 270M per head · Qwen3 0.6B per head · Gemma 3 1B per head · OLMo 2 1B all heads · Qwen3 1.7B per head · Gemma 3 4B per head · Qwen3 4B per head · OLMo 3 7B all heads · OLMo 2 7B all heads · Qwen3 8B per head · Gemma 3 12B per head · OLMo 2 13B all heads · Qwen3 14B per head · Gemma 3 27B per head · Qwen3 30B-A3B per head · OLMo 3 32B all heads · OLMo 2 32B all heads · Qwen3 32B per head · Llama 4 Scout (17B-16E) L2 · MiniMax M2 all heads · Qwen3 235B-A22B per head · Inkling-Small per head · GLM-4.5 per head · Inkling per head · Ling-1T per head.

Introduced in Dehghani et al., “Scaling Vision Transformers to 22 Billion Parameters” (2023).

Related

RMSNorm · Self-attention · every term