Repository navigation
[data][actor-only][9/n] Node-shaped scaling requests - #67705
iamjustinhsu wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the experimental actor pool scaling logic by replacing the generic ExperimentalActorPoolScalingRequest with specific ScaleUpRequest and ScaleDownRequest dataclasses. This shifts the responsibility of picking specific victim actors from the sizer to the actor pool itself, simplifying the placement strategy. Feedback on the changes highlights two key improvements: first, preventing a potential crash in capacity_transfer.py by ensuring ScaleDownRequest is only instantiated when there are actually nodes to cancel; second, improving the robustness of _shed_on_node in actor_pool.py by iterating through all victim candidates until the target count is reached, rather than slicing the list beforehand.
| claimed = set(still_pending) | ||
| pool.scale( | ||
| ExperimentalActorPoolScalingRequest( | ||
| delta=-len(still_pending), | ||
| ScaleDownRequest.on_nodes( | ||
| [ | ||
| node | ||
| for node, ids in pool.pending_ids_by_target_node().items() | ||
| for actor_id in ids | ||
| if actor_id in claimed | ||
| ], | ||
| force=True, | ||
| reason="optimizer: transfer timed out", | ||
| actor_ids_to_downscale=tuple(still_pending), | ||
| ) | ||
| ) |
There was a problem hiding this comment.
If nodes_to_cancel (the list of nodes to cancel) is empty, calling ScaleDownRequest.on_nodes will result in delta = 0. This will trigger an AssertionError in ScaleDownRequest.__post_init__ which asserts self.delta < 0.
To prevent this crash, we should only call pool.scale if there are actually nodes to cancel.
claimed = set(still_pending)
nodes_to_cancel = [
node
for node, ids in pool.pending_ids_by_target_node().items()
for actor_id in ids
if actor_id in claimed
]
if nodes_to_cancel:
pool.scale(
ScaleDownRequest.on_nodes(
nodes_to_cancel,
force=True,
reason="optimizer: transfer timed out",
)
)| num_downscaled = 0 | ||
| for _ in range(count): | ||
| if self._remove_inactive_actor(): | ||
| for logical_id in victims[:count]: | ||
| if self._downscale_actor_by_id(logical_id, reason): | ||
| num_downscaled += 1 | ||
| return num_downscaled |
There was a problem hiding this comment.
Slicing victims[:count] and attempting to downscale only those specific actors can result in downscaling fewer actors than requested if any of the selected actors fail to downscale (e.g., if they are already draining or not found).
Instead, we should iterate through all available victims and stop once we have successfully downscaled count actors. This makes the downscaling process much more robust against concurrent state changes.
num_downscaled = 0
for logical_id in victims:
if num_downscaled >= count:
break
if self._downscale_actor_by_id(logical_id, reason):
num_downscaled += 1
return num_downscaled8ed44a6 to
edc1389
Compare
cf79851 to
d8b133b
Compare
d8b133b to
6396876
Compare
0f0bd28 to
8df7dea
Compare
8df7dea to
e0ef1c7
Compare
e0ef1c7 to
e004e19
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e004e19. Configure here.
e004e19 to
b012a45
Compare
rayhhome
left a comment
There was a problem hiding this comment.
LGTM! Bugbot provided one reasonable suggestion that's non-blocking.
bdec7aa to
815c3d8
Compare
815c3d8 to
a847f5a
Compare
82d5c62 to
f0f4e6f
Compare
Make the sizer's scaling requests node-shaped. scale_where resolves each operator's delta to concrete nodes for both scale-ups and scale-downs (pick_downscale_nodes), and the actor pool applies those per-node deltas directly. Placement is re-derived from current state every tick, so a failed placement or a slow drain simply retries. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: iamjustinhsu <[email protected]> Co-authored-by: sampan <[email protected]> Co-authored-by: Prasad Palkar <[email protected]>
…ing_actor Node-shaped scaling removed _ExperimentalActorPool._try_remove_pending_actor; a single pending actor is now cancelled through _downscale_actor_by_id. The "pending" case of test_exact_resource_requests_lifecycle still called the removed method and failed with AttributeError. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: iamjustinhsu <[email protected]>
f0f4e6f to
f92f771
Compare
…o/09-node-shaped-scaling Signed-off-by: iamjustinhsu <[email protected]>
…o/09-node-shaped-scaling Signed-off-by: iamjustinhsu <[email protected]>

Summary
Make the sizer's scaling requests node-shaped: placement resolves each operator's delta to concrete nodes for scale-ups and scale-downs, and the actor pool scales up and down on those nodes.
Part 9 of 12 of the Ray Data actor-only backend stack. Stacked on #67704; review only the top commit. Everything here is gated behind
RAY_DATA_ACTOR_ONLY_BACKEND(off by default) unless noted under After.Before
Scale-down requests are counts, and the pool picks which actors to shed. Scale-up placement and pool bookkeeping use separate models.
After
scale_wherereturns per-node deltas in both directions (pick_downscale_nodes).flowchart TD subgraph Before subgraph BS[Subsystem: resource allocation] subgraph BC[Component: operator sizer -> actor pool] B1["scale_where: upscale nodes only"] --> B2["pool: picks actors to shed"] end end end subgraph After subgraph AS[Subsystem: resource allocation] subgraph AC[Component: operator sizer -> actor pool] A1["scale_where: per-node up/down deltas"] --> A2["pool: applies per-node deltas"] end end end class A1,A2 changed classDef removed fill:#ffcdd2,stroke:#c62828,color:#000 classDef added fill:#c8e6c9,stroke:#2e7d32,color:#000 classDef changed fill:#fff9c4,stroke:#f9a825,color:#000Subsystems
resource allocation / autoscaling (flag-gated), execution (experimental actor pool)
Testing
RAY_DATA_ACTOR_ONLY_BACKEND=1 pytest python/ray/data/tests/actor_only: 354 passed.pre-commit runon changed files: clean.Notes
gh pr list --repo ray-project/ray --state open --search "actor-only").🤖 Generated with Claude Code