Unit 10 of 11 · about 4 hours · measure, implement

Storage saturation, partial writes, slow ranks and last-known-good retention

Checkpoint writes are the heaviest storage burst in the job. Without retention discipline the disk fills, the newest save corrupts, and there is nothing to fall back to.

You'll be able to

  • Detect a saturated filesystem, a partial write and a slow saver from rank-side evidence, and act before the job dies.
  • Implement keep-k retention that never deletes the last known good and garbage-collects in the background.

Covers

Storage saturation, partial writes and slow rank diagnosisRetention, garbage collection and last-known-good protection
1

Read

In this order, only the parts listed

0 of 4 done

  1. Disk watchdogs and the 80 percent ruleMachine Learning Engineering Open Book - Checkpoints, Storage and Fault Tolerance

    Low disk space alerts: 80 percent is full on rebalancing filesystems, inode exhaustion, df staleness, fs-watchdog.py; Dealing with slow memory leaks: voluntary exit with save_checkpoint before OOM

  2. BLOOM retention arithmeticMachine Learning Engineering Open Book - Checkpoints, Storage and Fault Tolerance

    Frequent checkpoint saving: 2.3TB every 3 hours is 18.4TB a day; keep the 2 most recent checkpoints local for fast resume

  3. Keep-k retention in codeTorchFeather - Distributed Checkpoint Manager

    keep_latest_k: rejecting 1, rank-0 _purge_stale_checkpoints with sorted step-* selection, background purge_thread with TerminateSentinel, _save_last_step always synchronous and full

  4. Stragglers and slow ranksMachine Learning Systems Volume II - Chapter 7 Fault Tolerance

    Distinguishing stragglers from failures with Definition 1.2 and the straggler step-time model; Napkin Math 1.5: the straggler tax

2

Focus on

  • Treat 80 percent as full on shared filesystems. Rebalancing can fail a write while df still shows space, and df itself can lag by 30 minutes. Monitor the consumption rate in TB per day, not just the percent.
  • Keep at least two complete checkpoints. The newest may be mid-write when the crash lands, so retention protects the last known good, never just the last.
  • Delete in the background and never on the training thread. Rank-0 selection plus a purge queue keeps rmtree latency off the critical path.
  • A slow saver is a straggler, not yet a failure. Per-rank save timings name it, and past the break-even point killing and recovering beats waiting.
Common mistakes · 3
  • Setting keep_latest_k=1 to save space. TorchFeather rejects it because the single copy can be purged while its replacement is still writing; the minimum safe retention is 2.
  • Purging from every rank. Concurrent deletes race and partially remove directories, so only rank 0 selects and a single background thread deletes.
  • Watching bytes but not inodes. Virtualenvs and sharded checkpoints create many small files, so an inode-full filesystem fails writes with terabytes free.
3

Try it yourself

Closed-book, before checking anything

With keep_latest_k=2, save steps 1 to 4 on CPU, delete .metadata from step 4, and show the loader selects step 3 while the purge set holds only the older steps.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.A filesystem shows 78 percent used and writes start failing. What is the most likely cause, and what threshold would have prevented it?Answer

    Rebalancing or per-device imbalance on a shared filesystem: one device is full while the aggregate shows space. Alert at 80 percent at the latest, and track the daily consumption rate against the job length.

  2. 2.Why must the purge select on rank 0 and delete on a background thread?Answer

    Selection needs one decider to avoid races; deletion is slow I/O that must stay off the training thread. The queue between them bounds both.

  3. 3.Checkpoints land every hour and each takes 6 minutes to write on the slowest rank. When is that rank a straggler to kill rather than wait for?Answer

    Sustained, it holds every step 10 percent longer (). Napkin Math 1.5's rule: replace it once that slowdown share exceeds ; past that break-even point, killing and recovering beats waiting.

  4. 4.df shows free space but a save fails with no space. Name two non-capacity causes from the chapter.Answer

    Inode exhaustion, and stale df on a distributed filesystem that lags reality by up to 30 minutes.

5

Practice

  • Retention plus watchdog lab

    TorchFeather _purge_stale_checkpoints with keep_latest_k=2: save 4 interval checkpoints, corrupt the newest, and show the loader falls back to the previous complete one while the purge removes only older ones; adapt the Stas fs-watchdog.py thresholds to your disk with a consumption-rate estimate

    Run on CPU with small shards; the purge and fallback logic is identical at scale. The Stas watchdog lives at https://github.com/stas00/ml-engineering/blob/139708e52cb06f9191cf1d9959def9187b205c58/training/fault-tolerance/README.md under Low disk space alerts.

You're done when

A corrupted newest checkpoint falls back to the previous complete one, retention holds exactly 2, and your watchdog names the byte rate and the inode headroom.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 10 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.

  • 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 of storage/README.md. Turn them into an operational save, verify, publish, retain and recover runbook.

Also in this section

  • PyTorch Distributed Checkpoint RecipesPyTorch · required

    Complete the distributed checkpoint recipe with a tiny sharded model on CPU, then dcp.async_save from 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.

  • Distributed Training Guide - Sharded Checkpoints, Determinism and Elastic TrainingLambda Labs · required

    Run related-topics/elastic-training/toy.py with 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.

  • 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 in src/nanotron/serialize/. Use it as the worked example of why resharding is hard.

  • 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.

  • TorchTitan - CheckpointingPyTorch · support

    Read docs/checkpoint.md and 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.py and 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, and src/test/train/checkpoint_test.py (run_checkpointer) for the save, find and reload assertions.