Skip to content

[data][actor-only][10/n] AO cleanup aftermath - #67706

Open
iamjustinhsu wants to merge 3 commits into
iamjustinhsu/ao/09-node-shaped-scalingfrom
iamjustinhsu/ao/10-cleanup-aftermath
Open

iamjustinhsu wants to merge 3 commits into
iamjustinhsu/ao/09-node-shaped-scalingfrom
iamjustinhsu/ao/10-cleanup-aftermath

Conversation

@iamjustinhsu

@iamjustinhsu iamjustinhsu commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-ups on the sizer:

  • Capacity transfers hold the capacity they're still owed, and a transfer that would undo a recent one is refused as thrashing.
  • Warmup has a timeout.
  • Initial sizing places constrained operators before unconstrained ones.

Part 10 of 12 of the Ray Data actor-only backend stack. Stacked on #67705; review only the top commit. Everything here is gated behind RAY_DATA_ACTOR_ONLY_BACKEND (off by default) unless noted under After.

Before

A capacity transfer's freed capacity can be taken by another operator before its recipient scales up. A transfer can be undone right away (A->B, then B->A). If one critical operator never produces output, the sizer stays in warmup indefinitely.

After

  • Holding owed capacity: open transfers reserve their owed capacity against free.
  • No thrashing: an inverse transfer is refused for RAY_DATA_SIZER_TRANSFER_THRASH_WINDOW_TICKS ticks (default 20).
  • Warmup timeout: warmup ends after at most RAY_DATA_SIZER_WARMUP_TIMEOUT_S (default 300s).
  • Initial-sizing order: operators below their min size go first, but within that group the scarcity tiers (label selector, placement group, GPU) still apply. Constrained operators are placed before unconstrained ones at startup, so an unconstrained operator can't take the labeled nodes first.
  • Release test fix: heterogeneous_memory_batch_inference now requests num_cpus=1 for its GPU stage. The GPU nodes in both compute configs that run it (heterogeneous_memory_compute.yaml and heterogeneous_memory_compute_multitenancy.yaml, which reuses the same pipeline) now have CPUs.
flowchart TD
    subgraph Before
        subgraph BS[Subsystem: resource allocation]
            subgraph BC[Component: sizer optimizer]
                B1[capacity transfer] --> B2[free capacity up for grabs]
            end
        end
    end
    subgraph After
        subgraph AS[Subsystem: resource allocation]
            subgraph AC[Component: sizer optimizer]
                A1[capacity transfer] --> A2[hold owed capacity]
                A1 --> A3[refuse inverse transfer within thrash window]
                A4[warmup timeout]
            end
        end
    end
    class A2,A3,A4 added
    class A1 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); release test config

Testing

  • RAY_DATA_ACTOR_ONLY_BACKEND=1 pytest python/ray/data/tests/actor_only: 368 passed, including the new test_scarcity_first_ordering[all-below-min-keeps-tiers] case.
  • 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 force-pushed the iamjustinhsu/ao/10-cleanup-aftermath branch from fbdf128 to c6dbcdc Compare November 2, 2026 21:10
@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
@iamjustinhsu iamjustinhsu added the go add ONLY when ready to merge, run all tests label Nov 2, 2026

@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 introduces several enhancements to Ray Data's execution sizer, including a warmup timeout mechanism, a thrashing prevention window for capacity transfers, and improved actor backpressure metrics that exclude draining or restarting actors. It also refactors capacity transfers to hold owed capacity until donor slots are freed and resolves a concurrency issue during executor shutdown. However, the reviewer identified a regression in the operator ordering logic: defaulting num_schedulable_nodes to 0 instead of None incorrectly prioritizes operators with unknown eligibility over highly constrained ones. To preserve the 'scarcity first' principle, it is recommended to revert this field to Optional[int], update the sorting key to handle None as infinite, and restore the corresponding test cases.

@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 data Ray Data-related issues release-test release test labels Nov 3, 2026
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/10-cleanup-aftermath branch from c6dbcdc to 14597c2 Compare November 3, 2026 20:09

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

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/10-cleanup-aftermath branch 2 times, most recently from 40fa403 to f406bfa Compare November 6, 2026 00:56
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/10-cleanup-aftermath branch 2 times, most recently from 909a569 to bc4d1ed Compare November 6, 2026 04:17

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

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/10-cleanup-aftermath branch 2 times, most recently from 2292e20 to 5819607 Compare November 10, 2026 19:01

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

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/10-cleanup-aftermath branch from 5819607 to b7de3b7 Compare November 10, 2026 21:09

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

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/10-cleanup-aftermath branch from b7de3b7 to b199a6e Compare November 12, 2026 17:04

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

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/10-cleanup-aftermath branch 2 times, most recently from a2fbf79 to 6339405 Compare November 13, 2026 22:36

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

# of closing is thrashing the same capacity back and forth.
recent_transfers: Deque[RecentTransfer] = field(
default_factory=lambda: deque(maxlen=8)
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thrash window dropped after eight transfers

Low Severity

inverted_by is supposed to refuse an inverse transfer for THRASH_WINDOW_S after close, but recent_transfers is still a deque(maxlen=8). A ninth transfer evicts an earlier record even if it closed inside the window, so A→B then B→A can proceed before the configured ticks have elapsed.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6339405. Configure here.

@rayhhome rayhhome self-assigned this Nov 16, 2026
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/10-cleanup-aftermath branch from 6339405 to 8390ae8 Compare November 17, 2026 23:54

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

There are 2 total unresolved issues (including 1 from previous review).

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 8390ae8. Configure here.

"""
self._record_transfer_pendings(state)
self._close_finished_transfers(ctx, state)
self._hold_owed_capacity(ctx, state)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timeout preempts same-tick placement

Medium Severity

advance closes timed-out transfers before _hold_owed_capacity can place on newly freed slots. A donor that finishes draining after SIZER_TRANSFER_TIMEOUT_S loses the transfer on the tick the recipient could finally be brought up, and the hold is dropped so another operator can take that capacity.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 8390ae8. Configure here.

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.

Nit and not blocking: I guess this could be an improvement, but only for the rare case when a donor finishes draining on the tick the 60s timer runs out. One way of addressing this is to split the timeout check out of _close_finished_transfers and move it below this line _hold_owned_capacity.

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/10-cleanup-aftermath branch from 8390ae8 to 349796c Compare November 19, 2026 00:41
@richardliaw
richardliaw force-pushed the iamjustinhsu/ao/10-cleanup-aftermath branch from 349796c to 51a8e42 Compare November 19, 2026 19:52
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/10-cleanup-aftermath branch 3 times, most recently from b5f7508 to 9bda5ab Compare November 19, 2026 23:22
Sizer follow-ups:
- Open capacity transfers hold the capacity they're still owed against
  free capacity, so another op can't take it before the recipient
  scales up.
- A transfer that would undo a recent one is refused as thrashing for
  RAY_DATA_SIZER_TRANSFER_THRASH_WINDOW_TICKS ticks (default 20).
- Warmup ends after at most RAY_DATA_SIZER_WARMUP_TIMEOUT_S (default
  300s) even if a critical op never produces output.
- Initial-sizing order: below-min ops go first, but the scarcity tiers
  (label, placement group, GPU) still apply within that group, so
  constrained ops are placed before unconstrained ones at startup.
- heterogeneous_memory_batch_inference requests num_cpus=1 for its GPU
  stage, and the GPU nodes in its compute configs (single-tenant and
  multitenancy) get CPUs.

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]>
@richardliaw
richardliaw force-pushed the iamjustinhsu/ao/10-cleanup-aftermath branch from 9bda5ab to 155d334 Compare November 19, 2026 23:23

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

Approved with a few non-blocking comments!

else:
pool._release_running_actor(actor)
assert pool.get_resource_requests() == []
def test_output_backpressured_actors_counts_serving_actors_only():

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.

This is failing pre_commit and needs two blank lines before it.

"""
self._record_transfer_pendings(state)
self._close_finished_transfers(ctx, state)
self._hold_owed_capacity(ctx, state)

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.

Nit and not blocking: I guess this could be an improvement, but only for the rare case when a donor finishes draining on the tick the 60s timer runs out. One way of addressing this is to split the timeout check out of _close_finished_transfers and move it below this line _hold_owned_capacity.

# The GPU nodes have CPUs for the GPU stage's actors; keep the CPU stages
# on the small-memory CPU nodes this test is about. Merged with the
# tenant's subcluster selector, if any.
cpu_nodes = {"node-pool": "cpu"}

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.

Should we add this selector to the random_shuffle above (line 129)? I think it aligns with the purpose of this test by preventing unlabelled CPU work landing on the GPU nodes.

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 release-test release test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants