Repository navigation
[Train][Docs] Document Ray Train new api for node preemption - #66579
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces documentation and code examples for just-in-time checkpointing on node preemption in Ray Train. It details how to use ray.train.get_preemption_info() to save checkpoints before a node is preempted and how to configure FailureConfig to handle slow checkpoint uploads. The review feedback suggests two improvements to the code examples: first, optimizing save_checkpoint by restricting the creation of the temporary directory to rank 0; second, specifying map_location="cpu" in torch.load to avoid potential out-of-memory errors or incorrect device placement during distributed loading.
JasonLi1909
left a comment
There was a problem hiding this comment.
This is great, thanks!
## Why are these changes needed?
Converts the 40 remaining non-API `.rst` pages under `doc/source/train/`
to MyST Markdown. Format only: the rendered HTML should match
`/en/master`. `train/api/` stays RST, following the other libraries'
API-reference trees.
The PR has two commits:
1. **Conversion.** Prose line wrapping is kept as in the `.rst`, so you
can review it line by line against the source.
2. **Soft-wrap.** A whitespace-only reflow to one line per paragraph.
`ray-soft-wrap`'s `verify.py` confirms non-whitespace bytes and rendered
HTML are unchanged.
### Notable conversions
- The `train/common/` fragments convert in lockstep with the three
`getting-started-*` pages that include them. They now use MyST
`{include}`, with their headings at H2 to match the includers.
- `benchmarks`: RST named hyperlink targets are inlined as Markdown
links.
- RST `#.` auto-numbered lists become `1.` lists in `overview`,
`dreambooth_finetuning`, and `experiment-tracking`.
### Doctest coverage
`pytest-sphinx` builds identical examples from every converted page and
the `.rst` it replaced, with one exception:
- `user-guides/experiment-tracking`: 1 → 0. On master the plugin
collects a `.. testcode::` that sits inside an RST comment. The block
renders nothing and only defines `train_func` without calling it, so no
real coverage is lost.
### Explained render differences
- `examples/pytorch/dreambooth_finetuning`: `/en/master` renders a stray
trailing backtick inside three code spans. The `.md` reproduces it,
using double-backtick spans.
- `getting-started-xgboost`: a `.. testcode::` with no blank line before
its body makes docutils drop that block on `/en/master`. The `.md`
renders it.
### Render diff
Against `/en/master`, 31 of 40 pages render identically. The other 9
differ only in these ways:
- **RST comments become HTML comments**, invisible to readers. This
covers 7 pages: `hyperparameter-optimization-deprecated`,
`getting-started-jax`, `getting-started-pytorch`,
`getting-started-pytorch-lightning`, `getting-started-transformers`,
`experiment-tracking`, and `reproducibility`.
- **`getting-started-xgboost`:** the `testcode` block that `/en/master`
drops now renders, as noted above.
- **`user-guides/checkpoints`:** one apostrophe after an inline literal
(`report`'s) now renders as a curly quote. On `/en/master`, docutils'
smartquotes left it straight.
The diff also caught a `<REGION>` placeholder in `aws-trainium/llama3`
that Markdown read as an HTML tag. It's escaped in 9fe8671, and the
page now renders identically.
### Open PRs that edit these pages
#66579 edits a Train `.rst` page and will need to move its change onto
the `.md`.
## Related issue number
## Checks
- [x] I've signed off every commit (DCO).
- [x] RtD preview green under `fail_on_warning`.
- [x] Render diff against `/en/master` reviewed.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lehui Liu <[email protected]>
Signed-off-by: Lehui Liu <[email protected]>
a6b6092 to
7b2e5a9
Compare
dstrodtman
left a comment
There was a problem hiding this comment.
Docs-side style review from Douglas Strodtman (Ray docs team), drafted with Claude Code. I read and stand behind every comment below.
Scope is style, grammar, and Ray's writing style guide only. Technical accuracy stays with the Ray Train maintainers, and @JasonLi1909's approval covers that side.
This section is in good shape. It's clear, uses sentence-case headings and labeled cross-references, and the emphasize-lines ranges line up with the example code. The suggestions below are small and optional. The docs side has no objection to this merging.
One note outside the diff, so there's no suggestion for it: the page's H1, Handling Failures and Node Preemption, is title case. The style guide calls for sentence case and an imperative for task headings, such as Handle failures and node preemption. Fine to leave for a follow-up.
Signed-off-by: Lehui Liu <[email protected]>
…ect#66668) ## Why are these changes needed? Converts the 40 remaining non-API `.rst` pages under `doc/source/train/` to MyST Markdown. Format only: the rendered HTML should match `/en/master`. `train/api/` stays RST, following the other libraries' API-reference trees. The PR has two commits: 1. **Conversion.** Prose line wrapping is kept as in the `.rst`, so you can review it line by line against the source. 2. **Soft-wrap.** A whitespace-only reflow to one line per paragraph. `ray-soft-wrap`'s `verify.py` confirms non-whitespace bytes and rendered HTML are unchanged. ### Notable conversions - The `train/common/` fragments convert in lockstep with the three `getting-started-*` pages that include them. They now use MyST `{include}`, with their headings at H2 to match the includers. - `benchmarks`: RST named hyperlink targets are inlined as Markdown links. - RST `#.` auto-numbered lists become `1.` lists in `overview`, `dreambooth_finetuning`, and `experiment-tracking`. ### Doctest coverage `pytest-sphinx` builds identical examples from every converted page and the `.rst` it replaced, with one exception: - `user-guides/experiment-tracking`: 1 → 0. On master the plugin collects a `.. testcode::` that sits inside an RST comment. The block renders nothing and only defines `train_func` without calling it, so no real coverage is lost. ### Explained render differences - `examples/pytorch/dreambooth_finetuning`: `/en/master` renders a stray trailing backtick inside three code spans. The `.md` reproduces it, using double-backtick spans. - `getting-started-xgboost`: a `.. testcode::` with no blank line before its body makes docutils drop that block on `/en/master`. The `.md` renders it. ### Render diff Against `/en/master`, 31 of 40 pages render identically. The other 9 differ only in these ways: - **RST comments become HTML comments**, invisible to readers. This covers 7 pages: `hyperparameter-optimization-deprecated`, `getting-started-jax`, `getting-started-pytorch`, `getting-started-pytorch-lightning`, `getting-started-transformers`, `experiment-tracking`, and `reproducibility`. - **`getting-started-xgboost`:** the `testcode` block that `/en/master` drops now renders, as noted above. - **`user-guides/checkpoints`:** one apostrophe after an inline literal (`report`'s) now renders as a curly quote. On `/en/master`, docutils' smartquotes left it straight. The diff also caught a `<REGION>` placeholder in `aws-trainium/llama3` that Markdown read as an HTML tag. It's escaped in 9fe8671, and the page now renders identically. ### Open PRs that edit these pages ray-project#66579 edits a Train `.rst` page and will need to move its change onto the `.md`. ## Related issue number ## Checks - [x] I've signed off every commit (DCO). - [x] RtD preview green under `fail_on_warning`. - [x] Render diff against `/en/master` reviewed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Description
Ray Train added a preemption-handling API (
ray.train.get_preemption_info(),PreemptionInfo,PreemptionError, and theFailureConfigoptionsmax_preemption_failures,relax_collectives_on_preemption, andpreemption_grace_s). None of it has a user guide. This PR adds a "Just-in-time checkpointing on node preemption" section to the Train fault tolerance guide (train/user-guides/fault-tolerance.rst). The section covers:PreemptionInfoevery rank receives, the drain window (120s fallback when there's no deadline), and the restart. The restart counts againstmax_preemption_failures, which is separate frommax_failures.TorchTrainerexample with the preemption-specific lines highlighted. It comes with the usage rules: callget_preemption_info()the same number of times on every rank because it's a barrier, save once, fit the upload in the drain window, and don'treturnafter saving, because a clean return finishes the run.relax_collectives_on_preemptionandpreemption_grace_s. A warning lists the limits: rank 0 must survive, sharded checkpoints (FSDP or ZeRO) can be committed without the preempted ranks' shards, and collectives in user code aren't relaxed.Related issues
Additional information
Test locally with





make local, see screenshot below: