Why Gradients Rapidly Increase Near the End of Training
Long-duration LLM (and ImageNet/ResNet) training runs exhibit an unexplained rapid increase in gradient norm near the end of training. Defazio shows this is a clean three-way interaction between weight decay, normalization layers (LayerNorm/BatchNorm), and the learning-rate schedule: for any layer immediately followed by a normalization, weight decay drives the gradient-to-weight ratio to a steady state , so when on the decay tail, that ratio (and hence the gradient norm) must blow up. The proposed fix — AdamC / SGDC — replaces the weight-decay term with , exactly cancelling the schedule-induced inflation; on 200B-token Llama-3-style 120M pretraining and ResNet-50/ImageNet it removes the late-training gradient blow-up and also lowers loss/improves accuracy.
Key claims
Section titled “Key claims”- For any weight matrix followed by a normalization layer, gradients are orthogonal to weights (a known property of normalized layers), giving an exact closed-form recursion for under SGD with weight decay [§3, Eq. 1].
- Weight decay drives the per-layer gradient-to-weight ratio to a steady state of (SGD) or (AdamW), and empirically all normalized layers in ResNet-50 converge to this ratio early in training and track it for the remainder of the run [§3, Fig. 2].
- Because the steady-state ratio depends on the current , a cosine learning-rate schedule with forces the steady state at the end of training; this exactly matches the observed “tail blow-up” of the gradient norm in both SGD-momentum ResNet runs and AdamW LLM pretraining [§3.1, Fig. 3].
- Weight decay’s role under AdamW is reinterpreted as balancing the per-layer to a uniform value across layers (via a Hölder-inequality upper bound on the AdamW-weighted norm), giving a new explanation for why Adam without decoupled weight decay underperforms AdamW: it lacks this balancing property [§4.1–4.2].
- Decoupled weight decay alone (the AdamW form) is not enough to prevent the tail blow-up; the steady-state ratio still depends on [§5].
- The proposed correction is to replace the weight-decay term with on all normalized layers (called SGDC for SGD, AdamC for AdamW); this exactly cancels the dependence in the steady state, yielding (SGD) or (AdamW) — schedule-independent [§5, Algorithm 1].
- On a 120M Llama-3-style model trained 200B tokens with batch 256k on FineWeb-Edu, AdamC vs. AdamW (each LR-swept on a power-of-2 grid): the loss-curve shape shifts substantially with lower final loss, the gradient-norm increase in the second half of training is largely removed, and weight norms become much more stable [§6, Fig. 4].
- On ResNet-50 / ImageNet with SGD-momentum and cosine LR (5 seeds, swept LR and WD): SGDC eliminates the rapid end-of-training gradient-norm spike, though a slower linear upward trend over training remains unaffected [§6, Fig. 5].
- The training-noise regime matters for whether this is observable: classical MNIST/CIFAR setups (low label noise, multi-epoch, gradients go to zero near a minimum) do not exhibit the tail blow-up; modern single-pass LLM training does. Many optimizer benchmarks are simply too short (10B tokens) to surface this [§2, §6].
Method
Section titled “Method”The analysis is built on a single property of normalized layers — the gradient of a pre-norm linear layer is orthogonal to its weights, so . Plugging this into the SGD-with-weight-decay update gives a clean recursion for the squared weight norm; solving for the fixed point (and dropping a second-order term) yields the steady-state . The same derivation under AdamW — treating the Adam step as multiplication by a diagonal preconditioner and measuring the change in — gives the AdamW steady state , but only because AdamW decouples decay from ; the original Adam (where decay is also normalized by ) breaks the cancellation, which the paper proposes as a fresh explanation for the AdamW>Adam gap.
The correction is a one-line patch: replace in the weight-decay term on every layer followed by a normalization (in Transformers, the paper applies it to every linear layer except the LM head). The factor is purely to keep the magnitude consistent with the uncorrected case. Experiments use the standard cosine-with-warmup schedule and sweep LR/WD on power-of-2 grids for both methods to remove a “you just got lucky with the LR” confound.
Results
Section titled “Results”- 120M Llama-3-style LLM, 200B tokens, FineWeb-Edu, AdamC vs AdamW (independent LR sweeps): noticeably lower loss values throughout training, near-elimination of the end-of-training gradient-norm rise, and substantially more stable weight norms (AdamW’s weight norms decrease rapidly; AdamC’s stay flat) [§6, Fig. 4].
- ResNet-50/ImageNet, 5 seeds, SGDC vs SGDM with cosine LR (independent LR/WD sweeps): tail-end gradient-norm spike eliminated; the slow linear gradient-norm rise across all of training is not removed (the paper notes this as residual and open) [§6, Fig. 5].
- The size of the correction grows with how aggressively the schedule decays : under cosine with min-LR = , the late-training is up to 10× the nominal — i.e. AdamC effectively increases weight-decay strength on the tail rather than letting the gradient norm increase to compensate.
Why it’s interesting
Section titled “Why it’s interesting”This sits directly in the Training stability at scale / Hyperparameter scaling laws arc the wiki has been tracking, but locates the fix in a fourth place — the weight-decay term itself, conditional on the schedule. How to Set the Learning Rate for Large-Scale Pre-training? argues QK-Norm subsumes µP’s role at modern scale; Controlled LLM Training on Spectral Sphere argues the optimizer should retract weights and updates to a spectral sphere; this paper argues a much smaller surgery — multiply by on normalized layers — gives schedule-independent gradient-to-weight ratios and recovers stable weight-norm dynamics with one extra scalar per step. The mechanism (gradient-weight orthogonality on normalized layers ⇒ steady-state ) is also exactly the rotational-equilibrium picture How to Set the Learning Rate for Large-Scale Pre-training? §6.2 uses to justify why module-specific LRs are unnecessary at scale — so AdamC is the natural “fix the residual schedule artifact” companion to that line.
It is also a candidate cause for the slow linear gradient-norm drift mentioned (but unexplained) in several wiki entries on long-horizon training. AdamC handles the schedule-induced spike but leaves that drift untouched, which is a clean open question Defazio himself flags.
See also
Section titled “See also”- Training stability at scale — locates training stability in architecture / optimizer / parametrization; this paper adds the weight-decay × schedule axis
- Hyperparameter scaling laws — Fitting/Transfer/Enforce; AdamC is an orthogonal surgery that doesn’t change the LR recipe but fixes a coupled artifact
- How to Set the Learning Rate for Large-Scale Pre-training? — uses rotational equilibrium to justify a single global LR; AdamC’s derivation uses the same equilibrium picture
- Controlled LLM Training on Spectral Sphere — also bounds activations via constraints on weights; AdamC achieves stable weight norms via the decay term instead
- The Newton-Muon Optimizer — another recent optimizer-side intervention in the Muon family
- Muon is Not That Special: Random or Inverted Spectra Work Just as Well — concurrent ablation of what makes Muon work; relevant to the “is the optimizer choice load-bearing or is the schedule artifact?” question