Repository navigation
[data][actor-only][7/n] Operator sizer + sizer metrics - #67703
iamjustinhsu wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a robust, multi-phase actor-pool sizing and placement system (OperatorSizer) for Ray Data's actor-only backend. It implements cross-operator optimization rules (such as capacity transfers and silent bottleneck grants), locality-first actor placement, constraint-aware capacity tracking, and comprehensive telemetry. The changes are integrated into the streaming executor and backed by extensive unit and end-to-end tests. One code improvement was suggested to directly access op.op_tag() instead of retrieving it via the topology state mapping, which is safer and more direct.
| ): | ||
| for op, r in placed.items(): | ||
| self._metrics.record_actor_delta( | ||
| operator=topology[op].op_tag(), phase=phase, delta=r.delta |
There was a problem hiding this comment.
Using topology[op].op_tag() is less direct and potentially unsafe if OpState (the value type of topology) does not expose op_tag(). Since op itself is the ExperimentalActorPoolMapOperator instance (which inherits from PhysicalOperator and has op_tag()), you can directly call op.op_tag() instead.
| operator=topology[op].op_tag(), phase=phase, delta=r.delta | |
| operator=op.op_tag(), phase=phase, delta=r.delta |
6dd155f to
bdc65af
Compare
bdc65af to
79a04bc
Compare
2b3e6de to
e50e09f
Compare
e50e09f to
9a30fe9
Compare
9a30fe9 to
b1cf8b1
Compare
b1cf8b1 to
43ec0e7
Compare
43ec0e7 to
a89460c
Compare
| force=True, | ||
| reason=f"optimizer: donate to {recipient.name}", | ||
| victim_node=node_plan.node, | ||
| ) |
There was a problem hiding this comment.
Transfer evicts the wrong victims
High Severity
Capacity transfer plans exact victims, including pending actors and only those that free a resource the recipient still lacks, then fires a victim_node downscale that discards those ids. Apply-time picking looks only at running actors on the node and takes the cheapest drain, so pending claims stay, CPU actors can be shed for a GPU recipient, and the new actors may never fit.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit a89460c. Configure here.
a89460c to
fc2e552
Compare
| for op, count in node_plan.victims_by_donor().items(): | ||
| donor = donors_by_op[op] | ||
| donor.removable = max(0, donor.removable - count) | ||
| _consume_victims_from_view(donor.view, node_plan.node, count) |
There was a problem hiding this comment.
Donor view consumed by count
Medium Severity
After a transfer fires, _consume_victims_from_view drops the first N pending then running actors on the node rather than the actor ids the plan actually took. Candidates skipped by _frees_short_dim still occupy those prefix slots, so a later recipient in the same tick can reuse already-claimed victims or see the wrong remaining surplus.
Reviewed by Cursor Bugbot for commit fc2e552. Configure here.
107f55d to
5cf9408
Compare
ayushk7102
left a comment
There was a problem hiding this comment.
Just tracking some divergences from our benchmark branch, which I want to make sure we double-check
| pool = op.actor_pool | ||
| return max(1, math.ceil(self.upscale_factor * pool.serving_size())) | ||
|
|
||
| def growth_delta(self, op: "ExperimentalActorPoolMapOperator") -> int: |
There was a problem hiding this comment.
This drops the backlog cap from the earlier revision, so the silent-bottleneck step is now limited only by max size. The reasoning in the docstring makes sense to me (upstream backpressure keeps the bottleneck's queue shallow). Can we confirm this is intended and not just a response to Bugbot? The two growth paths now diverge, and the old docstring said they matched on purpose.
| continue | ||
| # A silent bottleneck's output-blocked actors look like surplus, | ||
| # but it is what limits the pipeline: grow it, never drain it. | ||
| if SilentBottleneckGrant.is_silent_bottleneck(op, ctx): |
There was a problem hiding this comment.
Excluding silent bottlenecks as donors looks right to me. Since this came in through the Bugbot thread with no discussion, could someone who owns the optimizer confirm the behavior?
| pool = op.actor_pool | ||
| return max(1, math.ceil(self.upscale_factor * pool.serving_size())) | ||
|
|
||
| def growth_delta(self, op: "ExperimentalActorPoolMapOperator") -> int: |
There was a problem hiding this comment.
Divergence 1: growth_delta is capped at pool_cap, not backlog_actor_target (the op_state param is gone).
There was a problem hiding this comment.
Intended, so basically this affects silient bottleneck. A silent bottleneck is an operator that is bottlenecked (needs more actors), however, it does not because of how the code is written (it's considered as a special case, not a normal case in the control flow). Silent bottlneck operators have shallow queues, typically run very long per task, and has backpressured actors. In this case, if we use backlog_actor_target, the "backlog" refers to the ongoing tasks + queue, and that value for backlog_actor_target will typically be less than serving size.
That's just theory, but i'll run benchmarks later to confirm this
| capacity=ctx.capacity, | ||
| profiles=self._profiles, | ||
| growth_delta={ | ||
| op: self._policy.growth_delta(op) |
There was a problem hiding this comment.
Divergence 2: call site is growth_delta(op), not growth_delta(op, self._topology[op]).
There was a problem hiding this comment.
related to divergence 1
| return requests | ||
|
|
||
| @classmethod | ||
| def is_silent_bottleneck( |
There was a problem hiding this comment.
Divergence 3: _is_silent_bottleneck became the public @classmethod is_silent_bottleneck; the growth_delta > 0 check is no longer inside it.
There was a problem hiding this comment.
related to divergence 1
| for op in ctx.actor_pool_ops: | ||
| if not self._guard.can_scale(op) or op.actor_pool.num_pending_actors() > 0: | ||
| continue | ||
| if ctx.growth_delta.get(op, 0) <= 0 or not self.is_silent_bottleneck( |
There was a problem hiding this comment.
Divergence 3 (cont.): the growth_delta > 0 check moved here into apply().
There was a problem hiding this comment.
related to divergence 1
| continue | ||
| # A silent bottleneck's output-blocked actors look like surplus, | ||
| # but it is what limits the pipeline: grow it, never drain it. | ||
| if SilentBottleneckGrant.is_silent_bottleneck(op, ctx): |
There was a problem hiding this comment.
Divergence 4: _collect_donors skips silent bottlenecks.
| OptimizationRule, | ||
| ) | ||
| from ray.data._internal.experimental.execution.sizer.optimizer.silent_bottleneck import ( # noqa: E501 | ||
| SilentBottleneckGrant, |
There was a problem hiding this comment.
Divergence 4 (cont.): new SilentBottleneckGrant import to support the donor exclusion.
There was a problem hiding this comment.
intended, a capacity transfer means we will downscale an operator's actors to create headroom for another operator to upscale. To identify a donor, we go through multiple checks, and one silent bottlenecks
| pytest.param(dict(max_size=10, running=10), 0, id="at-max-size"), | ||
| ], | ||
| ) | ||
| def test_silent_bottleneck_growth_delta_ignores_backlog(pool_kwargs, expected): |
There was a problem hiding this comment.
Divergence 5: new test test_silent_bottleneck_growth_delta_ignores_backlog (covers Divergence 1).
There was a problem hiding this comment.
related to div 1
|
|
||
|
|
||
| @pytest.mark.parametrize("bottleneck", [True, False], ids=["bottleneck", "not"]) | ||
| def test_capacity_transfer_never_drains_a_silent_bottleneck(bottleneck): |
There was a problem hiding this comment.
Divergence 6: new test test_capacity_transfer_never_drains_a_silent_bottleneck (covers Divergence 4).
There was a problem hiding this comment.
related to div 4
5cf9408 to
28dca40
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
There are 3 total unresolved issues (including 2 from previous reviews).
❌ 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 28dca40. Configure here.
| if limit.all_fields_gt(usage): | ||
| return True | ||
| # Nothing is working, so nothing is stalled. | ||
| return not working |
There was a problem hiding this comment.
Output budget ignores stalled idle actors
Medium Severity
has_enough_budget_for_prebuffered_outputs skips every actor with num_tasks_in_flight == 0. An actor that already finished its tasks and is sitting at its output cap is treated as not stalled, and if no other actor is in flight the method reports enough budget. The escape hatch then never raises the cap, so a completed-task output deadlock can persist.
Reviewed by Cursor Bugbot for commit 28dca40. Configure here.
28dca40 to
653d1cd
Compare
28dca40 to
87a3441
Compare
## Overview Add the operator sizer which handles sizing (answers the question: how many actors of each operator should be running every tick) and placement (where to scale up new actors, which actor to downscale). the sizing path is largely broken down into: - scale_how_many() -> responsible for per operator greedy sizing decisions (looks at individual operators not the topology as a whole) - scale_where() -> responsible for placement - optimize() -> takes a more wholistic view of the topology before making key sizing decisions, currently supports two rules - capacity transfer: when we have reached max cluster capacity (cluster can no longer scale up) we might run into a scenario where both a producer (upstream) and consumer (downstream) op have a large backlog. the producer is bottlnecked by the downstream consumer but greedy op local sizing decisions tries to scale both op's but gets stuck due to lack of resources. in these scenarios, unused capacity of upstream op's is transfered to downstream ops via a cross tick (undisturbed) donor scale down followed by the bottle neck op scale up - an op may be output back pressured (so greedy sizing would suggest making no changes for the op) but its downstream is keeping up with its production speed, in this case the upstream op should scale up as all its outputs are being promptly consumed this pr also adds some new dashboards specific to sizing and placement. ## Glossary ### Capacity - **reserved** This dataset's slice of each node, as the autoscaling coordinator hands it out (`DatasetAllocationView`). - **committed** What our non-PG actors hold on a node: running actors plus pending actors at their target node. - **free** `reserved - committed`, per node. - **schedulable nodes** Nodes an op may run on: its label selector matches, and the slice is large enough for at least one of its actors. - **constrained** An op that can run on only some nodes, either because it has a label selector or requires a GPU. - **nodes to reclaim** Nodes where we hold more than our slice allows, for example because the coordinator shrank the allocation or the node is draining. Actors are evicted there until we fit within the slice. - **PG-managed** An op whose actors are placed through a placement group. The sizer never picks their node. Non-PG ops are placed by the sizer. ### Per-op sizing (`scale_how_many`) - **tick** One sizing evaluation, performed every `SIZER_CADENCE_S`. - **warmup** The first phase of a run. Until every critical op has produced output, there is no backpressure to react to, so each op is sized to an equal share of the allocation. - **has work** Input is queued or tasks are in flight. - **backpressured** The op's output is blocked: enough of its actors have exhausted their output budget (`SIZER_OUTQUEUE_FULL_FRACTION`). - **demand** How many actors the op needs for its current backlog: queued input plus tasks in flight. - **want** The delta an op asks for based on its own signals, before capacity is checked. - **ledger** One tick's free capacity, debited as wants are granted. - **shortfall** How many actors an op asked for but was not granted. - **ungranted** An op that asked to grow and was granted zero actors. ### Cross-op optimization (`optimizer`) - **guard** A lock over ops: while one rule is resizing an op, nothing else touches it. - **keeping up** A consumer that takes its producer's output as fast as it arrives, so it is not what limits the pipeline. - **silent bottleneck** An op that limits the pipeline but never asks to grow: its actors are busy and its output is backpressured, while its consumers keep up. - **capacity transfer** Moving actors from ops with spare actors (donors) to an op whose ask keeps going ungranted (the recipient). - **victim** One donor actor evicted to make room for the recipient. 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]>
Signed-off-by: iamjustinhsu <[email protected]>
9e6bfec to
b9ec19b
Compare
…ator-sizer Signed-off-by: iamjustinhsu <[email protected]>
…ator-sizer Signed-off-by: iamjustinhsu <[email protected]>


Summary
Add the operator sizer. Every tick it decides how many actors each operator should run, and where to add or remove them. It replaces the placeholder from the previous PR, and adds sizing and placement dashboards.
Part 7 of 12 of the Ray Data actor-only backend stack. Stacked on #67702; review only the top commit. Everything here is gated behind
RAY_DATA_ACTOR_ONLY_BACKEND(off by default) unless noted under After.Before
The actor-only scheduling loop has no sizing: pools stay at their initial size.
After
scale_how_many()makes greedy sizing decisions per operator.optimize()applies two whole-topology rules:scale_where()picks nodes for new actors and the actors to shed.ray_remote_args: only label selectors, placement groups, and CPU/GPU/memory are allowed.flowchart TD subgraph Before subgraph BS[Subsystem: resource allocation] subgraph BC[Component: scheduling loop] B1["size (placeholder)"] end end end subgraph After subgraph AS[Subsystem: resource allocation] subgraph AC[Component: operator sizer] A1["scale_how_many (per-op)"] --> A2["optimize (capacity transfer, silent bottleneck)"] --> A3["scale_where (placement)"] end end end class A1,A2,A3 added class B1 removed 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), observability (sizer metrics and dashboards)
Testing
RAY_DATA_ACTOR_ONLY_BACKEND=1 pytest python/ray/data/tests/actor_only: 348 passed. This PR touches no tests outsidetests/actor_only.pre-commit runon changed files: clean.Notes
gh pr list --repo ray-project/ray --state open --search "actor-only").🤖 Generated with Claude Code