Midway through a long training run, the loss suddenly spikes and then partially recovers. How would you diagnose it?
Role: Machine Learning Engineer
Category: Machine Learning
Difficulty: hard
Interview Round: Other
You are training a large neural network with an Adam-style optimizer, and checkpoints are saved regularly. Midway through the long training run, the loss suddenly spikes and then partially recovers. How would you diagnose it?
```hint Pin it to a step
Find the exact step and list everything that changed around it, both in the data and in the training state.
```
```hint Make the replay informative
Replaying from a checkpoint only separates causes if you change one thing at a time. Decide what to vary between replays.
```
```hint Inside the optimizer
Look at how Adam's per-parameter step size behaves when a parameter's gradients have been near zero for a long time and then become large.
```
### Clarifying Questions to Ask
- Is this the first spike in the run, or have there been several?
- Which optimizer settings, learning rate schedule and numeric precision (FP16, BF16) does the run use?
- What is logged per step (batch IDs, per-layer gradient norms, loss scale), and how far back is the nearest checkpoint?
- Did anything else happen near that step, such as a job restart, a config change or a new data shard?
### What a Strong Answer Covers
- Correlating the spike with the data, the schedule, gradient and optimizer statistics, and precision state at that step
- A replay plan from a checkpoint that separates bad data, an interaction between data and optimizer state, and nondeterministic faults
- The mechanisms that commonly cause spikes: stale Adam second moments, attention or output logit growth, FP16 overflow
- Mitigations matched to each cause
- What a partial recovery and repeated spikes say about the health of the run
### Follow-up Questions
- The spike does not reproduce when you replay the same batches from the same checkpoint. What does that suggest?
- Why does lowering Adam's beta2 to 0.95 reduce spikes, and what does it cost?
- How does z-loss work, and why does it help with output logit growth?
- How would you set up monitoring so the next spike is detected and handled without someone watching the run?
Overview: Asks how to diagnose a sudden loss spike that partially recovers in the middle of a long neural network training run. It tests step-level debugging of data, schedule, gradients and precision, a checkpoint replay plan that isolates the cause, Adam and logit-growth instabilities, and matching mitigations.