Skip to content

[data][actor-only][5/n] Experimental actor pool map operator for actor only backend - #67701

Merged
richardliaw merged 2 commits into
masterfrom
iamjustinhsu/ao/05-actor-pool-op
Nov 19, 2026
Merged

richardliaw merged 2 commits into
masterfrom
iamjustinhsu/ao/05-actor-pool-op

Conversation

@iamjustinhsu

Copy link
Copy Markdown
Contributor

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

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

@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:15
@iamjustinhsu
iamjustinhsu requested a review from a team as a code owner November 2, 2026 21:15

@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 the actor-only backend for Ray Data, implementing an experimental actor pool and map operator that support pull-based dispatch, per-actor input/output budgets, and spot-preemption node draining. Key feedback includes importing the missing Any type in actor_pool.py, adding defensive defaults to prevent TypeError when optional ExecutionResources fields (such as cpu and object_store_memory) are None, and gracefully handling None values for actor_id in actor_pool_map_operator.py to avoid executor crashes.

@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/05-actor-pool-op branch from 33454e6 to d771820 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/05-actor-pool-op branch 2 times, most recently from 2c9cd3a to 1c8ee5c Compare November 6, 2026 00:57

@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/05-actor-pool-op branch 2 times, most recently from 86d6139 to e734a10 Compare November 10, 2026 19:01
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/05-actor-pool-op branch from e734a10 to c898783 Compare November 10, 2026 21:09

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

A few comments:

exception or task_exec_driver_stats
), "Driver's task execution stats must be provided on task's successful completion"

inputs = self._metrics._running_tasks[task_index].inputs

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.

I think we don't need this line here because we already have inputs's value in the closure at this point and the value is the same.

MIN_ACTORS_LOG_INTERVAL_S: float = 30.0

def __init__(self, *args, **kwargs):
self._user_set_ray_remote_args: Dict[str, Any] = dict(

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.

Here, self._user_set_ray_remote_args and self._user_set_ray_remote_args_fn are read with kwargs.get, which assumes callers pass them by keyword. But in ActorPoolMapOperator, the constructor declares them as ordinary parameters, so they can also be passed by position:

class ActorPoolMapOperator(MapOperator, ReportsExtraResourceUsage):
...
    def __init__(
        self,
        ...,
        ray_remote_args_fn: Optional[Callable[[], Dict[str, Any]]] = None,
        ray_remote_args: Optional[Dict[str, Any]] = None,
        ...
    ):
    ...

This means if a future caller passes them by position, they will land in *args. ExperimentalActorPoolMapOperator's local copy will misalign with what its superclass (ActorPoolMapOperator) owns. Everything is wired correctly today, but it might be better to make this explicit so it's foolproof.

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/05-actor-pool-op branch from c898783 to 123b8cb 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.

parts.append(f"blocked={blocked}/{self.actor_pool.current_size()}")
if not parts:
return ""
return f"[{', '.join(parts)}]"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Progress bar uses wrong actor count

Low Severity

backpressure_progress_str reports blocked over current_size(), but cached_output_backpressured_actors already returns (blocked, running). current_size includes pending and draining actors, so the fraction does not match the share of serving actors that cannot emit, which is what the docstring describes.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 123b8cb. 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.

This would result in underreporting from [10/n] on and should be quite easy to fix. Not blocking though.

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/05-actor-pool-op branch from 94a6edc to a11697e Compare November 13, 2026 22:36

@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! Cursor's reports are non-blocking but are probably worth fixing.

parts.append(f"blocked={blocked}/{self.actor_pool.current_size()}")
if not parts:
return ""
return f"[{', '.join(parts)}]"

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 would result in underreporting from [10/n] on and should be quite easy to fix. Not blocking though.

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/05-actor-pool-op branch from a11697e to 8308eae Compare November 19, 2026 00:41

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

continue
if not self._actor_pull_budget(actor_id).all_fields_gt(zeros):
blocked += 1
result = (blocked, info.running)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Draining actors inflate backpressure counts

Medium Severity

output_backpressured_actors walks get_logical_ids() and counts any actor has_actor still knows about, including draining ones, but reports the denominator as info.running, which excludes draining actors. Draining actors usually sit at an exhausted pull budget, so blocked can exceed running. backpressure_progress_str then ignores that running count and divides by current_size, and it also drops the base class's task-submission backpressure tag. Idle detection and the sizer that refresh this cache will treat a draining pool as fully output-blocked.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 8308eae. Configure here.

cpu=self._ray_remote_args.get("num_cpus"),
gpu=self._ray_remote_args.get("num_gpus"),
memory=self._ray_remote_args.get("memory"),
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

GPU actors get tiny output budgets

Medium Severity

_apply_default_remote_args never rewrites num_cpus=0 to 1 when num_gpus>0, and _create_actor_pool_config records cpu from ray_remote_args as-is. Pool output-budget derivation then sees zero CPU, takes the zero-CPU branch, and clamps to the 16MiB floor. GPU map_batches that omit num_cpus (Ray Core still launches them with 1 CPU) therefore run under a far smaller per-actor object-store cap than their real footprint, so generator backpressure will stall GPU actors almost immediately.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 8308eae. Configure here.

Base automatically changed from iamjustinhsu/ao/04-reject-unsupported to master November 19, 2026 19:52
@richardliaw
richardliaw force-pushed the iamjustinhsu/ao/05-actor-pool-op branch from 8308eae to 2c41511 Compare November 19, 2026 19:52

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

f"max_input_bytes_per_actor={self.max_input_bytes_per_actor}, "
f"max_concurrent_calls_per_actor={self.max_concurrent_calls_per_actor}, "
f"max_num_output_bytes_per_actor={self.max_num_output_bytes_per_actor}, "
f"max_num_outputs_per_actor={self.max_num_outputs_per_actor}, "

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Duplicated strategy equality and repr fields

Low Severity

While removing max_input_bytes_per_actor, ActorPoolStrategy.__eq__ and __repr__ still compare and print max_num_output_bytes_per_actor and max_num_outputs_per_actor twice. Equality is unchanged, but __repr__ now emits duplicate fields, which makes logs and debug output misleading and invites later drift if only one copy is updated.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2c41511. Configure here.

@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/05-actor-pool-op branch from 2c41511 to 8308eae Compare November 19, 2026 20:53
iamjustinhsu and others added 2 commits November 19, 2026 20:54
…r only backend

Adds experimental actor pool and actor pool map operator which will be
used when the actor only backend is enabled. We are deliberately keeping
this separate so that when the flag is off the existing path is
minimally affected.

the new actor pool supports:
- gracefully draining of actors running tasks
- integration with the resource bank API's
- support for actor level backpressure
- uses core actor backpressure
(`_actor_generator_backpressure_num_objects`)
- input admission: each actor always admits a small task floor
(max_concurrency x RAY_DATA_PER_ACTOR_INPUT_BACKPRESSURE_MIN_NUM_TASKS,
default 2/slot); beyond the floor, a per-actor input-bytes cap owns
admission. Setting max_tasks_in_flight_per_actor raises
NotImplementedError under this backend.
- dynamically setting output bp for actors and enforcing it during
object consumption from streams
- down scaling specific actors
- upscaling actors on specific nodes
- sets num cpu = 1 when num_gpu > 0 and num_cpu=0.

Not currently used, will be used by subsequent pr's

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]>
@iamjustinhsu
iamjustinhsu force-pushed the iamjustinhsu/ao/05-actor-pool-op branch from 8308eae to 08502e8 Compare November 19, 2026 20:55

@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 5 total unresolved issues (including 4 from previous reviews).

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 08502e8. Configure here.

# pool; the actor-denominated pair reads blocked < running there and
# would disable the hatch at exactly the state it exists for.
blocked, active = self.output_backpressured_fraction()
return blocked == active

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Vacuous output backpressure detection

Medium Severity

is_output_backpressured returns true when every in-flight task is skipped as an orphan (blocked == active == 0). A released actor can leave tasks in _data_tasks that output_backpressured_fraction does not count, so the deadlock hatch can fire even though no live task is blocked on output budget.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 08502e8. Configure here.

@richardliaw
richardliaw merged commit 57635d1 into master Nov 19, 2026
6 checks passed
@richardliaw
richardliaw deleted the iamjustinhsu/ao/05-actor-pool-op branch November 19, 2026 23:23
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