Why Gradients Rapidly Increase Near the End of Training

Aaron DefazioarXiv 2025 · DOI

Abstract

During the final stages of training large language models (LLMs), researchers often observe a sharp increase in gradient norms, a phenomenon known as "tail blow-up." This paper identifies the root cause as an unintended interaction between standard weight decay and decaying learning rate schedules in the presence of normalization layers. We derive a theoretical steady state for the ratio of gradient norm to weight norm and show that it diverges as the learning rate approaches zero. To address this, we propose Corrected Weight Decay, which scales the decay coefficient by the learning rate. Our experiments demonstrate that this simple modification stabilizes training norms and improves final model performance across both LLM and computer vision benchmarks.

Introduction

Monitoring the "health" of an LLM training run typically involves tracking the gradient norm. A stable gradient norm suggests a smooth optimization process, while sudden spikes can indicate instability. A persistent but poorly understood observation in long-duration runs is the "uptick" or "blow-up" of gradients near the end of training, coinciding with the cooling phase of the learning rate schedule.

This paper, authored by Aaron Defazio at FAIR, investigates the mathematical underpinnings of this phenomenon. We find that the standard implementation of weight decay (as seen in AdamW) is fundamentally incompatible with learning rate schedules that decay to zero, leading to an artificial inflation of gradients and a collapse of weight norms.

The Mechanism of Gradient Blow-up

In models utilizing normalization layers (such as LayerNorm or BatchNorm), the gradient $g$ is naturally orthogonal to the weights $x$. Under these conditions, weight decay acts as a balancing force. We derive that in a steady state, the ratio of the gradient norm to the weight norm converges to a value proportional to the square root of the ratio of weight decay $\lambda$ to learning rate $\gamma$: $$\frac{\|g\|}{\|x\|} \approx \sqrt{\frac{\lambda}{\gamma}}$$

In standard training recipes, $\lambda$ is held constant while $\gamma$ follows a decay schedule (e.g., cosine decay) toward zero. As $\gamma \to 0$, the denominator in the equilibrium ratio vanishes, forcing the "target" gradient norm to blow up toward infinity.

The ratio of gradient norm to weight norm follows a theoretical steady state that diverges as the learning rate decays.

As shown in the figure above, experimental data closely tracks this theoretical prediction. The purple lines represent individual layers, which converge to the theoretical steady state (dashed red line) that rises sharply as the run progresses and the learning rate drops.

Corrected Weight Decay

To maintain a constant target equilibrium throughout training, we propose scaling the weight decay parameter by the current learning rate: $$\hat{\lambda}_t = \lambda \frac{\gamma_t}{\gamma_{max}}$$ This modification, implemented in the AdamC and SGDC optimizers, ensures that the ratio $\sqrt{\hat{\lambda}_t/\gamma_t}$ remains constant. This simple, one-line change prevents the late-stage collapse of weight norms and the subsequent explosion of gradients.

Experimental Results

We evaluated the "C" variants of standard optimizers on two major benchmarks: a 120M parameter Llama-3 model trained on 200 billion tokens of FineWeb-Edu, and a ResNet-50 trained on ImageNet.

LLM Training Stability

In the 200B token run, AdamC demonstrated significantly better stability than AdamW. While AdamW experienced a doubling of the gradient norm and a significant drop in weight norm in the final 25% of training, AdamC maintained nearly flat norms.

Comparison of AdamW and AdamC on a 200B token LLM run. AdamC achieves lower loss and stabilizes both gradient and weight norms.

Crucially, this stability translated into better performance. AdamC achieved a final loss of 2.457, compared to 2.461 for AdamW.

Computer Vision Performance

The benefits extend beyond Transformers. On ImageNet, SGDC (Corrected SGD) achieved a top-1 accuracy of 77.07%, outperforming the standard SGDM baseline of 76.95%. The correction effectively balances the learning rates across different layers of the ResNet architecture.

Conclusion

The "tail blow-up" of gradients is not an inherent property of the loss landscape but a side effect of how we apply weight decay. By correcting the weight decay coefficient to account for the learning rate schedule, we can achieve more stable training runs and better final model performance. This research suggests that weight decay's primary role in modern deep learning is "layer balancing," a function that is disrupted by standard decaying schedules.

Summary updated

Abstract

During long-duration Large Language Model (LLM) training runs the gradient norm increases rapidly near the end of training. In this short note, we show that this increase is due to an unintended interaction between weight decay, normalization layers, and the learning rate schedule. We propose a simple correction that fixes this behavior while also resulting in lower loss values throughout training.
BibTeX
@misc{defazio2025why,
  author = {Aaron Defazio},
  title = {{Why Gradients Rapidly Increase Near the End of Training}},
  year = {2025},
  eprint = {2506.02285},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2506.02285},
}
Figure