Repository navigation
[data] Run the autoscaling coordinator actor on the head node - #67480
pseudo-rnd-thoughts merged 8 commits into
Conversation
`get_or_create_autoscaling_coordinator` created the detached coordinator with hard node affinity to the first caller's node and `max_restarts=-1`. That caller can be on any node, for example a Train controller or a Ray Data executor running inside a Train worker. If that node died, the actor couldn't be rescheduled (`ActorUnschedulableError`), and every Ray Data and Ray Train requester on the cluster lost the coordinator for good. Soft affinity doesn't keep the local-node preference for this actor: `ClusterResourceScheduler::GetBestSchedulableNode` places an actor that requests no resources on a random node unless its affinity is hard. So the actor would land on any node, including autoscaled workers it would restart off whenever they scale down. Pin it to the head node instead, with a tiny amount of the head node's `node:__internal_head__` resource, the way Ray Serve places its controller. The head node lives as long as the cluster, and a restarted head, with GCS fault tolerance, has the same resource, so the actor can restart there. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Mark Towers <[email protected]>
… group Pinning the coordinator to the head node with the `node:__internal_head__` resource dropped its explicit scheduling strategy. A caller running in a placement group that captures child tasks (Tune trials, Train V1 workers) then made the actor join that group, whose bundles don't hold the head node resource, so creating it raised `ValueError: Cannot schedule _AutoscalingCoordinatorActor with the placement group`. This broke test_new_dataset_config.py::test_basic and test_torch_transformers_train.py::test_e2e_ray_data. Use the "DEFAULT" strategy, as the Train state actors do, so the detached actor escapes the group and doesn't die when it's removed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Mark Towers <[email protected]>
Signed-off-by: Mark Towers <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request modifies the AutoscalingCoordinator to be created on the head node as a detached actor, rather than being pinned to the local node of the initial caller. This ensures that the coordinator remains available even if the initiating worker node is lost. The scheduling strategy was updated to use the default strategy with a head node resource requirement. Two new unit tests were added to verify that the coordinator runs on the head node and escapes caller placement groups. There are no review comments to address, and the changes look solid.
| # on the cluster shares this detached actor. | ||
| actor_cls = ray.remote( | ||
| num_cpus=0, | ||
| resources={HEAD_NODE_RESOURCE_LABEL: 0.001}, |
There was a problem hiding this comment.
Without this label, was it not guaranteed to run on the head node? I thought num_cpus=0 meant that it must go onto the head node, since worker nodes should have non-zero cpus
There was a problem hiding this comment.
Interesting question, checking, when you request num_cpu=0 and no hard affinity, then GetBestSchedulableNode will pick a random feasible node which could be the head node but not guaranteed.
| assert ray.get([res1, res2]) == ["ok"] * 2 | ||
|
|
||
|
|
||
| def test_coordinator_actor_runs_on_the_head_node(cluster): |
There was a problem hiding this comment.
Is this test a subset of the next one?
When can the remove_node / remove_placement_group tails in both tests fail btw?
There was a problem hiding this comment.
Sort of, the first test is a basic check that the AutoscalingCoordinator is scheduled on the head node and if the worker node is deleted, the coordinator still exists. While for the second test is a more realistic variant using a PlacementGroup to check that when a placement group is killed then the coordinator isn't lost as well.
Happy to delete the first test
There was a problem hiding this comment.
Would be great; thanks
There was a problem hiding this comment.
Will do, added in the latest commit
…mory Signed-off-by: Mark Towers <[email protected]>
Co-authored-by: Chi-Sheng Liu <[email protected]> Signed-off-by: Mark Towers <[email protected]>
Signed-off-by: Mark Towers <[email protected]>
Signed-off-by: Mark Towers <[email protected]>
Summary
Runs the shared AutoscalingCoordinator actor on the head node instead of the first caller's node, so losing a worker node no longer takes the coordinator with it for every Ray Data and Ray Train requester on the cluster.
Before
get_or_create_autoscaling_coordinatorcreated the detached actor with hard node affinity to the caller's node andmax_restarts=-1. The original PR (#59353) noted "Create the actor on the local node, to reduce network overhead".The problem is that the coordinator, though, is shared by every requester on the cluster. The first caller can be on any node, for example a Train controller or a Ray Data executor inside a Train worker. If that node dies, the actor can't be rescheduled (
ActorUnschedulableError). Requesters that already hold a handle, such as Train's coordinator client, lose it for good, so a running elastic run can't resize or restart.Soft affinity doesn't help:
ClusterResourceScheduler::GetBestSchedulableNodeplaces an actor that requests no resources on a random node unless its affinity is hard, so it could land on an autoscaled worker and restart elsewhere every time that worker scales down.After
The actor requests
node:__internal_head__: 0.001and usesscheduling_strategy="DEFAULT". This is the same pattern as the Serve controller (serve/_private/default_impl.py) and both Train state actors (train/_internal/state/state_actor.py,train/v2/_internal/state/state_actor.py). The head node lives as long as the cluster. With GCS fault tolerance, a restarted head has the same resource, so the actor can restart there.The explicit
"DEFAULT"strategy matters. Without it, a caller in a placement group that captures child tasks (Tune trials, Train V1 workers) makes the actor join that group. The bundles don't hold the head-node resource, so creation fails withValueError: Cannot schedule _AutoscalingCoordinatorActor with the placement groupand a detached actor shouldn't die with someone else's group anyway.New tests
In
test_autoscaling_coordinator.py:test_coordinator_actor_runs_on_the_head_node: created from a worker node, the actor runs on the head and survives that worker's removal.test_coordinator_actor_escapes_the_callers_placement_group: created from a task in a placement group that captures child tasks, the actor runs on the head and survives the group's removal. It fails withoutscheduling_strategy="DEFAULT".The end-to-end case,
test_run_restarts_after_the_coordinators_first_caller_dies, is in #67481.AI assistance (Claude Code) was used to write these changes and tests, run the suites, and write this description.
🤖 Generated with Claude Code