Repository navigation
[train] Revert Train V2 reservation pinning (#66002, #66646) - #67337
pseudo-rnd-thoughts merged 2 commits into
Conversation
…zed them (ray-project#66646)" This reverts commit c854475. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Mark Towers <[email protected]>
…vations (ray-project#66002)" This reverts commit e39557f. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Mark Towers <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request removes the node-pinning logic (label selectors) from Ray Train V2's scaling policies and worker group startup, simplifying resource requests and placement group waiting. It also moves the _get_reserved_resources method directly into ElasticScalingPolicy. A bug was identified in this new method where transient failures when fetching reserved resources would incorrectly overwrite and clear the cached _latest_reserved_resources with None. A code suggestion was provided to ensure the cache is only updated upon a successful query.
| reserved_resources = None | ||
| try: | ||
| reserved_resources = ray.get( | ||
| self._autoscaling_coordinator.get_reserved_resources.remote( | ||
| self._requester_id | ||
| ), | ||
| timeout=AUTOSCALING_REQUESTS_GET_TIMEOUT_S, | ||
| ) | ||
| except Exception: | ||
| msg = ( | ||
| f"Failed to get reserved resources for {self._requester_id}." | ||
| " Will not resize the worker group." | ||
| " If this only happens transiently during network partition or" | ||
| " CPU being overloaded, it's safe to ignore this error." | ||
| " If this error persists, file a GitHub issue." | ||
| ) | ||
| logger.warning(msg, exc_info=True) | ||
| finally: | ||
| self._latest_reserved_resources_query_time = time_monotonic() | ||
| self._latest_reserved_resources = reserved_resources |
There was a problem hiding this comment.
In _get_reserved_resources, if ray.get raises an exception, reserved_resources remains None. In the finally block, self._latest_reserved_resources is then overwritten with None. This clears the cache on any transient failure (such as a temporary network partition or coordinator timeout), which causes subsequent calls within GET_RESERVED_RESOURCES_INTERVAL_S to also return None instead of the last known good cached resources.
We should only update self._latest_reserved_resources when the query succeeds, allowing the cache to persist and be returned on transient failures.
| reserved_resources = None | |
| try: | |
| reserved_resources = ray.get( | |
| self._autoscaling_coordinator.get_reserved_resources.remote( | |
| self._requester_id | |
| ), | |
| timeout=AUTOSCALING_REQUESTS_GET_TIMEOUT_S, | |
| ) | |
| except Exception: | |
| msg = ( | |
| f"Failed to get reserved resources for {self._requester_id}." | |
| " Will not resize the worker group." | |
| " If this only happens transiently during network partition or" | |
| " CPU being overloaded, it's safe to ignore this error." | |
| " If this error persists, file a GitHub issue." | |
| ) | |
| logger.warning(msg, exc_info=True) | |
| finally: | |
| self._latest_reserved_resources_query_time = time_monotonic() | |
| self._latest_reserved_resources = reserved_resources | |
| try: | |
| reserved_resources = ray.get( | |
| self._autoscaling_coordinator.get_reserved_resources.remote( | |
| self._requester_id | |
| ), | |
| timeout=AUTOSCALING_REQUESTS_GET_TIMEOUT_S, | |
| ) | |
| self._latest_reserved_resources = reserved_resources | |
| except Exception: | |
| msg = ( | |
| f"Failed to get reserved resources for {self._requester_id}." | |
| " Will not resize the worker group." | |
| " If this only happens transiently during network partition or" | |
| " CPU being overloaded, it's safe to ignore this error." | |
| " If this error persists, file a GitHub issue." | |
| ) | |
| logger.warning(msg, exc_info=True) | |
| finally: | |
| self._latest_reserved_resources_query_time = time_monotonic() |
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]>
…oordinator's view is wrong Train V2 sizes its worker group from the AutoscalingCoordinator's reservation, which is built from each node's total capacity, counts draining nodes as alive, and is recomputed from scratch when nodes join or leave. Pinning workers to that reservation (ray-project#66002, reverted in ray-project#67337) turned each of the following into a run that retried the same pins forever. These tests assert that the run starts and finishes instead: - Capacity held outside the coordinator: an actor holds node X's slot. The run must start on node Y. - Draining node: X is draining after a preemption notice and is still reported alive. The run must start on Y. - Node churn with two runs: a node joins and sorts first, then the node of the second run is removed. The second run must restart on the new node without disturbing the first, and both must finish. - STRICT_SPREAD on an autoscaling cluster (ray-project#66766): the autoscaler must launch one node per worker, and the run must start on two nodes. Each run's driver and controller stay on the head node, so the scenarios can drain and remove worker nodes. Against the code before the revert, the occupied and draining tests time out, the churn test's second run loops on WorkerGroupStartupTimeoutError while the new node sits free, and the STRICT_SPREAD run waits forever on a reservation that covers one node. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Mark Towers <[email protected]>
Description
Reverts #66646, then #66002, so Train V2 schedules workers the way it did in 2.59. #66001 and #66370 stay; without these two PRs, Train only uses the AutoscalingCoordinator's reservation to count how many workers fit.
#66002 pins every Train V2 worker to a node from the coordinator's reservation, using a
ray.io/node-idbundle label selector. #66646 builds on it. The reservation was built to size autoscaler requests, and it isn't accurate enough to pin to:ray.nodes()reports asAlive, which includes draining nodes, and it uses each node's total resources rather than what's free. So it can reserve a node that is draining, or capacity that's already held by work that never went through the coordinator (any other task, actor, placement group or Serve replica).memoryvalue differs slightly even between nodes of the same type. When a node joins, an existing run's reservation can move to other nodes, including nodes another run is using.When a pin is wrong, the run can't go anywhere else. The pinned placement group never gets placed, and the autoscaler sees no unmet demand, because
request_resourcesalready counts the reserved capacity. The controller retries the same pins after each startup timeout, and with the defaultcontroller_failure_limit=-1it never stops.Reproductions on master
With
ray.cluster_utils.Cluster, a head node plus worker nodes X and Y, each with oneslotresource. X sorts first in the coordinator. A one-worker run asks for{"slot": 1}, withRAY_TRAIN_WORKER_GROUP_START_TIMEOUT_S=5:Alive=True)Driving
_AutoscalingCoordinatorActordirectly with two runs holding reservations, one node joining with slightly morememorymoves both reservations. The second run's new reservation then lands on nodes where the first run's workers are already running.A fixed-size run that asks for more than the cluster has keeps the TrainController actor at 101% CPU while it waits, and
abort()can't reach it. #66646 made the fixed scaling policy wait for its reservation inside the controller loop, and_stepnever awaits on that path.Other failures
train_elastic_e2e_with_node_killing.awsfails intermittently, and every failure since 2026-09-28 has been on a build that contains [train] Pin Train V2 workers to autoscaling coordinator reservations … #66002. Onreleases/2.60.0it failed in 3 of its 5 runs; [cherry-pick][2.60.0][train] Pin worker groups to the reservation snapshot that sized them (#66646) #67327 lists the builds. In builds 109533 and 111090 the run loops onWorkerGroupStartupTimeoutErroruntil the job times out. I have the last ~1,000 log lines of each build, with three startup tracebacks between them. All three time out waiting for the pinned placement group, after the reservation already covered all 12 workers. [train] Pin worker groups to the reservation snapshot that sized them #66646's early exit only fires when a pinned node has died, so it doesn't help there.Bringing pinning back
The goal of #66002, keeping concurrent runs off each other's capacity, still stands. A follow-up can bring pinning back as a single change, off by default behind a flag. It should let a pin cost at most one startup attempt, retrying unpinned if the pinned placement group doesn't place in time. It should also make the reservation leave out draining nodes and stay put when nodes join.
Not part of this revert
_stepalso busy-waits for elastic runs belowmin_workers, and that predates #66002. The yield in #66763 fixes it and applies with or without this revert.Related issues
Reverts #66002 and #66646. Related to #66766, #66794, #66762, #66763, #66765 and #67327.
These open PRs build on #66002 and would need rebasing or closing: #66762, #66763 and #66765.
For
releases/2.60.0, which has #66002 but not #66646, a matching revert of #66002 will follow as a cherry-pick. It's the alternative to #67327, which cherry-picks #66646 onto that branch instead.Additional information
Not a duplicate. No open PR reverts #66002 or #66646.
Revert details. Two commits:
git revert c85447533d(#66646), thengit revert e39557f46c(#66002). Both applied cleanly. #66225's later change tocontroller.pymerged automatically. No master commit has touched these files since #66646. No references to the removed functions remain. pre-commit passes on all changed files.Testing. Run locally on macOS:
I haven't run the
train_elastic_e2e_with_node_killingrelease test on this branch.AI assistance (Claude Code) was used to investigate the failures, write the reproductions, make this revert and write this description.
🤖 Generated with Claude Code