Training Stability › Understanding Loss Spike Anatomy: A Numerical Walkthrough
Language AI HandbookAll chapters Training Stability › Understanding Loss Spike Anatomy: A Numerical WalkthroughOne section · Sections in this chapter9 / 15 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
To build deeper intuition, it is worth walking through the exact sequence of events that happens at the parameter level during a loss spike. This makes the abstract mechanisms concrete and clarifies why the interventions in this chapter are effective.
The Spike as a Three-Phase Event
A loss spike is not instantaneous; it unfolds over several steps. Understanding each phase clarifies what can be done at each point.
Phase 1: The trigger step. A batch arrives with unusually high loss. This could be an outlier document, a sharp curvature cliff in the landscape, or a sudden change in the effective learning rate. The gradient computed from this batch has a norm that is much larger than the running average, say 50x. The optimizer applies this gradient to all parameters.
Phase 2: Parameter displacement. After the large update, model parameters are in a different region of the loss landscape than they were a step earlier. If the update was large enough, they have moved past a local minimum and are now in a high-loss region. This is when the loss curve shows the spike: the next batch sees a higher loss than before the trigger.
Phase 3: Optimizer state corruption. Even if the parameters are eventually restored (by gradient descent pulling them back toward a good region), the Adam optimizer's second moment estimate has absorbed a large gradient squared value. Because , this inflated estimate decays slowly:
where is the typical second moment value. With and a typical training run, the spike's influence on is not halved until about 693 steps later ( such that ). During those 693 steps, Adam's adaptive step size for the affected parameters is artificially suppressed, because the denominator is larger than it should be. The model is effectively frozen in those parameters while they slowly "forget" the spike.
A Concrete Numerical Example
Let us trace through the numbers for a single parameter to make this vivid. Suppose a parameter has:
- Current value:
- Typical gradient: (normal)
- Adam state before spike: , (so )
- Learning rate: ,
The normal update magnitude is:
That is a small, reasonable update. Now a spike batch arrives with gradient (50x normal). After one Adam step:
The update magnitude at step is:
That is 3.16x larger than the normal update: the momentum-inflated first moment drives a much larger step. Three hundred steps later, the second moment has decayed to approximately:
So even 300 steps after the spike, is still 3x its pre-spike value, and the adaptive step size for this parameter is still suppressed by a factor of . The parameter is learning at 58% of its normal rate for 300+ steps after a single bad gradient. At scale, with thousands of affected parameters, this explains the "loss plateau" that practitioners often observe after a spike even when the loss appears to have recovered.
Gradient clipping prevents all of this from happening. By capping at 1.0 (assuming a clip threshold of 1.0), the spike's contribution to and is:
This is only slightly above normal. The optimizer state remains well-behaved, and training continues smoothly after the clipped step.