Unit 9 of 11 · about 5 hours · explain, implement
Rank crashes, collective timeouts, elastic restart and replica recovery
One dead rank invalidates the whole communicator. The choice is restart-from-checkpoint, which works everywhere, versus heal-in-place, which needs replicas.
You'll be able to
- Explain what a rank crash does to a collective, how teardown plus rendezvous rebuilds membership, and what unstable ranks imply for state.
- Restart a crashed CPU job with
torchrun --max-restartsand resume from the last checkpoint; contrast with per-step healing.
Covers
Read
In this order, only the parts listed
0 of 4 done
- Restart and membership vocabularyPyTorch Elastic Run Documentation
Fault tolerant (fixed sized number of workers, no elasticity, tolerates 3 failures) with
--max-restarts=3; Elastic (min=1,max=4) with--nnodes=1:4; Note on rendezvous backend (rdzv-id,rdzv-backendc10d, endpoint default 29400); Definitions (Node, Worker, WorkerGroup,RANK,WORLD_SIZE); Environment Variables (TORCHELASTIC_RESTART_COUNT,TORCHELASTIC_MAX_RESTARTS) - Crash-and-restart behaviorDistributed Training Guide - Sharded Checkpoints, Determinism and Elastic Training
README Elastic Training: all workers restart on one failure and ranks are unstable across restarts, with one crashing attempt's
error.json;toy.py: barrier-separated steps with a rank-0 state write and a random crash - Per-step healing as the contrasttorchft
Overview: per-step fault tolerance without interrupting the job; Lighthouse:
torchft_lighthousequorum with step-granularity membership; Example Training Loop (DDP) withManager,ProcessGroupGlooandTORCHFT_LIGHTHOUSE; Fault Tolerant HSDP Algorithm (page read 2026-10-14) - Detection, teardown and warm versus coldMachine Learning Systems Volume II - Chapter 7 Fault Tolerance
Failure Detection and Recovery: heartbeat versus collective-timeout versus orchestration layers, Figure 28's detect, pause, rescale and resume sequence with the equation 9 recovery budget, cold versus warm restart with Table 9; Checkpoint 1.5: Tuning detection and recovery
Focus on
- A crashed rank turns every pending collective into a hang or an error. Survivors must tear down the process group and re-rendezvous; no rank is removed in place from a live communicator. PyTorch 2.14.1 also ships an experimental, private reconfigure path behind
init_process_group(..., enable_reconfigure=True); this section does not rely on it. - Elastic restart rebuilds the group of workers, not the failed rank.
RANKandWORLD_SIZEcan change, so resume keys state by global step, never by rank. --max-restartsbounds crash loops. Each attempt re-runs the script, which reloads the last checkpoint itself, and exceeding the budget surfaces the failure instead of spinning forever.- torchft heals inside the job when replicas exist (lighthouse quorum per step, live peer transfer). Restart-from-checkpoint works with no replicas but loses work back to the last save. Replicas are the precondition, not the default.
Common mistakes · 3
- Catching the exception and continuing in the same process group. Timeouts and dead peers leave the communicator unusable; teardown plus fresh rendezvous is the only path.
- Assuming
RANKis stable across a restart. The guide states it explicitly: re-derive sharding and logging identity from the new membership. - Treating torchft as a checkpoint replacement for all jobs. Without at least two replicas there is no healthy peer to heal from; single-replica jobs still need file checkpoints.
Try it yourself
Closed-book, before checking anything
torchrun --max-restarts=1. Show TORCHELASTIC_RESTART_COUNT reads 0 then 1 and the final exit code is 0.Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.Rank 2 dies mid-
all_reduce. Why must the surviving ranks tear down instead of continuing?AnswerThe collective never completes, so every survivor hangs waiting for rank 2's contribution. The communicator is defined over the full group, so a membership change needs a new group.
2.A job with
--max-restarts=3fails four times. How many training attempts ran, and what ends the loop?AnswerFour: the initial attempt plus three restarts. The fourth failure exceeds the budget, so the agent surfaces the error instead of restarting.
3.After an elastic restart with fewer workers, each rank reloads its old rank's data shard. What breaks?Answer
Coverage: shards were computed for the old world size. Reshard the dataset for the new membership and resume from the global step.
4.When does per-step healing beat restart-from-checkpoint, and what does it cost standing by?Answer
When replicas exist and failures are frequent: it loses at most a step instead of all work since the last save. It costs per-step lighthouse coordination plus peer capacity to heal onto.
Practice
- torchrun bounded-restart test plus crash loop
Run the Reproduce script under
--max-restarts=1and assert the retry runs withTORCHELASTIC_RESTART_COUNT=1and the job exits 0; then run the guide'stoy.pywith two CPU processes and inspect one crashing attempt'serror.jsonBoth run on CPU gloo.
toy.pycrashes on its own within seconds; deletetoy-state.jsonbefore each fresh run and wrap it intimeout.
You're done when
You can crash any rank of a CPU job, watch the agent restart within budget, resume from the checkpoint, and state when healing needs replicas.
Only when you can do this without notes.
Leads to
Notes
Resources · 4 for this unit, 9 more in the section
- Machine Learning Systems Volume II - Chapter 7 Fault ToleranceML Systems Textbook · primary
Read Failure Analysis at Scale, Hardware Fault Taxonomy, Check-and-Verify, Fault Injection Tools and Frameworks, Checkpointing, Failure Detection and Recovery, Elastic Recovery and Distributed Debugging and Observability. Turn them into a failure matrix before implementing the PyTorch DCP lab.
- Distributed Training Guide - Sharded Checkpoints, Determinism and Elastic TrainingLambda Labs · required
Run
related-topics/elastic-training/toy.pywith two CPU processes (hide any GPU so it uses Gloo) to see a crash-and-restart loop, then read the determinism related topic and the Chapter 4 sharded save and load. Prove the same next batches and updates after one interrupted run. - PyTorch Elastic Run DocumentationPyTorch · support
Use failure modes and membership changes to understand agent, worker group, rendezvous and restart semantics. Implement only bounded local restart tests; elasticity is not a substitute for checkpoint correctness.
- torchftPyTorch · support
Read the README and
train_ddp.py: per-step quorum through the lighthouse, fault-tolerant DDP and HSDP, and live peer recovery. Compare per-step healing with restart-from-checkpoint.
Also in this section
- PyTorch Distributed Checkpoint RecipesPyTorch · required
Complete the distributed checkpoint recipe with a tiny sharded model on CPU, then
dcp.async_savefrom the 2.14 reference at https://docs.pytorch.org/docs/2.14/distributed.checkpoint.html. The recipe saves model and optimizer only: add scheduler, scaler, RNG and dataloader state yourself, then inject partial directories, missing shards and a changed world-size restore. - TorchFeather - Distributed Checkpoint ManagerTorchFeather · required
Trace components/checkpoint.py through state wrappers, DCP save and load, asynchronous mode, retention and cleanup. Write a failure table for every barrier, future, temporary artifact and deletion boundary.
- Machine Learning Engineering Open Book - Checkpoints, Storage and Fault ToleranceStas Bekman · required
Read
training/fault-tolerance/README.md(frequent checkpoints, kill and save switches, watchdogs, preemption) and the "Don't forget the checksums" and benchmark sections ofstorage/README.md. Turn them into an operational save, verify, publish, retain and recover runbook. - Picotron - Checkpoint StateHugging Face · support
Inspect picotron/checkpoint.py and every call site in train.py. List which state is saved, how ranks participate and which DT-1 reproducibility requirements need to be added in your project.
- Nanotron - Distributed SerializationHugging Face · support
Read the serialization section of
docs/docs.md(metadata, per-rank optimizer and RNG shards) and its statement that checkpoints are not topology agnostic, then the reasons insrc/nanotron/serialize/. Use it as the worked example of why resharding is hard. - TorchTitan - CheckpointingPyTorch · support
Read
docs/checkpoint.mdand the checkpointer component at a pinned commit: intervals, model-only and export saves, asynchronous modes and keys excluded from loading. - The Llama 3 Herd of Models - Reliability and Operational ChallengesLlama Team, Meta (2024) · support
Read the reliability section and its interruption table (root causes of unexpected interruptions over a 54-day snapshot) and use it to set failure rates in your checkpoint-interval model.
- Bumblebee - DCP and Checkpoint Smoke TestsBumblebee · depth
Only as a possible capstone target: read
primitive/ckpt/dcp.pyand the checkpoint smoke tests in a clean checkout. Its own roadmap lists reshardable optimizer state as a gap. - OLMo-core CheckpointerAi2 · support
Read
src/olmo_core/train/checkpoint.py(_temporary_wd,_get_tmp_dir,_teardown_tmp_dir,_save_metadata) for temp-directory atomic publish with barrier discipline, andsrc/test/train/checkpoint_test.py(run_checkpointer) for the save, find and reload assertions.