Home Knowledge Base Attention Head Scaling

Attention Head Scaling is the sqrt(d_k) divisor used inside scaled dot-product attention so scores remain in a numerically stable range before the softmax — dividing dot products by the square root of the key dimension prevents very large values that would collapse softmax probabilities and choke gradients.

What Is Head Scaling?

Why Scaling Matters

Scaling Variants

Standard sqrt(d_k):

Head-wise Scaling:

Bias + Scale:

How It Works / Technical Details

Step 1: After computing the dot product between queries and keys, multiply the result by the scalar 1/sqrt(d_k) to normalize variance.

Step 2: Feed the scaled logits into softmax, ensuring the distribution stays smooth and gradient-friendly; head-wise scaling further trains these scalars.

Comparison / Alternatives

AspectScaled AttentionUnscaledLearnable Scale
Variance ControlYesNo
Gradient StabilityHighLow
ComplexityMinimalMinimal
ViT Best PracticeRequiredNot recommended

Tools & Platforms

Attention head scaling is the simple divisor that makes multi-head attention numerically tame despite large key dimensions — without it, the softmax becomes brittle and transformers lose their ability to learn.

attention head scaling

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.