Skip to content

[train] Turn on Train v2 by default - #57857

Merged
justinvyu merged 2 commits into
ray-project:masterfrom
justinvyu:flipswitchforreal
Oct 17, 2025
Merged

justinvyu merged 2 commits into
ray-project:masterfrom
justinvyu:flipswitchforreal

Conversation

@justinvyu

Copy link
Copy Markdown
Contributor

Description

Release tests, unit tests, doctests, and examples are all migrated to V2, so this PR turns V2 on by default. To run with Train V1 (deprecated), set RAY_TRAIN_V2_ENABLED=0.

Related issues

#49454

Additional information

User guides and API references have already been updated to V2.

Signed-off-by: Justin Yu <[email protected]>
@justinvyu
justinvyu requested a review from a team as a code owner October 17, 2025 20:17
@justinvyu justinvyu added the go add ONLY when ready to merge, run all tests label Oct 17, 2025

@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 correctly enables Ray Train v2 by default by changing the default value for the RAY_TRAIN_V2_ENABLED environment variable. The change is straightforward and aligns with the migration to v2 as described. I have one suggestion to add a docstring to the is_v2_enabled function to improve code clarity and maintainability, making the new default behavior explicit.

@matthewdeng matthewdeng 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.

AMdXhUR

Signed-off-by: Justin Yu <[email protected]>
@justinvyu
justinvyu requested a review from a team as a code owner October 17, 2025 22:16
@justinvyu
justinvyu enabled auto-merge (squash) October 17, 2025 22:20
@justinvyu
justinvyu merged commit 338ae52 into ray-project:master Oct 17, 2025
@justinvyu
justinvyu deleted the flipswitchforreal branch October 17, 2025 23:27
xinyuangui2 pushed a commit to xinyuangui2/ray that referenced this pull request Oct 22, 2025
Release tests, unit tests, doctests, and examples are all migrated to
V2, so this PR turns V2 on by default. To run with Train V1
(deprecated), set `RAY_TRAIN_V2_ENABLED=0`.

---------

Signed-off-by: Justin Yu <[email protected]>
Signed-off-by: xgui <[email protected]>
elliot-barn pushed a commit that referenced this pull request Oct 23, 2025
Release tests, unit tests, doctests, and examples are all migrated to
V2, so this PR turns V2 on by default. To run with Train V1
(deprecated), set `RAY_TRAIN_V2_ENABLED=0`.

---------

Signed-off-by: Justin Yu <[email protected]>
Signed-off-by: elliot-barn <[email protected]>
landscapepainter pushed a commit to landscapepainter/ray that referenced this pull request Nov 17, 2025
Release tests, unit tests, doctests, and examples are all migrated to
V2, so this PR turns V2 on by default. To run with Train V1
(deprecated), set `RAY_TRAIN_V2_ENABLED=0`.

---------

Signed-off-by: Justin Yu <[email protected]>
Future-Outlier pushed a commit to Future-Outlier/ray that referenced this pull request Dec 7, 2025
Release tests, unit tests, doctests, and examples are all migrated to
V2, so this PR turns V2 on by default. To run with Train V1
(deprecated), set `RAY_TRAIN_V2_ENABLED=0`.

---------

Signed-off-by: Justin Yu <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
matthewdeng pushed a commit that referenced this pull request May 7, 2026
…63196)

## Why

The Anyscale docs team is auditing `doc/source/conf.py` against current
Ray state as part of strategy work tracked in
[anyscale/docs#2064](anyscale/docs#2064). One
finding: the last two lines of conf.py force two env vars
unconditionally:

```python
os.environ["RAY_TRAIN_V2_ENABLED"] = "1"
os.environ["RAY_DOC_BUILD"] = "1"
```

`RAY_TRAIN_V2_ENABLED=1` was added when Train v2 was opt-in. Justin Yu's
[#57857](#57857) (Oct 2025) made
Train v2 the default. The conf.py force should now be vestigial.

`RAY_DOC_BUILD=1` is intentional and stays — it switches Ray-internal
code paths during doc generation.

## What this PR does

Drops the `os.environ["RAY_TRAIN_V2_ENABLED"] = "1"` line from
`doc/source/conf.py`.

## How to validate

This is a probe, not a request-for-merge. The validation surfaces are:

1. **RtD PR preview build** — runs against this branch. With
`fail_on_warning: true` set in `.readthedocs.yaml`, any new Sphinx
warning means the line was still load-bearing.
2. **`doc: check API doc consistency`** — premerge step that runs `make
-C doc/ html` internally. Same fail-on-warning gate.
3. **Visual diff of API ref pages** for any class previously rendered
through Train v2 codepaths.

If the build is clean and the API ref renders identically, this line can
be dropped.

## What happens if I'm wrong

If `RAY_TRAIN_V2_ENABLED=1` is still load-bearing, the doc build will
surface the dependency (likely as a missing-reference or autosummary
failure). I revert and document the actual reason it's still needed.

## Status

**Draft.** Posting for visibility and validation, not for merge. Looking
for confirmation from a Ray maintainer (Justin Yu @justinvyu would be
the natural reviewer given Train v2 ownership) that there's no
non-obvious reason to keep this. Happy to close if there is.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Douglas Strodtman <[email protected]>
Lucas61000 pushed a commit to Lucas61000/ray that referenced this pull request May 15, 2026
…ay-project#63196)

## Why

The Anyscale docs team is auditing `doc/source/conf.py` against current
Ray state as part of strategy work tracked in
[anyscale/docs#2064](anyscale/docs#2064). One
finding: the last two lines of conf.py force two env vars
unconditionally:

```python
os.environ["RAY_TRAIN_V2_ENABLED"] = "1"
os.environ["RAY_DOC_BUILD"] = "1"
```

`RAY_TRAIN_V2_ENABLED=1` was added when Train v2 was opt-in. Justin Yu's
[ray-project#57857](ray-project#57857) (Oct 2025) made
Train v2 the default. The conf.py force should now be vestigial.

`RAY_DOC_BUILD=1` is intentional and stays — it switches Ray-internal
code paths during doc generation.

## What this PR does

Drops the `os.environ["RAY_TRAIN_V2_ENABLED"] = "1"` line from
`doc/source/conf.py`.

## How to validate

This is a probe, not a request-for-merge. The validation surfaces are:

1. **RtD PR preview build** — runs against this branch. With
`fail_on_warning: true` set in `.readthedocs.yaml`, any new Sphinx
warning means the line was still load-bearing.
2. **`doc: check API doc consistency`** — premerge step that runs `make
-C doc/ html` internally. Same fail-on-warning gate.
3. **Visual diff of API ref pages** for any class previously rendered
through Train v2 codepaths.

If the build is clean and the API ref renders identically, this line can
be dropped.

## What happens if I'm wrong

If `RAY_TRAIN_V2_ENABLED=1` is still load-bearing, the doc build will
surface the dependency (likely as a missing-reference or autosummary
failure). I revert and document the actual reason it's still needed.

## Status

**Draft.** Posting for visibility and validation, not for merge. Looking
for confirmation from a Ray maintainer (Justin Yu @justinvyu would be
the natural reviewer given Train v2 ownership) that there's no
non-obvious reason to keep this. Happy to close if there is.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Douglas Strodtman <[email protected]>
alexandrplashchinsky pushed a commit to alexandrplashchinsky/ray-alex that referenced this pull request May 29, 2026
…ay-project#63196)

## Why

The Anyscale docs team is auditing `doc/source/conf.py` against current
Ray state as part of strategy work tracked in
[anyscale/docs#2064](anyscale/docs#2064). One
finding: the last two lines of conf.py force two env vars
unconditionally:

```python
os.environ["RAY_TRAIN_V2_ENABLED"] = "1"
os.environ["RAY_DOC_BUILD"] = "1"
```

`RAY_TRAIN_V2_ENABLED=1` was added when Train v2 was opt-in. Justin Yu's
[ray-project#57857](ray-project#57857) (Oct 2025) made
Train v2 the default. The conf.py force should now be vestigial.

`RAY_DOC_BUILD=1` is intentional and stays — it switches Ray-internal
code paths during doc generation.

## What this PR does

Drops the `os.environ["RAY_TRAIN_V2_ENABLED"] = "1"` line from
`doc/source/conf.py`.

## How to validate

This is a probe, not a request-for-merge. The validation surfaces are:

1. **RtD PR preview build** — runs against this branch. With
`fail_on_warning: true` set in `.readthedocs.yaml`, any new Sphinx
warning means the line was still load-bearing.
2. **`doc: check API doc consistency`** — premerge step that runs `make
-C doc/ html` internally. Same fail-on-warning gate.
3. **Visual diff of API ref pages** for any class previously rendered
through Train v2 codepaths.

If the build is clean and the API ref renders identically, this line can
be dropped.

## What happens if I'm wrong

If `RAY_TRAIN_V2_ENABLED=1` is still load-bearing, the doc build will
surface the dependency (likely as a missing-reference or autosummary
failure). I revert and document the actual reason it's still needed.

## Status

**Draft.** Posting for visibility and validation, not for merge. Looking
for confirmation from a Ray maintainer (Justin Yu @justinvyu would be
the natural reviewer given Train v2 ownership) that there's no
non-obvious reason to keep this. Happy to close if there is.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Douglas Strodtman <[email protected]>
Signed-off-by: Alexandr Plashchinsky <[email protected]>
dstrodtman added a commit that referenced this pull request Oct 13, 2026
…#66895)

## Why are these changes needed?

The Ray Train style-pass PRs, #66886, #66887, and #66888, flagged
pre-existing claims that looked inconsistent with the source and kept
them as written. This PR corrects the ones that current source settles.
Each claim was already in the docs before the style pass, so none of
them is drift that the style pass introduced.

It's stacked on #66894, the mechanical fixes for the same pages, which
builds on the three style PRs. The diff against #66894's branch is one
commit, `6c6db91`.

**For Ray Train reviewers:** these corrections change what the docs say,
so please confirm them. Each item cites the source it rests on. Items
marked **confirm** carry a specific point to check.

### Getting-started guides

- `getting-started-jax.md`: "By default, this configuration requests one
GPU per worker." `use_gpu` defaults to `False`
(`python/ray/train/v2/api/config.py`). One GPU per worker is what
`use_gpu=True` gives you when `resources_per_worker` isn't set
(`_resources_per_worker_not_none` in `python/ray/air/config.py`).
- `getting-started-transformers.md`: `prepare_trainer` doesn't validate
configurations
(`python/ray/train/huggingface/transformers/_transformers_utils.py`). It
swaps in Ray Data-aware dataloaders and records a usage tag, so
"validate its configurations" goes.
- `getting-started-pytorch-lightning.md`: the strategy classes accept
their base classes' arguments, but the `RayDDPStrategy` docstring says
`process_group_backend`, `timeout`, and `start_method` are disabled and
belong in `TorchConfig`
(`python/ray/train/lightning/_lightning_utils.py`). The sentence now
says so.
- `getting-started-pytorch-lightning.md`: CI tests
`pytorch-lightning==1.8.6` in the Lightning 1.x lane
(`python/requirements/ml/lightning1.txt`, `.buildkite/ml.rayci.yml`) and
`2.6.1` in the main ML lanes (`python/requirements_compiled.txt`).
Nothing installs 1.6.5 or 2.1.2. The minimum, `>=1.6.5`, stays as
written. Whether to raise it is a separate question for the Train team.

### User guides

- `checkpoints.md`: Python, not Ray Train, deletes a
`tempfile.TemporaryDirectory` when its `with` block exits, which can
happen before an async upload finishes. Ray Train deletes the local
directory only after the upload, when
`delete_local_checkpoint_after_upload` is set (`_upload_checkpoint` in
`python/ray/train/v2/_internal/execution/context.py`). The sentence
names the right actor and points out that the page's sample uses
`tempfile.mkdtemp`.
- `fault-tolerance.md`, `hyperparameter-optimization.md`, and
`api/api.md`: Ray Train V2 is the default starting in Ray 2.51.
`is_v2_enabled()` defaults `RAY_TRAIN_V2_ENABLED` to `True`
(`python/ray/train/v2/_internal/constants.py`) since #57857, which
`ray-2.51.0` contains and `ray-2.50.0` doesn't. The intro notes and the
"Enable `RAY_TRAIN_V2_ENABLED=1`" migration steps now scope the variable
to Ray 2.43 through 2.50. Whether to drop these notes entirely is a
scope decision for the Train team.
- `elastic-training.md`: "Without a retry limit, the run exits on the
first such failure," where "such failures" includes node preemption.
`DefaultFailurePolicy`
(`python/ray/train/v2/_internal/execution/failure_handling/default.py`)
charges preemptions to `max_preemption_failures`, which defaults to
`-1`, unlimited (`FailureConfig` in
`python/ray/train/v2/api/config.py`). Other worker failures count
against `max_failures`, which defaults to 0. The prose and the sample's
comment now say so, and the sample's emphasized line moves down one to
stay on `run_config`. **Confirm** node loss: a failure counts as a
preemption only when `RayActorError.preempted` is set, which needs drain
information, so an unannounced node loss should count against
`max_failures`.
- `results.md`: "Ray Train stores all training results, including
reported metrics" contradicts the note at the top of the same page. In
V2, the report handler keeps only reports that carry a checkpoint
(`python/ray/train/v2/_internal/execution/checkpoint/report_handler.py`).
The sentence now says Ray Train stores checkpoints and the metrics
attached to them.
- `asynchronous-validation.md`: worker 0's return value is rejected with
a `ValueError` if `contains_tensor(result)` is true
(`python/ray/train/v2/_internal/execution/worker_group/worker.py`). That
check inspects nested containers, so "can't contain" is more accurate
than "can't be". "Must be Python-based" overstated it. The sentence now
suggests converting with `.item()`, as the page's sample does.

### Framework pages

- `huggingface-accelerate.md`: "the plan is to deprecate
`AccelerateTrainer` in Ray 2.8" is stale. #40274 deprecated it in 2.8.0,
and #41276 removed it in 2.9.0. Whether to keep the migration section at
all is a scope decision for the Train team.
- `distributed-tensorflow-keras.md`: `train.report` doesn't save
checkpoint state "on the trainer, where you ran your Python script".
Workers copy checkpoint files to the configured storage path
(`persist_current_checkpoint` in
`python/ray/train/v2/_internal/execution/storage.py`, called from
`_upload_checkpoint`). The sentence now says so and links the persistent
storage guide.

## Related issue number

None. Not a duplicate: I searched open PRs touching `doc/source/train/`.
The open PRs there are this stack and the example cleanups (#66892,
#66893), which don't touch these lines.

Questions from the style pass that need a Train decision rather than a
source check aren't in this PR. Examples are whether Lightning's
`AsyncCheckpointIO` is incompatible in every upload mode, whether the
PyTorch and TensorFlow parity benchmarks should be rerun or retired, and
when to drop the V2 opt-in and `AccelerateTrainer` migration notes.
They're tracked separately for Ray Train engineering.

## Checks

- Docs-only: every change is in a `.md` file under `doc/source/train/`,
so no library tests run. The one sample edit, a code comment in
`elastic-training.md`, is in an untested `code-block`.
- Every cited claim was checked against the source at this branch's
base.
- `vale` on the changed files from the repo root: alerts only removed,
none added.
- `codespell` on the changed files: clean.
- `doc/.claude/skills/ray-soft-wrap/scripts/softwrap.py --check` on the
changed files: clean.
- Full `-W` doc build: relying on the Read the Docs preview.

AI assistance (Claude Code) was used to research and draft these edits.
Draft until the submitter has reviewed every changed line and a Ray
Train reviewer has confirmed the claims.

🤖 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants