Crash-consistency testing for ML training checkpoints: kill a save at every file boundary, resume, classify the outcome.
ckpt-chaos kills a training job at every file boundary of a checkpoint save, resumes it, and tells you what came back: a clean resume, a crash that needs manual cleanup, a silent resume with different weights, or lost work. It works on your own unmodified training script (any framework, or none), needs only the Python standard library for that, and exits non-zero on a failure so it can gate CI.
Most training stacks treat "checkpoint-N/ exists" as "checkpoint N is complete". A kill in the middle of a save leaves a folder that looks valid and is not.
It builds on the single-node, single-filesystem study Crash-Consistent Checkpointing for AI Training on macOS/APFS, whose stated limits (one filesystem, one node, a synthetic workload) are this tool's starting points.
pip install ckpt-chaos # put {out} where your command takes its output / checkpoint directory ckpt-chaos run --step-regex "resumed from step (\d+)" --result-file "{out}/final.pt" \ -- python train.py --output_dir {out} It runs your command once fault-free to record every file it creates, renames or removes under {out}, then kills a fresh copy at each of those events (and, for files written by torch.save, safetensors or Python's open(), a second copy with the file cut in half). Each time it runs your resume command (--resume-cmd, default: the same command) and compares what came back with the fault-free run. It only ever writes inside {out} directories it creates itself, and exits 1 on HARD_FAIL, SILENT_DIVERGENCE or a failing control (--fail-on changes that).
Two ordinary scripts are included, with no changes to either:
Options worth knowing: --result-cmd (compare with a tolerance), --max-points (sample long runs), --jobs (keep 1 on a shared GPU), --timeout. If two fault-free runs of your command already differ (unseeded training), the report says so, because divergence verdicts mean nothing then. run mode cannot tell which checkpoints were complete, so it does not report LOST_WORK or the "newest ok" column.
ckpt-chaos bench hf_trainer # HF Trainer, single process (needs torch, transformers, accelerate) ckpt-chaos bench hf_trainer --ranks 2 # two gloo ranks ckpt-chaos bench lightning_trainer --ranks 2 # needs lightning ckpt-chaos bench loop_ddp --ranks 2 --strategy tmp_rename --flake 25 # repeat the fault-free job, count failures ckpt-chaos judge runs/ # re-apply the verdict rules to a finished run Tests: python -m unittest discover tests.
Setup: transformers 5.18.0 (tiny GPT-2, resume_from_checkpoint=True) and Lightning 2.6.6 (tiny MLP, fit(ckpt_path="last")), torch 2.14.1 (CPU), Windows/NTFS. The job is killed while the step-10 checkpoint is being saved (the step-5 checkpoint already exists).
Each run is one crash point; the control run has no crash and a clean one counts as a PASS.
loop_ddp is a small hand-written DDP loop with three ways of installing a checkpoint, run with 2 gloo ranks. It shows the harness can say PASS, and that it can find a protocol that is broken only sometimes.
pip install torch transformers accelerate ckpt-chaos bench hf_trainer # 1 process: 17 HARD_FAIL, 1 PASS (plus a passing control) ckpt-chaos bench hf_trainer --ranks 2 # 2 ranks: 19 HARD_FAIL, 2 SILENT_DIVERGENCE # the same, but get_last_checkpoint skips a folder whose trainer_state.json is missing or unparseable: CKPT_CHAOS_PATCH=skip_incomplete ckpt-chaos bench hf_trainer # 1 process: 19 of 19 PASS CKPT_CHAOS_PATCH=skip_incomplete ckpt-chaos bench hf_trainer --ranks 2 # 19 PASS, 2 SILENT_DIVERGENCE, 1 HARD_FAIL To test any other change to a library without touching the installed copy, copy its package to a folder, edit the copy, and run with CKPT_CHAOS_PREPEND_PYTHONPATH= . That is how the open pull request #39599 (continue resuming when trainer_state.json is missing) was tested: the same single-process matrix gave 9 HARD_FAIL, 8 SILENT_DIVERGENCE and 2 PASS, because the resumed run restarts at step 0 on the weights of the incomplete folder.
ckpt-chaos roundtrip --dir DIR --n 200 --writer torch|lightning saves a checkpoint, loads it straight back, and repeats, for reports like Lightning #21431 (a save that is sometimes unreadable right after writing, in Docker on Windows/WSL). With the included Dockerfile on Docker Desktop for Windows, 8 MB checkpoints, one file overwritten each time:
The Windows host itself (NTFS) gave 0 of 100 (torch) and 0 of 40 (Lightning). #21431 did not reproduce. The reporter's model size, versions and hardware differ from mine, so this does not show the report is wrong; it shows these four setups do not trigger it.
See ROADMAP.md: the features ranked by the evidence behind them (what developers actually report in GitHub issues and papers), what is done, and what is not verified.
checkpoint pytorch fault-tolerance chaos-engineering reproducibility testing mlops
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.




