Controlling changes to attention logits

Ben Anson, Laurence AitchisonarXiv 2025 · DOI

Training large-scale Transformer models is notoriously difficult due to inherent instabilities. A primary driver of these instabilities is the "blow-up" of attention logits—the raw scores calculated before the softmax layer. When these values grow excessively large or change abruptly between steps, gradients can explode, leading to training failure. In "Controlling changes to attention logits," researchers Ben Anson and Laurence Aitchison introduce QuacK (Query and Key control), a principled method to stabilize training by dynamically adjusting learning rates based on the weight norms of the attention mechanism.

The Challenge of Attention Logit Blow-up

In standard Transformers, the attention mechanism computes scores by multiplying Query ($Q$) and Key ($K$) matrices. As training progresses, the weights in these matrices typically grow. Because the operation is quadratic ($Q \times K^T$), even minor updates to the weights can cause massive, destabilizing jumps in the resulting logits.

The current industry standard for mitigating this is QK norm, which applies LayerNorm or RMSNorm to queries and keys before their interaction. While effective for stability, QK norm is incompatible with high-efficiency architectures like Multi-Latent Attention (MLA), used in models such as DeepSeek-V3. MLA relies on low-rank compression to minimize KV-cache requirements; QK norm necessitates "materializing" full matrices during inference, which negates these efficiency gains. Other alternatives, like QK clipping, are often cumbersome to implement and require custom kernels.

The QuacK Method

QuacK adopts a "$\mu$P-inspired" approach by modifying the optimizer's behavior rather than the model's architecture. The core objective is to bound the change in logits ($\Delta L$). Using a first-order Taylor expansion, the authors demonstrate that the change in logits is roughly proportional to the update of one matrix multiplied by the norm of the other. To maintain stability, they propose parameter-specific learning rates:

  • The QuacK Rule: The learning rate for Query weights ($\eta_Q$) should be proportional to the inverse norm of the Key weights ($\|W_K\|^{-1}$), and vice versa.

By scaling updates this way, if the "Keys" are large, the optimizer becomes more cautious when updating the "Queries." This is implemented as a simple wrapper around the optimizer that adjusts the learning rate for each attention head at every step.

QuacK effectively bounds both the absolute magnitude and the step-to-step change of attention logits compared to the default baseline.

Experimental Evaluation

The researchers validated QuacK by pretraining 1B parameter models based on the Qwen3 architecture using a subset of the Cosmopedia-V2 dataset. Training was conducted over 5,000 steps using the Muon optimizer.

Key Results

  • Stability at High Learning Rates: At an aggressive base learning rate ($\eta = 3e-2$), standard models and QK-clip baselines became unstable or failed. QuacK remained perfectly stable, matching the robustness of QK norm.
  • MLA Compatibility: In the MLA setting where QK norm is not viable, QuacK significantly outperformed QK-clip and simple ablation baselines in final validation loss.
  • Efficiency: By moving stabilization to the optimizer's weight update phase, QuacK removes the need for RMSNorm operations in the forward pass, resulting in a measured ~10% speedup in training compared to QK norm.
Validation loss comparison across MHA and MLA architectures showing QuacK's stability and performance relative to baselines.

Discussion and Future Work

QuacK demonstrates that controlling the change in logits is as critical as controlling their absolute magnitude. By reining in these deltas, the method preserves model expressivity while preventing training crashes. While these results are promising at the 1B parameter scale over 5,000 steps, future work is needed to confirm if these inter-parameter dynamics scale linearly to 70B+ parameter models and over hundreds of billions of tokens.

In summary, QuacK offers a "best of both worlds" solution: the stability of normalization with the architectural flexibility and speed of unnormalized attention, making it a significant practical upgrade for modern, efficient Transformer architectures.

Summary updated

BibTeX
@misc{anson2025controlling,
  author = {Ben Anson and Laurence Aitchison},
  title = {{Controlling changes to attention logits}},
  year = {2025},
  eprint = {2511.21377},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2511.21377},
}
Figure