Foundations to Frontier
Tests
C. Programming, Tools and HPC › C6 Distributed Training

Fault Tolerance and Checkpointing at Scale

Large training jobs run for weeks on thousands of GPUs, and something fails every few hours: a GPU, a node, a network link, a storage hiccup, or the job's own walltime limit. Progress survives only through checkpoints, and resuming must reproduce the training exactly. This topic covers what a complete checkpoint contains (weights, optimizer state, learning-rate schedule, RNG states, data-loader position), atomic writes and integrity checks, sharded and asynchronous checkpointing, choosing the checkpoint interval (Young's and Daly's formulas), elastic training with torchrun, and detecting silent failures such as hangs and loss spikes. In the exercises you build an atomic, checksummed checkpoint of the full training state that resumes bit for bit after a crash and survives corruption; then you verify Young's optimal interval by Monte Carlo and measure how efficiency falls as clusters grow, and how much cheaper checkpoints recover.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Saving the game

Long video games let you save, so a power cut doesn’t send you back to the start. Training a big model is a weeks-long game played on thousands of computers, and with that many machines something breaks every few hours. Saving takes time, so you can’t save every minute, but saving too rarely means replaying hours after each crash. There is a best saving rhythm, and it depends on how often things break.

How often to checkpoint?
Young τ* = 2.9 hcheckpoint interval (log scale, τ*/16 … 16τ*) · y: expected fraction of time wasted
system MTBF 42.8 h · expected waste at this τ 7.0% (minimum 7.0%)
one simulated 48-hour job: finished after 49.6 h
blue: useful work · purple: writing checkpoints · orange: work lost to a failure · grey: restarting
A thousand-fold larger cluster fails a thousand times more often, so large jobs need frequent, cheap checkpoints: asynchronous saving (copy to host memory, write in the background), sharded checkpoints written in parallel by every rank, and in-memory replicas on neighbouring nodes.
Why engineers care

Spacecraft software is built around fault tolerance: watchdogs, safe modes, state saved to non-volatile memory, restartable procedures. Long training and simulation campaigns on supercomputers need the same discipline: a job that cannot resume exactly wastes allocation and makes results irreproducible.

📝 Quick check (Level 0)
0/3 answered
  1. 1. A checkpoint is…
  2. 2. Why not save every minute?
  3. 3. In the demo, what happens to the best interval as the cluster grows?

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

What a checkpoint must contain

  • Model weights (and EMA weights if used).
  • Optimizer state: Adam’s moments and step count; mixed-precision master weights and the loss scaler.
  • Schedules: learning-rate scheduler and step counters.
  • Randomness: RNG states of Python, NumPy, PyTorch CPU and every GPU (dropout, augmentation).
  • Data position: epoch, sampler seed and index (or the dataset iterator’s state), so no data is skipped or repeated.
  • Metadata: config, code version (git hash), library versions (C2.4).
torch.save({"model": model.state_dict(), "opt": opt.state_dict(), "sched": sched.state_dict(),
            "scaler": scaler.state_dict(), "step": step, "rng": {"torch": torch.get_rng_state(),
            "cuda": torch.cuda.get_rng_state_all(), "numpy": np.random.get_state()},
            "sampler": {"epoch": epoch, "index": i}}, tmp_path)
os.replace(tmp_path, final_path)     # atomic: readers see the old or the new checkpoint, never a partial one
📝 Quick check (Level 1)
0/3 answered
  1. 1. Resuming with only the model weights (no optimizer state) causes…
  2. 2. Why write to a temporary file and rename it?
  3. 3. Which state lets the data loader continue without repeating samples?

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 35 minUndergraduate students and practising engineers.

Checkpointing at scale

A 70B-parameter model’s training state is about 1 TB; writing it from one process to a parallel file system takes minutes. Practical systems:

  • Sharded checkpoints: every rank writes its own shard in parallel (PyTorch Distributed Checkpoint, DeepSpeed), which also allows resuming on a different number of GPUs by resharding.
  • Asynchronous checkpoints: copy state to host memory (seconds), then write to storage in the background while training continues.
  • Tiers: frequent in-memory or node-local copies, less frequent copies to the parallel file system, occasional ones to object storage.
  • Integrity: checksums, keep the last few, validate on load, and test restoring regularly.
🐍 Exercise 1: an exact, atomic, verified checkpoint
Serialize the full training state (weights, Adam moments and step, RNG bit-generator state, epoch, permutation and position) with a SHA-256 checksum; save atomically via a temporary name and rename, keeping the last three; load the newest valid checkpoint, skipping corrupted and half-written files; show that a crash and resume reproduces the uninterrupted run bit for bit, and that forgetting the RNG state does not.
📝 Quick check (Level 2)
0/3 answered
  1. 1. A checkpoint fails its checksum on load. The loader should…
  2. 2. Sharded checkpoints are written…
  3. 3. Asynchronous checkpointing hides…

Level 3: Advanced

★★★★☆ Advanced⏱ 30 minGraduate level, with full derivations and proofs.

How often?

With failures arriving at rate 1/M (for N nodes with independent failures, M = node MTBF / N), checkpoint cost C and interval τ, the expected waste is about C/τ (time spent saving) + (τ + C)/(2M) (half an interval of lost work per failure). Minimizing gives Young’s interval τ* = √(2CM); Daly’s refinement adds higher-order terms for larger C/M. A 5-year node MTBF means a 1024-node system fails every 43 hours and a 16 384-node system every 2.7 hours: at that scale, checkpoint cost must fall (asynchronous, in-memory) or efficiency collapses.

Beyond checkpoints

  • Elastic training (torchrun --nnodes=min:max --max-restarts=k) restarts workers and re-forms the process group when nodes fail or join.
  • Detecting silent failures: NCCL timeouts and watchdogs for hangs, health checks for GPUs (ECC errors, throttling), and monitoring for loss spikes or NaNs (roll back to an earlier checkpoint, skip the offending batch).
  • Walltime limits on clusters (C5.9) are failures you know in advance: catch the termination signal and checkpoint before exiting.
📝 Quick check (Level 3)
0/3 answered
  1. 1. Young's interval for C = 0.1 h and M = 42.8 h?
  2. 2. Doubling the number of nodes changes the optimal interval by…
  3. 3. A job receives SIGTERM before its walltime ends. Best response?

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

Fault tolerance, measured

Exercise 1. A run that checkpoints every 10 steps and “crashes” at step 43 restores step 40 and finishes at step 57 with weights bit-for-bit identical to an uninterrupted run (optimizer moments, RNG state and data position all restored). Only the last three checkpoints are kept; a checkpoint with one flipped byte fails its SHA-256 and the loader falls back to the previous one; a half-written temporary file is ignored. Resuming with a fresh RNG instead of the saved one gives different weights.

Exercise 2: Young’s interval and cluster size. A 240-hour job, checkpoints costing 6 minutes, restarts 12 minutes, node MTBF 5 years, failures possible at any time (including during checkpoints and restarts), 400 simulated runs per setting:

Nodes system MTBF Young’s τ* simulated time at τ*/4, τ*/2, τ*, 2τ*, 4τ* efficiency at τ*
64 685 h 11.7 h 248.8, 245.2, 244.1, 245.0, 248.4 h 98%
1024 42.8 h 2.93 h 276.7, 262.2, 258.1, 262.4, 278.5 h 93%
16 384 2.7 h 0.73 h 422.1, 359.8, 344.6, 375.6, 496.6 h 70%

Young’s interval is the best of the tested multiples in every case, and the first-order waste formula predicts the simulated waste within a percentage point (1.7%, 7.0%, 29%). Daly’s estimate is within 10% of Young’s here. At 16 384 nodes, making checkpoints 10 times cheaper (asynchronous or in-memory) raises efficiency from 70% to 85%.

🐍 Exercise 2 (research): checkpoint interval and cluster size
Implement Young's and Daly's optimal intervals and a Monte Carlo simulation of a long job with exponential failures during work, checkpoints and restarts; for 64, 1024 and 16 384 nodes compare the simulated completion time for multiples of Young's interval, compare the simulated waste with the first-order formula, and measure the gain from 10× cheaper checkpoints.

Fault tolerance in AI, robotics and aerospace

  • Large-model training: published runs report hundreds of interruptions over a few months; automatic restart from sharded, asynchronous checkpoints is standard.
  • Simulation campaigns on supercomputers checkpoint solver state for restarts across allocations.
  • Flight software: state checkpoints in non-volatile memory, triple modular redundancy and watchdog resets for radiation-induced faults.
  • Robots: persisting maps and localization state so a reboot resumes a mission.

References

  1. J. W. Young (1974). “A first order approximation to the optimum checkpoint interval.” Communications of the ACM, 17(9).
  2. J. T. Daly (2006). “A higher order estimate of the optimum checkpoint interval for restart dumps.” Future Generation Computer Systems, 22(3).
  3. A. Grattafiori et al. (2024). “The Llama 3 herd of models.” arXiv:2407.21783 (interruptions during large-scale training).
  4. PyTorch documentation (pytorch.org/docs): Distributed Checkpoint, torchrun (elastic launch).
  5. F. Cappello et al. (2014). “Toward exascale resilience: 2014 update.” Supercomputing Frontiers and Innovations, 1(1).