Skip to content

[Data] Allow Early Resource Release Under Sustained Low Utilization for Rate-based Cluster Autoscaler - #66584

Merged
goutamvenkat-anyscale merged 2 commits into
ray-project:masterfrom
rayhhome:rate-based-low-util-release
Sep 30, 2026
Merged

goutamvenkat-anyscale merged 2 commits into
ray-project:masterfrom
rayhhome:rate-based-low-util-release

Conversation

@rayhhome

Copy link
Copy Markdown
Contributor

Description

DefaultClusterAutoscalerV2 releases its resource request under sustained low utilization (for example a straggler tail), so idle nodes can be reclaimed. The rate-based cluster autoscaler lacks this and keeps re-sending its last request
indefinitely, pinning nodes that nothing is using.

This PR strengthens the rate-based cluster autoscaler implementation by adding the same mechanism. On low utilization the autoscaler keeps its last non-empty request alive only for a grace window measured from when that request was sent (RAY_DATA_LOW_UTIL_REQUEST_RELEASE_DELAY_S, default 180s), then sends an empty request that keeps the requester registered but drops the demand. It reuses V2's environment variable and field names.

Related issues

Related to #62592, which added this to DefaultClusterAutoscalerV2. Adding feature to #65954.

Additional information

Also includes unit tests for examining whether the mechanism is behaving correctly. Not a duplicate: no open PR touches rate-based low-utilization release.

@rayhhome rayhhome self-assigned this Sep 29, 2026
Copilot AI balanced review requested due to automatic review settings September 29, 2026 23:06
@rayhhome
rayhhome requested a review from a team as a code owner September 29, 2026 23:06
@rayhhome rayhhome added data Ray Data-related issues go add ONLY when ready to merge, run all tests labels Sep 29, 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 a bounded grace window to the rate-based cluster autoscaler. When cluster utilization drops below the scale-up threshold, the last explicit resource request is kept alive briefly before releasing it with an empty request, allowing idle termination to reclaim nodes. Unit tests have been added to verify this grace period and release behavior. Feedback on the changes suggests avoiding the reassignment of the resource_request parameter in _send_resource_request by using a local variable instead, which improves code readability and maintainability.

Comment on lines +631 to +656
now = self._get_time()
update_non_empty_request_state = True
if resource_request is None:
if self._should_keep_non_empty_request(now):
resource_request = self._last_non_empty_resource_request
update_non_empty_request_state = False
else:
# Renew our registration on AutoscalingCoordinator without
# keeping explicit autoscaler demand alive.
resource_request = []

self._last_resource_request = [r.copy() for r in resource_request]
self._autoscaling_coordinator.request_resources(
resources=[r.copy() for r in resource_request],
expire_after_s=self._autoscaling_request_expire_time_s,
request_remaining=STANDARD_RESOURCE_TYPES,
)
self._last_request_time = time.monotonic()
if resource_request and update_non_empty_request_state:
self._last_non_empty_resource_request = [
bundle.copy() for bundle in resource_request
]
self._last_non_empty_request_time = now
elif not resource_request:
self._last_non_empty_resource_request = []
self._last_non_empty_request_time = None
self._last_request_time = now

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

Reassigning the parameter resource_request can make the code harder to read and maintain, as it obscures the original input value and changes the variable's meaning mid-execution. It is cleaner and less error-prone to use a local variable (e.g., resolved_request) to hold the final request list that is actually sent.

        now = self._get_time()
        update_non_empty_request_state = True
        if resource_request is None:
            if self._should_keep_non_empty_request(now):
                resolved_request = self._last_non_empty_resource_request
                update_non_empty_request_state = False
            else:
                # Renew our registration on AutoscalingCoordinator without
                # keeping explicit autoscaler demand alive.
                resolved_request = []
        else:
            resolved_request = resource_request

        self._last_resource_request = [r.copy() for r in resolved_request]
        self._autoscaling_coordinator.request_resources(
            resources=[r.copy() for r in resolved_request],
            expire_after_s=self._autoscaling_request_expire_time_s,
            request_remaining=STANDARD_RESOURCE_TYPES,
        )
        if resolved_request and update_non_empty_request_state:
            self._last_non_empty_resource_request = [
                bundle.copy() for bundle in resolved_request
            ]
            self._last_non_empty_request_time = now
        elif not resolved_request:
            self._last_non_empty_resource_request = []
            self._last_non_empty_request_time = None
        self._last_request_time = now

Copilot AI 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.

Copilot review overview

🟢 Approval recommended

The implementation matches the described V2 semantics and includes focused regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Adds bounded release of explicit resource demand to the rate-based Ray Data cluster autoscaler during sustained low utilization.

Changes:

  • Reuses RAY_DATA_LOW_UTIL_REQUEST_RELEASE_DELAY_S with a 180-second default.
  • Tracks the last non-empty request and releases it after the grace period while preserving requester registration.
  • Adds unit coverage and updates E2E request recording for keep-alive calls.
File Description
python/​ray/​data/​_internal/​cluster_autoscaler/​rate_based_cluster_autoscaler.py Implements low-utilization request retention and release.
python/​ray/​data/​tests/​test_rate_based_cluster_autoscaler.py Tests grace-period retention, release, and re-arming.
python/​ray/​data/​tests/​test_rate_based_cluster_autoscaler_e2e.py Records None keep-alive requests in E2E tests.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@goutamvenkat-anyscale
goutamvenkat-anyscale merged commit 1a6aeec into ray-project:master Sep 30, 2026
6 checks passed
@rayhhome
rayhhome deleted the rate-based-low-util-release branch September 30, 2026 18:13
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…or Rate-based Cluster Autoscaler (ray-project#66584)

## Description
`DefaultClusterAutoscalerV2` releases its resource request under
sustained low utilization (for example a straggler tail), so idle nodes
can be reclaimed. The rate-based cluster autoscaler lacks this and keeps
re-sending its last request
indefinitely, pinning nodes that nothing is using.

This PR strengthens the rate-based cluster autoscaler implementation by
adding the same mechanism. On low utilization the autoscaler keeps its
last non-empty request alive only for a grace window measured from when
that request was sent (`RAY_DATA_LOW_UTIL_REQUEST_RELEASE_DELAY_S`,
default 180s), then sends an empty request that keeps the requester
registered but drops the demand. It reuses V2's environment variable and
field names.

## Related issues
Related to ray-project#62592, which added this to `DefaultClusterAutoscalerV2`.
Adding feature to ray-project#65954.

## Additional information
Also includes unit tests for examining whether the mechanism is behaving
correctly. Not a duplicate: no open PR touches rate-based
low-utilization release.

Signed-off-by: Sirui Huang <[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