Skip to content

[autoscaler][Data] Accept fractional resource values in request_resources - #63306

Merged
justinvyu merged 8 commits into
ray-project:masterfrom
liulehui:relax-int-constraint
May 14, 2026
Merged

justinvyu merged 8 commits into
ray-project:masterfrom
liulehui:relax-int-constraint

Conversation

@liulehui

Copy link
Copy Markdown
Contributor

Description

#59353 open-sourced the AutoscalingCoordinator including a math.ceil block on incoming resource bundles. The block traces back to that validator was added back in #26626 to fix a shape bug (#23166 ). The literal int came from an informal type annotation;
It seems that neither v1 (KV → load_metrics → bin-packing) nor v2 (proto map<string, double>) requires it.

Drop the value-type check in the SDK and remove the math.ceil workaround in Ray Data

Related issues

Related to #63241

Additional information

Submitting a Ray Train job with fractional CPU, see full repro script here: https://gist.github.com/liulehui/6d2548f0ff85e7e19f7908b46b224280

TorchTrainer(
    train_fn,
    scaling_config=ScalingConfig(
        num_workers=10,
        resources_per_worker={"CPU": 0.1},
    ),
)

before the change:

(autoscaler +11s) Adding 10 node(s) of type worker_pool.
(autoscaler +11s) Resized to 10 CPUs.
total_CPU_demanded=10.0
(autoscaler) Adding 10 node(s) of type worker_pool.

after the change:

(autoscaler +10s) Adding 1 node(s) of type worker_pool.
(autoscaler +10s) Resized to 1 CPUs.
total_CPU=1.0

@liulehui
liulehui requested review from a team as code owners May 12, 2026 18:19
@liulehui liulehui added the go add ONLY when ready to merge, run all tests label May 12, 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 enables support for fractional resource requests in the autoscaler by allowing float values in resource bundles and removing the rounding logic in the autoscaling coordinator. The feedback identifies several areas for improvement: the num_cpus parameter should be updated to accept floats for consistency, resource values should be validated as non-negative to prevent issues with NaN or negative inputs, and the reallocation logic needs to be updated from floor division to true division to avoid truncating fractional resources. Additionally, it is recommended to expand test coverage to explicitly verify that booleans are rejected and floats are accepted.

Comment thread python/ray/autoscaler/sdk/sdk.py Resolved
Comment thread python/ray/autoscaler/sdk/sdk.py Resolved
Comment thread python/ray/tests/test_autoscaler.py Resolved
Signed-off-by: Lehui Liu <[email protected]>
@ray-gardener ray-gardener Bot added core Issues that should be addressed in Ray Core data Ray Data-related issues labels May 12, 2026

@bveeramani bveeramani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Data changes LGTM

Signed-off-by: Lehui Liu <[email protected]>

@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 53cc949. Configure here.

Comment thread python/ray/tests/test_autoscaler.py Resolved
liulehui added 2 commits May 13, 2026 13:33
Signed-off-by: Lehui Liu <[email protected]>
Signed-off-by: Lehui Liu <[email protected]>
@liulehui
liulehui requested a review from Kunchd May 13, 2026 20:35
Comment thread python/ray/tests/test_autoscaler.py Resolved
@liulehui
liulehui requested a review from Kunchd May 14, 2026 17:43

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

Thank you so much!

@justinvyu
justinvyu merged commit 299ac78 into ray-project:master May 14, 2026
3 checks passed
TruongQuangPhat pushed a commit to cyhapun/ray-fix-issue that referenced this pull request May 27, 2026
…rces (ray-project#63306)

ray-project#59353 open-sourced the `AutoscalingCoordinator` including a `math.ceil`
block on incoming resource bundles. The block traces back to that
validator was added back in ray-project#26626 to fix a *shape* bug (ray-project#23166 ). The
literal `int` came from an informal type annotation;
It seems that neither v1 (KV → load_metrics → bin-packing) nor v2 (proto
`map<string, double>`) requires it.

Drop the value-type check in the SDK and remove the `math.ceil`
workaround in Ray Data

---------

Signed-off-by: Lehui Liu <[email protected]>
Signed-off-by: phattruong <[email protected]>
alexandrplashchinsky pushed a commit to alexandrplashchinsky/ray-alex that referenced this pull request May 29, 2026
…rces (ray-project#63306)

ray-project#59353 open-sourced the `AutoscalingCoordinator` including a `math.ceil`
block on incoming resource bundles. The block traces back to that
validator was added back in ray-project#26626 to fix a *shape* bug (ray-project#23166 ). The
literal `int` came from an informal type annotation;
It seems that neither v1 (KV → load_metrics → bin-packing) nor v2 (proto
`map<string, double>`) requires it.

Drop the value-type check in the SDK and remove the `math.ceil`
workaround in Ray Data

---------

Signed-off-by: Lehui Liu <[email protected]>
Signed-off-by: Alexandr Plashchinsky <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues that should be addressed in Ray Core 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.

4 participants