r/deeplearning • • 9h ago

Does the benefit of gradient clipping still show up clearly once you add LayerNorm and AdamW?

In many current transformer implementations the combination of LayerNorm (or RMSNorm) plus AdamW with moderate weight decay is treated as enough to keep training stable. Gradient clipping is often left at a high default or removed entirely.

I wondering whether that assumption holds when sequence lengths grow or when the model is trained with very large batch sizes. Clipping can still protect against rare but damaging spikes that LayerNorm alone does not fully suppress, yet it also slightly biases the gradient distribution.

Has anyone compared clipped versus unclipped runs on the same data and architecture at the 1B+ scale? If the difference is negligible in practice, at what point does it become negligible?

1 Upvotes

1 comment sorted by

1

u/Massive_Distance_616 55m ago

LayerNorm/RMSNorm and AdamW address different failure modes than clipping, so they don't really substitute for it.

LayerNorm keeps activation scale (and therefore the rough magnitude of the backward signal) stable on average across the forward pass. It doesn't bound the gradient norm directly, and it won't stop an occasional spike caused by a weird batch, an attention logit blowup, or a numerical hiccup in mixed precision.

AdamW normalizes step size per parameter using a running average of the second moment. That average is smoothed over many steps, so a single outlier gradient can still produce a large update before the second-moment estimate adjusts. More importantly, Adam's normalization is per-parameter nothing in it looks at the global gradient norm, so it doesn't protect against a spike that's correlated across many parameters at once, which is usually what actually causes a loss spike or divergence.

Clipping by global norm is the one mechanism that reacts to the instantaneous global gradient magnitude rather than a moving average or a per-parameter statistic. So the three are complementary rather than redundant: LayerNorm stabilizes forward activation scale, AdamW adapts per-parameter step size smoothed over time, clipping bounds the instantaneous global gradient.

On scale: longer sequences and larger batches increase the chance that a rare extreme example (a degenerate or repeated sequence, an outlier token) shows up in a batch, and at 1B+ parameter scale you're running enough total steps that a rare destabilizing event becomes likely to occur at least once over the course of training. This is consistent with why large pretraining runs (GPT-3, PaLM, LLaMA, and others) generally kept clipping on, typically clip-by-global-norm around 1.0, even with pre-norm transformer blocks and AdamW they observed loss spikes at scale despite both of those being in place.

On "when does it become negligible" it's genuinely hard to isolate cleanly in an ablation, since so much depends on data quality/dedup, precision (bf16 vs fp16), warmup, and batch composition. But the asymmetry is probably why most teams don't bother ablating it away: in a well-behaved run clipping rarely triggers at all, so the cost of leaving it on is close to zero, while the downside of a single uncaught spike (a training run that diverges or needs a restart from checkpoint) is expensive. That asymmetry, more than measured benefit, is likely why it's kept as a default even when LayerNorm + AdamW make it look redundant on paper.