Skip to content

[train] Add Elastic Training Capability for Ray Train - #60721

Merged
justinvyu merged 8 commits into
ray-project:masterfrom
liulehui:oss-elastic-training
Feb 11, 2026
Merged

justinvyu merged 8 commits into
ray-project:masterfrom
liulehui:oss-elastic-training

Conversation

@liulehui

@liulehui liulehui commented Feb 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR adds the Elastic Training capability in Ray Train.

  1. we add a new ElasticScalingPolicy that can take ScalingConfig(num_workers=(2,4))
  2. ElasticScalingPolicy talks with AutoScalingCoordinator to decide the number of possible workers in the cluster to launch with the worker group.
227f8a4c06729567220ca059206248cc 3. elastic training will be automatically enabled if user passed in num_workers=(2,4). 4. added corresponding unit test coverage

Related issues

Additional information

Tested on Anyscale platform:

https://console.anyscale-staging.com/cld_kvedZWag2qA8i5BjxUevf5i7/prj_92c7b71w55flm6gv6imv4m6vqg/workspaces/expwrk_ab5kfa4v9ci15t56dbr8rhmks3/train/train/f5fa9fc5f8d94dc0bd7b545876d660ab?workspace-tab=ray-turbo-dashboard&command-history-section=application_logs

ee28696c710f21511022a5d0ea9b93b8

@liulehui liulehui added the go add ONLY when ready to merge, run all tests label Feb 3, 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 a prototype for elastic training in Ray Train, which is a great addition. The core logic is implemented in the new ElasticScalingPolicy, which interacts with the AutoscalingCoordinator to dynamically adjust the number of workers based on available cluster resources. The changes to ScalingConfig to support a (min_workers, max_workers) tuple for num_workers are well-designed and include good validation logic. The accompanying tests are comprehensive and cover many important scenarios.

I've found a critical issue in the error handling logic that could suppress exceptions, and a validation gap that allows negative worker counts. My review includes suggestions to address these points. Overall, this is a solid foundation for the elastic training feature.

Comment thread python/ray/train/v2/api/config.py Resolved
@liulehui
liulehui force-pushed the oss-elastic-training branch from c6163ca to 8c3e611 Compare February 5, 2026 23:25
@liulehui liulehui changed the title [train] prototype for oss elastic training [train] Add Elastic Training Capability for Ray Train Feb 6, 2026
@liulehui
liulehui marked this pull request as ready for review February 6, 2026 21:21
@liulehui
liulehui requested a review from a team as a code owner February 6, 2026 21:21

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

Thanks, let's add the one ray.get() timeout in the code sending the resource request.

Also, let's file some tickets to also add a user guide and port over the release test.

@liulehui

Copy link
Copy Markdown
Contributor Author

Thanks, let's add the one ray.get() timeout in the code sending the resource request.

Also, let's file some tickets to also add a user guide and port over the release test.

SG! done adding the timeout, for ticket see this epic: https://anyscale1.atlassian.net/browse/TRAIN-874
next few ones are doc/release tests/telemetry
Let me know you think there are other follow up we should add!

@liulehui
liulehui force-pushed the oss-elastic-training branch from 0aa6ff2 to 2123ab4 Compare February 10, 2026 22:11

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Comment thread python/ray/train/v2/api/config.py Resolved
Signed-off-by: Lehui Liu <[email protected]>
@justinvyu
justinvyu merged commit 5eb9413 into ray-project:master Feb 11, 2026
3 checks passed
ans9868 pushed a commit to ans9868/ray that referenced this pull request Feb 18, 2026
)

This PR adds the Elastic Training capability in Ray Train.
1. we add a new `ElasticScalingPolicy` that can take
`ScalingConfig(num_workers=(2,4))`
2. `ElasticScalingPolicy` talks with `AutoScalingCoordinator` to decide
the number of possible workers in the cluster to launch with the worker
group.
3. elastic training will be automatically enabled if user passed in
num_workers=(2,4).
4. added corresponding unit test coverage

---------

Signed-off-by: Lehui Liu <[email protected]>
Signed-off-by: Adel Nour <[email protected]>
Aydin-ab pushed a commit to kunling-anyscale/ray that referenced this pull request Feb 20, 2026
)

This PR adds the Elastic Training capability in Ray Train.
1. we add a new `ElasticScalingPolicy` that can take
`ScalingConfig(num_workers=(2,4))`
2. `ElasticScalingPolicy` talks with `AutoScalingCoordinator` to decide
the number of possible workers in the cluster to launch with the worker
group.
3. elastic training will be automatically enabled if user passed in
num_workers=(2,4).
4. added corresponding unit test coverage

---------

Signed-off-by: Lehui Liu <[email protected]>
pseudo-rnd-thoughts added a commit that referenced this pull request Oct 29, 2026
…d fix the elastic node-killing release test (#67478)

## Description

This PR fixes two issues with the controller.

1. **Controller busy-wait:** In `INITIALIZING`, `RESTARTING` and
`RESCHEDULING`, `TrainController._step` never awaits, yielding the event
loop. While the scaling policy keeps returning `NoopDecision` (an
elastic run waiting for `min_workers` to fit, or a failed coordinator
query), `run()` loops without yielding the event loop meaning that the
controller actor spins a full core and that an `abort()` can't reach it,
so Ctrl-C on the driver doesn't stop the run.

This has been true for elastic runs since #60721. This PR updates
`_step` to now sleeps `RAY_TRAIN_HEALTH_CHECK_INTERVAL_S` before asking
the policy again, matching the running path's poll interval. Once
`abort()` can run during that sleep, the control loop must not overwrite
the `AbortedState` it set with the state computed before the abort, so a
terminal state set concurrently is left in place.

2. **Elastic node-killing release test:** `terminate_node` in
`elastic_util.py` runs its killer task on the node it terminates, with
hard affinity and default retries. When the task dies with the node, Ray
retries it, and the retry can never be scheduled, so `ray.get` raises
`TaskUnschedulableError` and `train_elastic_e2e_with_node_killing` fails
after training already succeeded (failure mode A). The killer task is no
longer retried, and `NodeDiedError`, `WorkerCrashedError` and
`TaskUnschedulableError` count as the node having gone down.

New test: `test_abort_while_waiting_for_a_scaling_decision` in
`test_controller.py`. It raises `TimeoutError` without the fix. The
end-to-end version, `test_ctrl_c_aborts_a_run_waiting_for_workers` (a
real driver process receiving SIGINT), is in #67481.

AI assistance (Claude Code) was used to write these changes and tests,
run the suites, and write this description.

---------

Signed-off-by: Mark Towers <[email protected]>
Co-authored-by: Mark Towers <[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

claude-code-assisted go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants