Repository navigation
[cherry-pick][2.60.0][train] Pin worker groups to the reservation snapshot that sized them (#66646) - #67327
Closed
sai-miduthuri wants to merge 1 commit into
Closed
[cherry-pick][2.60.0][train] Pin worker groups to the reservation snapshot that sized them (#66646)#67327sai-miduthuri wants to merge 1 commit into
sai-miduthuri wants to merge 1 commit into
Conversation
…#66646) ## Description `test_elastic_e2e` has been timing out on CI since #66002, which pins Train V2 workers to AutoscalingCoordinator reservations. The elastic worker group start waits the full 60s (`RAY_TRAIN_WORKER_GROUP_START_TIMEOUT_S`) whenever the reservation changes between the scaling decision and pinning. The decision is sized from the cached reservation, while the pins come from a separate `recompute=True` poll in `_try_get_selectors`, so: 1. **The reservation grows past the decision.** Elastic requests `max_workers` bundles, so after `ResizeDecision(14)` the reservation can reach 32 slots. `len(label_selectors) != num_workers` then never passes. 2. **The reservation shrinks below the decision.** After a node dies, the cached view still counts it, and pinning waits for workers that don't exist. This PR takes the decision and the pins from the **same snapshot**, so they can't disagree: - **Pins on `ResizeDecision`.** `ResizeDecision.label_selectors` is built by the scaling policy from the reservation that chose `num_workers`, using the same `_floor_slots` math. The STRICT_PACK/STRICT_SPREAD layout check from #66002 is kept. The controller just applies the pins and no longer polls the coordinator. - **Elastic** decides and pins from a fresh (`recompute=True`) view. In the non-running path it reads the fresh view only once the cached one looks ready, so waiting doesn't trigger a full coordinator tick every loop. - **Fixed** now waits for its reservation in `make_decision_for_non_running_worker_group` (returning `NoopDecision` until every worker is covered), the same way elastic waits for `min_workers`. This removes `get_reserved_bundle_label_selectors`, its 60s poll loop, and the controller's `WorkerGroupStartupTimeoutError` raise. Both policies log a rate-limited "Waiting for reserved resources" message while they wait. Before, elastic logged nothing when nothing was reserved. - **Stop the placement group wait early when a pinned node dies.** The coordinator drops nodes that `ray.nodes()` reports dead, but the GCS can still report a just-removed node as alive for a short time. A pin made in that window can never be placed, so `WorkerGroup` now polls `pg_handle.wait()` in 1s intervals and stops as soon as a pinned node is no longer alive. It raises the same retryable `WorkerGroupStartupTimeoutError` instead of stalling for 60s. `test_elastic_e2e` hits this window on purpose by removing every node and restarting right away. Locally this went from a 60s stall to giving up after about 1s. Skipping pins (TPU, zero-resource workers, user `label_selector`) moves into `ScalingPolicy._should_pin_to_reservation`. The controller still lets a callback-provided `label_selector` win, because the policy can't see those. Behavior change: a fixed run waiting for capacity no longer fails and retries every 60s through the failure policy. It waits in the controller loop like elastic. With the default `controller_failure_limit=-1`, the only visible difference is the log messages. ## Related issues Alternative to #66601, which fixes the same `test_elastic_e2e` flake differently: it picks a subset of a larger reservation with `_compute_reservations` and adds a relative `_FIT_EPSILON` to the coordinator's shared `_bundle_can_fit_on_node`. This PR avoids the Train → Ray Data `_compute_reservations` dependency and leaves the coordinator's fit check, which every requester shares, unchanged. It also avoids an extra restart when the reservation grows, because it starts at the size the reservation supports now. ## Testing All passing locally (macOS, `ray_dev_py311`): ``` pytest python/ray/train/v2/tests/test_autoscaling_coordinator_client.py \ python/ray/train/v2/tests/test_elastic_scaling_policy.py # 37 passed pytest python/ray/train/v2/tests/test_controller.py \ python/ray/train/v2/tests/test_controller_callback_behaviour.py \ python/ray/train/v2/tests/test_failure_policy.py \ python/ray/train/tests/test_autoscaling_coordinator_client.py # 65 passed pytest python/ray/train/v2/tests/test_scheduling.py \ python/ray/train/v2/tests/test_elastic_e2e.py \ python/ray/train/v2/tests/test_state.py # 34 passed pytest python/ray/train/v2/tests/test_worker_group.py \ python/ray/train/v2/tests/test_elastic_e2e.py # 43 passed pre-commit run --files <changed files> # clean ``` In the last `test_elastic_e2e` run, the controller log shows the "decide 4 right after every node was removed" restart stopping after about 1s ("Giving up on the placement group early…") instead of the 60s stall seen before the early-stop change. Known gap: when it stops early, the retried `WorkerGroupStartupTimeoutError` still says "timed out after 60.0 seconds". The info log just before it gives the real reason. AI assistance (Claude Code) was used to write this change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Justin Yu <[email protected]> Signed-off-by: Mark Towers <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]> Co-authored-by: Mark Towers <[email protected]> Co-authored-by: Mark Towers <[email protected]> (cherry picked from commit c854475) Signed-off-by: Sai Miduthuri <[email protected]>
sai-miduthuri
marked this pull request as draft
October 23, 2026 13:27
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors and improves how Ray Train workers are pinned to AutoscalingCoordinator reservations. It updates both elastic and fixed scaling policies to include node-pinning label selectors directly in the scaling decisions, built from a fresh reservation snapshot to prevent scheduling onto nodes that have recently died. Additionally, the worker group startup logic is enhanced to check the liveness of pinned nodes while waiting for the placement group, allowing it to fail and retry early if a pinned node dies. Unit tests have been updated and added to verify these behaviors. As there are no review comments provided, I have no further feedback to offer.
Contributor
Author
sai-miduthuri
added a commit
that referenced
this pull request
Oct 26, 2026
Reverts #66002 on `releases/2.60.0`. This is the release-branch counterpart of #67337, which reverts #66646 and then #66002 on master. This branch never had #66646, so only #66002 is reverted here. ## Why #66002 pins every Train V2 worker to a node from the AutoscalingCoordinator's reservation. #67337 explains why that reservation isn't accurate enough to pin to: - It counts draining nodes and capacity held by work that never went through the coordinator. - It moves when nodes join. When a pin is wrong, the pinned placement group never gets placed, and the controller retries the same pins indefinitely. On this branch, the `train_elastic_e2e_with_node_killing.aws` release test failed in 3 of its 5 weekly release-pipeline runs. In builds 109533 and 111090 it looped on `WorkerGroupStartupTimeoutError` until the job timed out. #66766, where STRICT_SPREAD runs can wait forever, also bisects to #66002. After this revert, Train V2 schedules workers the way it did in 2.59. #66001 and #66370 stay, as in #67337, so Train still uses the coordinator's reservation to count how many workers fit. This is the alternative to #67327, which cherry-picks #66646 onto this branch instead. If this PR merges, #67327 should be closed. ## Revert details `git revert e39557f` applied with no conflicts, and git merged #66225's later change to `controller.py` automatically. The revert touches 11 files, with 70 insertions and 759 deletions. - The diff is byte-identical to #67337's revert of #66002 (deb5235), index lines included. - Before the revert, the 11 files on this branch were identical to master right after #67337 reverts #66646. After the revert, they match #67337's head. - No code on this branch references the functions or classes the revert removes. The few names that still have references are definitions that existed before #66002, such as the Ray Data coordinator's `get_reserved_resources`. Not a duplicate: no PR against `releases/2.60.0` reverts #66002. #67337 targets `master`. ## Testing | Command | Result | |---|---| | pre-commit, run as the commit hook on the 11 changed files | Passed (ruff, black, pydoclint, Ray Train circular imports, and the other applicable hooks) | I didn't run the unit tests locally. CI runs them on this PR: - `:bullettrain_front: ml: train v2 tests` runs the `train_v2`-tagged tests, including `test_controller.py`, `test_elastic_scaling_policy.py`, `test_autoscaling_coordinator_client.py` and `test_failure_policy.py`. - `:train: ml: train v1 tests` runs `python/ray/train/tests/test_autoscaling_coordinator_client.py`. - `:train: ml: data integration tests` runs `test_data_integration.py`. #67337 ran the same test files against the same resulting code on master, and they passed. AI assistance was used to prepare this revert. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Sai Miduthuri <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[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.
Cherry-pick of #66646 (master commit c854475) onto
releases/2.60.0.Why
#66646 fixes a Train v2 worker-group startup stall that started with #66002, which this branch has. Two things caused it:
#66646 takes the decision and the pins from the same reservation snapshot, and stops the placement-group wait early when a pinned node is no longer alive.
On this branch, the
train_elastic_e2e_with_node_killing.awsrelease test failed in 3 of its 5 weekly release-pipeline runs so far:WorkerGroupStartupTimeoutErrors. This is the stall [train] Pin worker groups to the reservation snapshot that sized them #66646 fixes.TaskUnschedulableError, because it targeted a node that no longer existed. That code is inrelease/train_tests/elastic_training/elastic_util.py, which this PR doesn't change.The test passed in builds 110336 and 111483.
Cherry-pick details
Applied cleanly with
git cherry-pick -x. The diff is byte-identical to the master commit, index lines included: 9 files, 496 insertions and 264 deletions.No prerequisite commits are missing:
time_monotonicfromray.train.v2._internal.util, which this branch has.python/ray/train/v2/differs from [train] Pin worker groups to the reservation snapshot that sized them #66646's parent only in files this PR doesn't touch: NCCL hang-detector changes and test fixes.Not a duplicate: this branch doesn't contain #66646, and no PR against
releases/2.60.0references it.Testing
pre-commit run --files <the 9 changed files>I didn't run the unit tests locally. The changed tests and
test_elastic_e2eare taggedtrain_v2, so CI's:bullettrain_front: ml: train v2 testsjob runs them on this PR.AI assistance was used to prepare this cherry-pick.
🤖 Generated with Claude Code