Skip to content

[data][actor-only][4/n] Actor-only backend: reject unsupported operators and options - #67700

Merged
richardliaw merged 3 commits into
masterfrom
iamjustinhsu/ao/04-reject-unsupported
Nov 19, 2026
Merged

richardliaw merged 3 commits into
masterfrom
iamjustinhsu/ao/04-reject-unsupported

Conversation

@iamjustinhsu

Copy link
Copy Markdown
Contributor

Summary

Under the actor-only backend, reject topologies that contain all-to-all, shuffle, join or zip operators, or that set preserve_order=True. These fail with a clear error as soon as the topology is built instead of stalling mid-run.

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

Before

Nothing stops an unsupported operator from running under the flag. It schedules its own tasks, which the actor-only backend can't account for.

After

With the flag on, StreamingExecutor.execute calls validate_actor_only_supported_topology right after build_streaming_topology. Operators are checked before preserve_order, so Zip and Sort (which force preserve_order=True) report the operator as the cause. With the flag off, nothing changes.

flowchart TD
    subgraph Before
        subgraph BS[Subsystem: execution]
            subgraph BC[Component: StreamingExecutor.execute]
                B1[build_streaming_topology] --> B2[run]
            end
        end
    end
    subgraph After
        subgraph AS[Subsystem: execution]
            subgraph AC[Component: StreamingExecutor.execute]
                A1[build_streaming_topology] --> A3["validate_actor_only_supported_topology (flag on)"] --> A2[run]
            end
        end
    end
    class A3 added
    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

execution (flag-gated)

Testing

  • RAY_DATA_ACTOR_ONLY_BACKEND=1 pytest python/ray/data/tests/actor_only: 67 passed, including test_topology_validation.py.
  • 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 marked this pull request as ready for review November 2, 2026 21:14
@iamjustinhsu
iamjustinhsu requested a review from a team as a code owner November 2, 2026 21:14
@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 topology validation for Ray Data's actor-only backend, preventing deadlocks by rejecting unsupported shuffle/all-to-all operators and execution options (such as preserve_order) early in the execution lifecycle. The feedback suggests optimizing this validation by running it before building the streaming topology and starting operators, which can be achieved by traversing the physical operator DAG using post_order_iter(). Additionally, adding an autouse fixture to the test suite is recommended to ensure the tests are self-contained and do not rely on external environment variables.

Comment on lines +326 to +335
if actor_only_backend_enabled():
# Reject shuffle / all-to-all ops and unsupported options here,
# while the topology is still just a plan: the actor-only backend
# has no implementation for them and would otherwise stall midway.
from ray.data._internal.experimental.execution.topology_validation import (
validate_actor_only_supported_topology,
)

validate_actor_only_supported_topology(self._topology, self._options)

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

To avoid starting operators and allocating resources (which happens during build_streaming_topology when op.start() is called) for a topology that is destined to be rejected, we should perform this validation before building the topology.

Please move this validation block to run before build_streaming_topology (around line 318) and pass dag instead of self._topology.

        # Validation moved before build_streaming_topology

Comment on lines +42 to +66
def validate_actor_only_supported_topology(
topology: "Topology", options: ExecutionOptions
) -> None:
"""Reject configs / operators the actor-only backend cannot run.

Args:
topology: The built streaming topology, iterated for physical operators.
options: The execution options this run was configured with.

Raises:
ValueError: If ``preserve_order`` is set, or the topology contains an
operator the actor-only backend cannot execute.
"""
# Operators first: plans that require ordering (Zip, Sort) have
# ``preserve_order`` forced on by ``Dataset._execute``, so checking the
# option first would report "preserve_order" for an operator that is itself
# the unsupported thing, hiding the real reason.
for op in topology:
if isinstance(op, _UNSUPPORTED_ACTOR_ONLY_OPS):
raise ValueError(
f"{type(op).__name__} is not supported when actor only "
"backend is enabled"
)
if options.preserve_order:
raise ValueError("preserve_order=True is not supported for actor only backend")

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

Update validate_actor_only_supported_topology to accept the root PhysicalOperator (dag) instead of the built Topology, and traverse it using dag.post_order_iter(). This allows us to validate the topology before starting any operators or allocating resources.

def validate_actor_only_supported_topology(
    dag: PhysicalOperator,
    options: ExecutionOptions,
) -> None:
    """Reject configs / operators the actor-only backend cannot run.

    Args:
        dag: The physical operator DAG, iterated for physical operators.
        options: The execution options this run was configured with.

    Raises:
        ValueError: If ``preserve_order`` is set, or the topology contains an
            operator the actor-only backend cannot execute.
    """
    # Operators first: plans that require ordering (Zip, Sort) have
    # ``preserve_order`` forced on by ``Dataset._execute``, so checking the
    # option first would report "preserve_order" for an operator that is itself
    # the unsupported thing, hiding the real reason.
    for op in dag.post_order_iter():
        if isinstance(op, _UNSUPPORTED_ACTOR_ONLY_OPS):
            raise ValueError(
                f"{type(op).__name__} is not supported when actor only "
                "backend is enabled"
            )
    if options.preserve_order:
        raise ValueError("preserve_order=True is not supported for actor only backend")

@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/04-reject-unsupported branch 2 times, most recently from 5bd2234 to 55cde81 Compare November 3, 2026 23:10

@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/04-reject-unsupported branch from 55cde81 to 9fc235a Compare November 6, 2026 00:57
@richardliaw
richardliaw force-pushed the iamjustinhsu/ao/04-reject-unsupported branch from 9fc235a to d9b6585 Compare November 6, 2026 19:59
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/04-reject-unsupported branch from d9b6585 to 6e2df0c Compare November 6, 2026 20:34

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

Just one thing to double check:

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/04-reject-unsupported branch from 6e2df0c to c326192 Compare November 10, 2026 19:01
@rayhhome

Copy link
Copy Markdown
Contributor

We would also need to deny the Disk-based shuffle operators: #67700 (comment)

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/04-reject-unsupported branch from c326192 to 42f89e1 Compare November 12, 2026 17:04
Base automatically changed from iamjustinhsu/ao/03-fusion to master November 17, 2026 02:01
@richardliaw
richardliaw force-pushed the iamjustinhsu/ao/04-reject-unsupported branch from 7c8ee75 to 44c8bfe Compare November 17, 2026 02:01
@richardliaw
richardliaw enabled stacked auto-merge (squash) November 17, 2026 02: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.

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 44c8bfe. Configure here.

GPUShuffleOperator,
DiskHashShuffleMapOp,
DiskHashShuffleReduceOp,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

TopN merge operator not rejected

Medium Severity

_UNSUPPORTED_ACTOR_ONLY_OPS omits TopNMergeOperator. When TopN rewrite is on under SHUFFLE_V2, sort().limit() becomes a local MapOperator plus TopNMergeOperator, which submits its own merge tasks via cached_remote_fn and is not an AllToAllOperator or shuffle op. That topology passes validation and can stall mid-run, which this check is meant to prevent.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 44c8bfe. Configure here.

@richardliaw

Copy link
Copy Markdown
Contributor

premerge failing

iamjustinhsu and others added 2 commits November 18, 2026 21:48
…ors and options

The actor-only backend runs every operator on an actor pool, so the
shuffle / all-to-all operators, which schedule their own tasks, have no
implementation under it. Reject them once the topology is built rather
than stalling partway through execution.

`validate_actor_only_supported_topology` rejects AllToAllOperator,
HashShuffleOperator, HashAggregateOperator, JoinOperator, ShuffleMapOp,
ShuffleReduceOp and ZipOperator, plus `preserve_order=True`.
`StreamingExecutor.execute` calls it right after
`build_streaming_topology`, gated on `actor_only_backend_enabled()`, so
the default path is untouched.

Operators are checked before the `preserve_order` option on purpose:
`Dataset._execute` forces `preserve_order=True` for plans that require
ordering (Zip, Sort), so checking the option first reports
"preserve_order" for an operator that is itself the unsupported thing
and hides the real reason.

The validation lives under `_internal/experimental/execution/` so the
actor-only streaming executor can take it over when it lands; it is a
free function rather than a method for that reason.

Test: pytest python/ray/data/tests/actor_only (67 passed, including all
13 of test_disabled_configs.py). With the flag off, zip / sort /
random_shuffle still execute normally.
AI assistance was used for this change.

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]>
Signed-off-by: iamjustinhsu <[email protected]>
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/04-reject-unsupported branch from 44c8bfe to 936c1f7 Compare November 19, 2026 00:41
@github-actions
github-actions Bot disabled stacked auto-merge November 19, 2026 00:41
@richardliaw
richardliaw merged commit 017949a into master Nov 19, 2026
6 checks passed
@richardliaw
richardliaw deleted the iamjustinhsu/ao/04-reject-unsupported branch November 19, 2026 19:52
richardliaw pushed a commit that referenced this pull request Nov 19, 2026
…r only backend (#67701)

## Summary
Add `ExperimentalActorPoolMapOperator` and its actor pool, which the
actor-only backend will use. It is kept separate from
`ActorPoolMapOperator`, so the classic path barely changes. Nothing uses
it until the next PR.

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

## Before
Only the classic actor pool exists. It has no graceful drain, no
per-actor input/output backpressure, and no way to scale up on a chosen
node or scale down a chosen actor.

## After
- The new pool and operator (not wired in yet) add:
  - graceful draining of actors that are running tasks;
  - `ResourceBank` integration;
- per-actor input admission: a small task floor per slot, then an
input-bytes cap;
- output backpressure enforced while consuming each actor's stream,
using core actor generator backpressure;
  - downscaling of specific actors and upscaling on specific nodes;
  - `num_cpus=1` when `num_gpus>0` and `num_cpus=0`.
- **Shared code, all backends:**
  - pool accounting tells serving actors from draining ones;
  - `launch_task` / `TaskPullRequest` hooks for pull-based dispatch;
  - `generator_backpressure_disabled`;
  - Grafana panels for cross-node input transfer and actor draining;
- `DataContext._actor_only_backend_override`, which lets internal
datasets such as checkpoint loaders run on the classic backend.

```mermaid
flowchart TD
    subgraph Before
        subgraph BS[Subsystem: execution]
            subgraph BC[Component: map operators]
                B1[ActorPoolMapOperator] --> B2[_ActorPool]
            end
        end
    end
    subgraph After
        subgraph AS[Subsystem: execution]
            subgraph AC[Component: map operators]
                A1[ActorPoolMapOperator] --> A2["_ActorPool (serving vs draining)"]
                A3[ExperimentalActorPoolMapOperator] --> A4["experimental ActorPool (drain, per-actor backpressure, targeted scaling)"]
                A1 -.subclass.-> A3
            end
        end
    end
    class A3,A4 added
    class 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
```
## Subsystems
execution (new operator, not wired yet), resource allocation /
backpressure (per-actor admission and output backpressure),
observability (dashboard panels)

## Testing
Each run used a clean checkout of this branch. Any test that failed was
rerun on unmodified `master` in the same environment; only failures that
pass on master count as regressions.

- `RAY_DATA_ACTOR_ONLY_BACKEND=1 pytest
python/ray/data/tests/actor_only`: 152 passed.
- `pytest python/ray/data/tests/test_actor_autoscaler.py
test_actor_pool_map_operator.py test_backlog_aware_actor_autoscaler.py
test_node_aware_actor_pool.py
unit/test_draining_actor_priority_bundle_queue.py test_map.py
test_stats.py test_streaming_executor.py`: 536 passed, 20 failed. 19
fail identically on master. The 20th
(`test_map.py::test_downstream_operators_scheduled_on_different_workers_than_read_workers`)
passed 3 out of 3 reruns on this branch and on master, so it was a load
flake.
- `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](https://claude.com/claude-code)

---------

Signed-off-by: iamjustinhsu <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: sampan <[email protected]>
Co-authored-by: Prasad Palkar <[email protected]>
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.

3 participants