Topic 42 of 62 · Training at scale
Checkpointing and failures at scale
MediumHow often should a large run checkpoint, what must be saved, and how do you recover from failures and loss spikes?
1 · Start with the intuition
With thousands of GPUs, something fails often, so failures are part of normal operation. Each failure loses the work since the last checkpoint; each checkpoint costs time. The best interval balances the two. A checkpoint is only useful if it restores the exact training state, not just the weights.
2 · How the mechanism works
Mechanism step 1 of 3 · no question to answer
Estimate failure rate
Cluster MTBF ≈ per-node MTBF / number of nodes.
Next, we will look at: Choose an interval. Move on when this operation makes sense.
Visualizing the behavior
Overhead vs checkpoint interval (C = 2 min, MTBF = 480 min)
Derived- C/τ + τ/(2M)
3 · The governing equation
τ_opt ≈ √(2 C M) Overhead ≈ C/τ + τ/(2M) State size ≈ 16 bytes × parameters (mixed-precision Adam)
Notation: C is the blocking time to write a checkpoint, M the mean time between failures of the whole job. The overhead formula counts checkpoint time plus expected lost work (half an interval per failure), ignoring restart time.
Shrinking the blocking cost C is the biggest lever: sharded checkpoints written in parallel by all ranks, and asynchronous checkpointing that copies state to host memory and writes it in the background. Keep several recent checkpoints and validate them, because a corrupted or NaN-containing checkpoint is worse than none. Loss spikes are a separate failure mode: a common recovery, used in PaLM, is to roll back to a checkpoint before the spike and skip the data batches around it.
4 · Put concrete numbers on it
Worked numbers (from stated assumptions)5 · Common misconception to avoid
“Saving the weights is enough to resume.” Without optimizer moments, the scheduler step, RNG and data position, the resumed run follows a different trajectory, repeats or skips data, and often shows a loss jump.
In practice · implementation & engineering rule of thumb
Save sharded distributed checkpoints asynchronously (copying state to pinned CPU RAM first so GPUs resume training immediately while disk/object-store writes finish in the background).
ckpt_state = {
"model": model.state_dict(),
"optimizer": optimizer.state_dict(),
"scheduler": scheduler.state_dict(),
"dataloader": dataloader.state_dict(),
"rng_state": torch.cuda.get_rng_state_all(),
"step": step,
}Go one level deeper
Follow-ups that often come after a correct first answer.
- Elastic and in-memory recovery
- Some systems keep redundant copies of state in peer GPU/CPU memory so a failed node’s shard can be restored without reading from storage, then replace the node or continue with fewer data-parallel replicas. This shortens restart time, which the Young/Daly formula ignores.
- Reshard on load
- Distributed checkpoint formats store tensors with sharding metadata so a run saved with one TP/PP/DP layout can be loaded into another. This matters when failures force a different GPU count.
6 · Self-check & interview synthesis
Explain it in your own words first
Before revealing the reference answer, try answering the opening question aloud in four beats: what it is → how the math works → what trade-off it makes → a concrete number or failure mode.
Follow-up question interviewers often ask next
MediumHow do you detect a silently failing GPU that produces wrong numbers rather than crashing?
Show follow-up reasoning
Monitor per-rank signals such as gradient norms, loss and step time for outliers. Run periodic deterministic health checks, and compare replicated computations across data-parallel ranks. Silent data corruption is rare per device but becomes likely across thousands of GPUs over weeks.