-
Notifications
You must be signed in to change notification settings - Fork 6.8k
[WIP][core][autoscaler] IPPR PoC #54981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @rueian, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces a Proof of Concept (PoC) for in-place resource provisioning and resizing within the Ray cluster, aiming to enable dynamic adjustment of resources on existing nodes. This capability allows for more flexible and efficient resource management without requiring node restarts or additions/removals. The changes involve adding new RPC capabilities to Raylets, enhancing the Global Control Store (GCS) to propagate these resource changes, and improving the consistency of GCS client subscriptions.
Highlights
- Dynamic Resource Resizing RPC: A new RPC endpoint,
ResizeLocalResourceInstances
, has been added to the Raylet's NodeManagerService. This enables external components, such as an autoscaler, to dynamically request changes to a node's total CPU and memory resources. - Raylet-side Resource Management: The Raylet's
NodeManager
now implements the logic to handle these resource resize requests. It includes validation to prevent resizing of unit-instance resources (like GPUs) and to ensure that downsizing does not result in negative available resources. Upon successful resizing, it updates its internal resource scheduler and triggers task rescheduling. - GCS Notification of Resource Changes: The Global Control Store (GCS)
NodeManager
has been enhanced to detect and publish updates to a node's total resources. When a Raylet's resources are resized, this change is immediately broadcasted to the GCS, making the updated resource view available to subscribers. - GCS Client Subscription Consistency: A potential race condition in the GCS client's node information subscription mechanism has been addressed. This ensures that initial node data population and subsequent real-time updates are processed consistently, preventing data inconsistencies by queuing updates received before the initial data is fully processed.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
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 proof-of-concept for in-place resource resizing (IPPR) in the autoscaler. It adds a new RPC ResizeLocalResourceInstances
to the NodeManagerService
to dynamically adjust a node's resources. The changes include protobuf definitions for the new RPC, implementation in raylet/node_manager.cc
to handle resource resizing, updates to gcs_node_manager.cc
to propagate resource changes, and a fix for a race condition in gcs_client/accessor.cc
during node info subscription. The new functionality is also well-tested.
The overall approach is sound. My feedback focuses on improving maintainability by reducing code duplication and enhancing logging for better observability.
auto resources_total = maybe_node_info.value()->mutable_resources_total(); | ||
auto &new_resources = resource_view_sync_message.resources_total(); | ||
// Check if resources_total has changed | ||
if (!MapEqual(*resources_total, new_resources)) { | ||
// Update total resources | ||
*resources_total = new_resources; | ||
// Publish the updated node info to notify subscribers | ||
auto status = | ||
gcs_publisher_->PublishNodeInfo(node_id, *maybe_node_info.value(), nullptr); | ||
if (!status.ok()) { | ||
RAY_LOG(WARNING).WithField(node_id) | ||
<< "Failed to publish node info update: " << status.ToString(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To improve readability and avoid multiple calls to maybe_node_info.value()
, it's better to get the GcsNodeInfo
object once and reuse it.
auto &node_info = *maybe_node_info.value();
auto resources_total = node_info.mutable_resources_total();
auto &new_resources = resource_view_sync_message.resources_total();
// Check if resources_total has changed
if (!MapEqual(*resources_total, new_resources)) {
// Update total resources
*resources_total = new_resources;
// Publish the updated node info to notify subscribers
auto status =
gcs_publisher_->PublishNodeInfo(node_id, node_info, nullptr);
if (!status.ok()) {
RAY_LOG(WARNING).WithField(node_id)
<< "Failed to publish node info update: " << status.ToString();
}
}
src/ray/raylet/node_manager.cc
Outdated
// Log the updated resources | ||
RAY_LOG(INFO) << "Successfully resized local resources. Current Total resources:"; | ||
for (const auto &[resource_name, updated_value] : updated_total_map) { | ||
RAY_LOG(INFO) << " " << resource_name << ": " << updated_value; | ||
} | ||
RAY_LOG(INFO) << "Available resources:"; | ||
for (const auto &[resource_name, updated_value] : updated_available_map) { | ||
RAY_LOG(INFO) << " " << resource_name << ": " << updated_value; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current logging for updated resources iterates through each resource and logs it on a new line. This can be very verbose and spammy in logs, especially when a node has many resource types. Consider formatting the resource maps into a single, more compact log line for better log readability and parsing.
For example:
auto format_map = [](const auto& map) {
std::stringstream ss;
ss << "{";
for (auto it = map.begin(); it != map.end(); ++it) {
ss << it->first << ": " << it->second;
if (std::next(it) != map.end()) {
ss << ", ";
}
}
ss << "}";
return ss.str();
};
RAY_LOG(INFO) << "Successfully resized local resources. "
<< "Current Total: " << format_map(updated_total_map)
<< ", Available: " << format_map(updated_available_map);
37b8077
to
faa0ad1
Compare
…changed Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]> [core][autoscaler] add HandleResizeLocalResourceInstances Signed-off-by: Rueian <[email protected]> [core][autoscaler] add HandleResizeLocalResourceInstances Signed-off-by: Rueian <[email protected]> [core][autoscaler] add HandleResizeLocalResourceInstances Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Co-authored-by: Chia-Yi Liang <[email protected]> Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Co-authored-by: Chia-Yi Liang <[email protected]> Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
b45d641
to
20205c4
Compare
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
…scribe" This reverts commit e3101f2.
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
1500719
to
963c18c
Compare
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
This pull request has been automatically marked as stale because it has not had 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. |
Why are these changes needed?
Related issue number
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.