Skip to content

[Train][Docs] Document Ray Train new api for node preemption - #66579

Merged
matthewdeng merged 3 commits into
ray-project:masterfrom
liulehui:preemption-doc
Oct 6, 2026
Merged

matthewdeng merged 3 commits into
ray-project:masterfrom
liulehui:preemption-doc

Conversation

@liulehui

@liulehui liulehui commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

Ray Train added a preemption-handling API (ray.train.get_preemption_info(), PreemptionInfo, PreemptionError, and the FailureConfig options max_preemption_failures, relax_collectives_on_preemption, and preemption_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:

  • How Ray Train handles a preemption: detection through Ray Core draining nodes (including TPU slice fate-sharing), the PreemptionInfo every rank receives, the drain window (120s fallback when there's no deadline), and the restart. The restart counts against max_preemption_failures, which is separate from max_failures.
  • Save a just-in-time checkpoint: a runnable TorchTrainer example with the preemption-specific lines highlighted. It comes with the usage rules: call get_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't return after saving, because a clean return finishes the run.
  • Finish slow checkpoints without the preempted workers: when to use relax_collectives_on_preemption and preemption_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.
  • Make preemptions visible to Ray: Briefly introduce how to integrates with Ray core draining code api

Related issues

  1. [train][Preemption handling 1/n] Add preemption watcher for node-drain observability #63807, [train][Preemption handling 2/n] Fan out preemption signal to workers #64099, [train][Preemption handling 3/n] Add public preemption API and controller PreemptingState #64360, [Train] Relax Ray Train collectives on preemption #66225
  2. [RFC][Train] Preemption-aware lifecycle for Ray Train #63968

Additional information

Test locally with make local, see screenshot below:
image
image
image
image
image

@liulehui
liulehui requested review from a team as code owners September 29, 2026 17:49
@liulehui liulehui added the go add ONLY when ready to merge, run all tests label Sep 29, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ray-gardener ray-gardener Bot added docs An issue or change related to documentation train Ray Train Related Issue labels Sep 29, 2026

@JasonLi1909 JasonLi1909 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks!

dstrodtman added a commit that referenced this pull request Oct 2, 2026
## 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]>

@dstrodtman dstrodtman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…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]>
@matthewdeng
matthewdeng merged commit 0ffa92d into ray-project:master Oct 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs An issue or change related to documentation go add ONLY when ready to merge, run all tests train Ray Train Related Issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants