Repository navigation
[train] Warn on Ray Train v1 mode, v1 trainers and v1-only public paths - #68144
Closed
pseudo-rnd-thoughts wants to merge 1 commit into
Closed
pseudo-rnd-thoughts wants to merge 1 commit into
pseudo-rnd-thoughts wants to merge 1 commit into
Conversation
Start the Ray 3.0 deprecation clock for Ray Train v1 (T1.3 of the AIR /
Train v1 removal plan). Each warning names Ray 3.0 as the removal version
and the replacement, and RAY_TRAIN_ENABLE_V2_MIGRATION_WARNINGS=0 silences
it.
- Warn once on `import ray.train` when RAY_TRAIN_V2_ENABLED=0. Ray worker
processes skip it.
- Warn in v1 `BaseTrainer.__init__`, attributed to the user's line and
naming the v2 trainer that replaces it. Skipped in Ray worker processes,
where Tune rebuilds the trainer.
- Turn `ray.train.SyncConfig`, `ray.train.context.{TrainContext,get_context}`
and `ray.train.error.SessionMisuseError` into module `__getattr__`
aliases that warn. Ray code imports private names, and lookups from
inside the `ray` package (including pickling) don't warn.
- Add the deprecation message to the `@Deprecated` docs of the torch AMP
utilities, which already warn in v1 and raise in v2.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Mark Towers <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR starts the Ray 3.0 deprecation clock for Ray Train v1. Train v2 has been the default since Oct 2025, but nothing warns that v1 as a whole is deprecated. Each new warning names Ray 3.0 as the removal version and the replacement.
RAY_TRAIN_ENABLE_V2_MIGRATION_WARNINGS=0silences them, the same as the existing v1 migration warnings.RAY_TRAIN_V2_ENABLED=0import ray.train, pointing at the user's import. Ray worker processes skip it, so it doesn't repeat for every Train worker, Tune trial and RLlib learner.BaseTrainer.__init__. The warning points at the user's line (not thesuper().__init__calls inside Ray) and names the v2 replacement, e.g.ray.train.torch.TorchTrainer. It's skipped in worker processes, where Tune rebuilds the trainer.ray.train.SyncConfig,ray.train.context.{TrainContext, get_context},ray.train.error.SessionMisuseError__getattr__aliases that warn. Ray's own code imports private names (_TrainContext,_SessionMisuseError, …). Lookups from inside theraypackage, includingray.cloudpicklepickling by reference, don't warn, because users can't fix those.SyncConfigis removed fromray.train.__all__.ray.train.torch.{accelerate, prepare_optimizer, backward}@Deprecateddocs and says "Ray 3.0". The message is now defined once, inray.train.constants.Notes for review:
SyncConfigkeeps__module__ = "ray.train", so existing pickledRunConfig(sync_config=...)objects, including Tune experiment state, still load. Unpickling them in user code (not Ray's deserializer) emits the warning._find_callerinray/train/utils.pyattributes a warning to the first frame outside theraypackage. It skips importlib's_handle_fromlist(packagefrom x import y) and the pickle lookup machinery, and it matches CPython's rule of not counting frozen importlib frames instacklevel.deprecated.rststill resolves every name through__getattr__.Related issues
Related to #49454 (Ray Train v2 migration).
Additional information
Not a duplicate: I searched open PRs for "train v1 deprecation warning" and "RAY_TRAIN_V2_ENABLED deprecat" and found nothing overlapping.
Tests:
python/ray/train/tests/test_v1_deprecation_warnings.py, run withRAY_TRAIN_V2_ENABLED=0as in its BUILD target. 17 passed. It covers:ray.train/ray.tune/ray.rllibraises noRayDeprecationWarningin either v1 or v2 mode;ray.cloudpicklepickling doesn't warn;RAY_TRAIN_V2_ENABLED=0 python -m pytest python/ray/train/tests/{test_api_migrations,test_session,test_storage}.py: 7, 32 and 14 passed.python -m pytest python/ray/tune/tests/{test_syncer,test_api_migrations,test_function_api}.py: 13, 3 and 12 passed.train/v2/tests/test_torch_trainer.pywas still running locally when I opened this PR. CI will cover it.test_session.py::test_lockingfails when it runs in the same process astest_api_migrations.py. It fails the same way on unmodified master and passes on its own; Bazel runs each file separately.pre-commit run --files <changed files>is clean.AI assistance: I wrote this change with Claude Code. I reviewed the diff and ran the tests listed above.
🤖 Generated with Claude Code