Skip to content

[Data] Fix rate-based autoscaler wrong scale-up for custom resources - #66647

Open
dragongu wants to merge 1 commit into
ray-project:masterfrom
dragongu:fix/coordinator-resource-shape-matching
Open

dragongu wants to merge 1 commit into
ray-project:masterfrom
dragongu:fix/coordinator-resource-shape-matching

Conversation

@dragongu

@dragongu dragongu commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Description

The rate-based cluster autoscaler builds its request from each operator's logical ExecutionResources,
which carries only the four standard dimensions — CPU, GPU, memory and object store memory — so it can
express neither custom resources nor labels. Tasks and actors that need different resources are
therefore flattened into one logical shape that carries none of their custom resources. The autoscaler
grows the wrong worker groups, and the work that needs the missing resource stays pending.

This PR requests the exact shape of every in-flight task and actor, reported through a new
PhysicalOperator.get_resource_requests() hook, and scales up only the shapes whose own demand has
crossed its utilization threshold, measured against the worker groups that can host the shape. The
throughput solver's delta and the object-store padding are unchanged.

Scope: custom resources. Labels are left to a separate PR — they keep working through Ray
scheduling and the coordinator's existing interfaces, but they do not take part in the shape grouping
here.

@dragongu
dragongu requested a review from a team as a code owner October 2, 2026 00:08

@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 ResourceRequest class and updates the Ray Data execution operators and the V2 cluster autoscaler to support exact resource shape scaling. Instead of relying on aggregate cluster-wide utilization ratios, the V2 autoscaler can now collect exact resource requests from active tasks and actors across the execution topology, allowing for more precise scaling decisions based on specific resource shapes (including custom resources). Comprehensive unit tests have been added to verify the correctness of resource request tracking, aggregator demand reporting, and autoscaler behavior. I have no additional feedback to provide as the implementation is clean and well-tested.

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

Comment thread python/ray/data/_internal/cluster_autoscaler/default_cluster_autoscaler_v2.py Outdated
Comment thread python/ray/data/_internal/execution/interfaces/physical_operator.py Outdated
@dragongu
dragongu force-pushed the fix/coordinator-resource-shape-matching branch from 952cfa6 to fef13fe Compare October 2, 2026 00:38
@ray-gardener ray-gardener Bot added data Ray Data-related issues community-contribution Contributed by the community labels Oct 2, 2026
@dragongu
dragongu force-pushed the fix/coordinator-resource-shape-matching branch from fef13fe to dffe0c9 Compare October 2, 2026 10:37

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

Comment thread python/ray/data/_internal/cluster_autoscaler/default_cluster_autoscaler_v2.py Outdated
Comment thread python/ray/data/_internal/cluster_autoscaler/default_cluster_autoscaler_v2.py Outdated
@dragongu
dragongu force-pushed the fix/coordinator-resource-shape-matching branch 2 times, most recently from e9f323f to 6ad6f44 Compare October 3, 2026 01:02
@iamjustinhsu iamjustinhsu self-assigned this Oct 5, 2026

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

Left some initial feedback, will take a look at the rest of the files later

Comment thread python/ray/data/_internal/cluster_autoscaler/default_cluster_autoscaler_v2.py Outdated
Comment thread python/ray/data/_internal/cluster_autoscaler/default_cluster_autoscaler_v2.py Outdated
Comment thread python/ray/data/_internal/cluster_autoscaler/default_cluster_autoscaler_v2.py Outdated
Comment thread python/ray/data/_internal/cluster_autoscaler/default_cluster_autoscaler_v2.py Outdated
Comment thread python/ray/data/_internal/cluster_autoscaler/default_cluster_autoscaler_v2.py Outdated
Comment thread python/ray/data/_internal/cluster_autoscaler/default_cluster_autoscaler_v2.py Outdated
Comment thread python/ray/data/_internal/cluster_autoscaler/default_cluster_autoscaler_v2.py Outdated
@dragongu
dragongu force-pushed the fix/coordinator-resource-shape-matching branch from 6ad6f44 to 1993655 Compare October 10, 2026 04:43

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

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 1993655. Configure here.

The rate-based cluster autoscaler built its resource request from each
operator's logical ExecutionResources, which cannot express custom
resources. A task or actor asking for {"CPU": 1, "worker_group_a": 1},
or a GPU task with accelerator_type="A10G", was flattened into a shape
the workload never uses, and different shapes from one operator were
mixed into a single bundle. The autoscaler therefore grew the wrong
worker groups: the groups providing the custom resource never grew, and
the batches that needed them stayed unscheduled while the request named
nodes the workload cannot use.

Build the request from the exact resource request of every in-flight
task and actor, reported through a single
PhysicalOperator.get_resource_requests() hook, and scale up only the
shapes whose demand has crossed their utilization threshold, measured
against the worker groups that can host the shape. The throughput
solver's delta and the object-store padding are unchanged.

Also fixes two keep-alive bugs found on the way: demand for
already-finished tasks was kept alive for up to
low_util_request_release_delay_s, and a later scale-up cancelled a copy
that was still inside its window.

Tests: python/ray/data/tests/test_rate_based_cluster_autoscaler.py,
python/ray/data/tests/unit/test_exact_resource_requests.py

Signed-off-by: dragongu <andrewgu@vip.qq.com>
@dragongu
dragongu force-pushed the fix/coordinator-resource-shape-matching branch from 549a6a8 to d00bf84 Compare October 10, 2026 06:48
@dragongu dragongu changed the title [Data] V2 autoscaler: exact resource shapes, custom resources included [Data] Fix rate-based autoscaler wrong scale-up for custom resources Oct 10, 2026

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

community-contribution Contributed by the community data Ray Data-related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants