Skip to content

[train] Preserve STRICT_SPREAD in autoscaling resource requests - #66794

Closed
galleonli wants to merge 2 commits into
ray-project:masterfrom
galleonli:fix/strict-spread-autoscaling-demand
Closed

galleonli wants to merge 2 commits into
ray-project:masterfrom
galleonli:fix/strict-spread-autoscaling-demand

Conversation

@galleonli

Copy link
Copy Markdown

Description

Preserve STRICT_SPREAD when the AutoscalingCoordinator forwards resource requests to the autoscaler. Without the placement constraint, four one-GPU workers can be considered satisfied by one eight-GPU node, while Train's reservation still needs four distinct nodes and cannot become ready.

Add a per-requester implicit resource to each forwarded bundle. Both autoscalers treat an implicit resource as having capacity one per node, so bundles from the same requester must use different nodes. Separate requesters can still share nodes when their CPU/GPU requirements fit.

Only the forwarded copies receive this resource. Reservations, worker resources, selectors, and Train's node pinning remain unchanged. Cancellation and expiration remove the constraint with the request.

Related issues

Fixes #66766.

Checked the neighboring Train changes in #66762 and #66763. Those address reservation snapshots and waiting for resources; this change addresses the topology missing from the autoscaling demand, without changing the Train startup path.

Additional information

The new regression cases fail on the unchanged implementation: 5 failed, 8 passed. With this change, the final related-module run passed all 101 tests, including the 13 new cases:

../../envs/ray/bin/python -m pytest -q python/ray/data/tests/test_autoscaling_coordinator.py python/ray/train/v2/tests/test_autoscaling_coordinator_client.py python/ray/train/v2/tests/test_elastic_scaling_policy.py --tb=short --show-capture=no --timeout=40

All applicable pre-commit hooks passed on the two changed files, as did git diff --check before staging. Coverage includes both autoscaler planners, other placement strategies, concurrent requesters, selector preservation, and request cleanup.

A separate local CPU probe also passed the GCS request round trip, V2 planning, fixed/elastic policy readiness, and placement-group tasks on three distinct reserved nodes. Node provisioning and Train client communication were substituted in that probe. Cloud autoscaling, a complete Trainer.fit(), GPU execution, and performance were not tested.

Validation used macOS arm64, Python 3.12.3, and an isolated Ray 3.0.0.dev0 environment with local Python sources at 1a9ba71 plus this patch. The official nightly native wheel is from a8e9860; this was not a source-matched native build.

AI assistance was used for analysis, implementation, regression tests, and drafting this description.

@galleonli
galleonli requested a review from a team as a code owner October 6, 2026 21:30

@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 support for the STRICT_SPREAD resource request strategy in the default autoscaling coordinator by annotating forwarded resource bundles with a unique implicit resource per requester, ensuring the autoscaler schedules them on distinct nodes. It also adds comprehensive unit tests to verify scheduling, resource preservation, and cleanup. The feedback suggests hashing the requester_id when generating the implicit resource name to prevent potential parsing or length issues in the raylet if the ID contains special characters.

Comment on lines +556 to +559
spread_resource = (
f"{ray._raylet.IMPLICIT_RESOURCE_PREFIX}"
f"autoscaling_coordinator_spread_{requester_id}"
)

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

If requester_id contains special characters (such as spaces, slashes, or other non-alphanumeric characters) or is excessively long, it could cause parsing issues or unexpected behavior in the autoscaler or raylet when used directly as part of a resource name. To ensure robustness, consider hashing the requester_id (e.g., using MD5) to guarantee a safe, alphanumeric, and fixed-length resource name.

                import hashlib
                hashed_id = hashlib.md5(requester_id.encode("utf-8")).hexdigest()
                spread_resource = (
                    f"{ray._raylet.IMPLICIT_RESOURCE_PREFIX}"
                    f"autoscaling_coordinator_spread_{hashed_id}"
                )

@ray-gardener ray-gardener Bot added the community-contribution Contributed by the community label Oct 7, 2026
@pseudo-rnd-thoughts pseudo-rnd-thoughts added train Ray Train Related Issue go add ONLY when ready to merge, run all tests data Ray Data-related issues labels Oct 13, 2026
Signed-off-by: Mark Towers <[email protected]>
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

You can always ask for help on our discussion forum or Ray's public slack channel.

If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Oct 28, 2026
@pseudo-rnd-thoughts

Copy link
Copy Markdown
Member

Thanks for the fix, while it looks good, I've reverted #66002 for the time being. Therefore, I'll close this and might reopen in the future

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 go add ONLY when ready to merge, run all tests stale The issue is stale. It will be closed within 7 days unless there are further conversation train Ray Train Related Issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Train] STRICT_SPREAD runs can wait forever when the autoscaler packs coordinator bundles onto one node

2 participants