The Gradient Difference Induced by Detaching the Denominator in QK Normalization
Abstract
QK normalization divides each query and key by its own RMS norm before the attention scores are computed. Treating this denominator as a constant during backpropagation leaves the forward pass unchanged but alters the parameter gradients. We derive a closed form for the difference between the gradient under this detached rule and the gradient under the standard rule. For a single token, this difference is parallel to the token's own query; it changes only the query norm and has no first-order effect after normalization. The queries, however, are computed by a projection matrix shared across all tokens. The gradient difference on therefore equals right-multiplied by a weighted second moment of the inputs, and it decomposes exactly into three components: a radial component that changes only the norm of , a tangential component that changes the query directions of other tokens, and an upstream component that changes the gradient passed to earlier layers. Under AdamW, the radial component drives to a larger equilibrium norm and reduces its angular update per step. Paired experiments on a small Transformer language model are consistent with this analysis. Detaching the query denominator consistently raises the test loss, and the gap persists across hardware, evaluation datasets and learning rates. All three components remain non-negligible throughout training, with the tangential component the largest. Norm growth and the smaller angular update appear only on the detached projection matrix, while the other projection matrix is essentially unchanged. With a learnable scale, however, we observe no resolvable loss gap.
Create a lesson
Metadata
- Comments
- 20 pages, 5 figures, 7 tables. Yuanqi Zhang and Haocheng Wang contributed equally
Related papers
Improving Tail-Augmented Speculative Drafting with Hidden State Mixing and Gradient Detach
Shared title terminologycs.LGYaniv Galron, Rabeeh Karimi Mahabadi, Maor Ashkenazi et al.
Kolpona: An Agentic Framework with Gradient-Free Neuron Programming for RTL Generation
Shared title terminologycs.LGMusa Tur Farazi, Md Nasir Uddin, Soumik Bhattacharjee et al.
Normalizing Flows are Capable World Models
Shared title terminologycs.LGZijia Li, Yong-Hyun Park, Shusheng Yang et al.
DiffER^2: Diffusion Ensembles for Retrosynthesis Prediction with SMILES Adapted Particle Guidance
Shared title terminologycs.LGSean Current, Daniel Adu-Ampratwum, Xia Ning et al.
A Bias in Disguise: Tiny Gradient Edits Stop a Small Language Model's Thinking Loops and Complement a Frontier Model's Weight Edit
Shared title terminologycs.LGHussamuddin Syed