Skip to content

[data][actor-only][9/n] Node-shaped scaling requests - #67705

Open
iamjustinhsu wants to merge 4 commits into
iamjustinhsu/ao/08-constraint-release-testsfrom
iamjustinhsu/ao/09-node-shaped-scaling
Open

iamjustinhsu wants to merge 4 commits into
iamjustinhsu/ao/08-constraint-release-testsfrom
iamjustinhsu/ao/09-node-shaped-scaling

Conversation

@iamjustinhsu

Copy link
Copy Markdown
Contributor

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_where returns per-node deltas in both directions (pick_downscale_nodes).
  • The pool applies them directly.
  • Placement runs again from current state every tick, so a failed placement or a slow drain just retries.
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:#000
Loading

Subsystems

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 run on changed files: clean.

Notes

  • Not a duplicate: no open ray-project/ray PR covers the actor-only backend (checked with gh pr list --repo ray-project/ray --state open --search "actor-only").
  • AI assistance (Claude Code) was used for this change. I have reviewed every changed line.

🤖 Generated with Claude Code

@iamjustinhsu
iamjustinhsu added this pull request to stack #67709 November 2, 2026 21:02
@iamjustinhsu
iamjustinhsu removed this pull request from stack #67709 November 2, 2026 21:05
@iamjustinhsu
iamjustinhsu added this pull request to stack #67710 November 2, 2026 21:05
@iamjustinhsu iamjustinhsu added the go add ONLY when ready to merge, run all tests label Nov 2, 2026
@iamjustinhsu
iamjustinhsu marked this pull request as ready for review November 2, 2026 21:16
@iamjustinhsu
iamjustinhsu requested a review from a team as a code owner November 2, 2026 21:16

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

Comment on lines +579 to 591
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),
)
)

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.

high

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",
                        )
                    )

Comment on lines 762 to 766
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

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.

medium

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_downscaled

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

Stale Bugbot comment from a previous run.

@ray-gardener ray-gardener Bot added the data Ray Data-related issues label Nov 3, 2026
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/09-node-shaped-scaling branch 2 times, most recently from 8ed44a6 to edc1389 Compare November 3, 2026 23:10
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/09-node-shaped-scaling branch 3 times, most recently from cf79851 to d8b133b Compare November 6, 2026 04:17
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/09-node-shaped-scaling branch from d8b133b to 6396876 Compare November 6, 2026 20:34
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/09-node-shaped-scaling branch 2 times, most recently from 0f0bd28 to 8df7dea Compare November 10, 2026 21:09
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/09-node-shaped-scaling branch from 8df7dea to e0ef1c7 Compare November 12, 2026 17:04
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/09-node-shaped-scaling branch from e0ef1c7 to e004e19 Compare November 13, 2026 02:38

@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 using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/09-node-shaped-scaling branch from e004e19 to b012a45 Compare November 13, 2026 22:36
@rayhhome rayhhome self-assigned this Nov 16, 2026

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

LGTM! Bugbot provided one reasonable suggestion that's non-blocking.

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/09-node-shaped-scaling branch from bdec7aa to 815c3d8 Compare November 19, 2026 00:41
@richardliaw
richardliaw force-pushed the iamjustinhsu/ao/09-node-shaped-scaling branch from 815c3d8 to a847f5a Compare November 19, 2026 19:52
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/09-node-shaped-scaling branch 3 times, most recently from 82d5c62 to f0f4e6f Compare November 19, 2026 23:22
iamjustinhsu and others added 2 commits November 19, 2026 15:23
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]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data Ray Data-related issues 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