[Core] Add default TPU Ray node labels#55064
Conversation
Signed-off-by: Ryan O'Leary <ryanaoleary@google.com>
There was a problem hiding this comment.
Summary of Changes
Hello @ryanaoleary, 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 significantly enhances Ray's ability to manage and schedule workloads on TPU devices by automatically adding detailed TPU-specific information as labels to Ray nodes. This change aims to provide finer-grained control for scheduling TPU workloads, particularly for SPMD (Single Program, Multiple Data) paradigms, and replaces a previous workaround that relied on custom resources for this information.
Highlights
- Enhanced TPU Node Labeling: Ray nodes with detected TPU resources will now automatically include detailed labels such as
ray.io/tpu-slice-name,ray.io/tpu-worker-id,ray.io/tpu-topology, andray.io/tpu-head. This provides richer metadata for scheduling. - Improved Scheduling for SPMD Workloads: The addition of these new TPU-specific labels enables more precise scheduling and resource allocation for multi-host TPU workloads, which is crucial for Single Program, Multiple Data (SPMD) execution paradigms.
- Refactored TPU Detection Logic: New methods have been introduced within the
TPUAcceleratorManagerto accurately detect TPU topology information from both environment variables (for GKE) and GCE metadata. - New Constants and Test Coverage: Corresponding C++ and Python constants for the new TPU labels have been defined across the codebase, and comprehensive unit and integration tests have been added to ensure the correct application and resolution of these labels.
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. ↩
|
cc: @andrewsykim |
There was a problem hiding this comment.
Code Review
This pull request introduces default TPU node labels to provide more fine-grained scheduling control. The changes are well-structured, touching the necessary C++ constants, Python backend logic for label resolution, and adding corresponding tests.
My review focuses on improving code maintainability and clarity. I've identified a few areas for improvement:
- Removing unused function parameters to simplify method signatures.
- Avoiding calls to private methods from other modules to respect encapsulation.
- Fixing a minor typo in a comment.
Overall, the changes are solid and the tests provide good coverage for the new functionality. Addressing the feedback will enhance the long-term quality of the code.
Signed-off-by: Ryan O'Leary <ryanaoleary@google.com>
Signed-off-by: Ryan O'Leary <ryanaoleary@google.com>
Signed-off-by: Ryan O'Leary <ryanaoleary@google.com> Remove leading underscores and update how topology is retrieved from GCE Signed-off-by: Ryan O'Leary <ryanaoleary@google.com>
|
Ran a manual test to verify the GCE code path works for retrieving the TPU topology:
With result: This matches the logic we use to query GCE in |
Signed-off-by: Ryan O'Leary <ryanaoleary@google.com>
Signed-off-by: Ryan O'Leary <ryanaoleary@google.com>
|
auto-merge on. ping me if CI fails and need to re-enable. can make any changes from offline discussion as follow ups |
This PR adds useful TPU accelerator information to the node labels of a Ray node when TPU resources are detected. These labels will enable fine-grained control over scheduling on TPU devices and support for SPMD workloads. This information is currently added to the resource configuration of Ray nodes as additional custom resources, but this workaround will be deprecated in favor of using the `label_selector` API. I added `get_current_node_accelerator_labels` as a function to the `AcceleratorManager` abstract class so that we can extend this to other accelerators in the future. --------- Signed-off-by: Ryan O'Leary <ryanaoleary@google.com> Signed-off-by: Kamil Kaczmarek <kamil@anyscale.com>
This PR adds useful TPU accelerator information to the node labels of a Ray node when TPU resources are detected. These labels will enable fine-grained control over scheduling on TPU devices and support for SPMD workloads. This information is currently added to the resource configuration of Ray nodes as additional custom resources, but this workaround will be deprecated in favor of using the `label_selector` API. I added `get_current_node_accelerator_labels` as a function to the `AcceleratorManager` abstract class so that we can extend this to other accelerators in the future. --------- Signed-off-by: Ryan O'Leary <ryanaoleary@google.com> Signed-off-by: Michael Acar <michael.j.acar@gmail.com>
This PR adds useful TPU accelerator information to the node labels of a Ray node when TPU resources are detected. These labels will enable fine-grained control over scheduling on TPU devices and support for SPMD workloads. This information is currently added to the resource configuration of Ray nodes as additional custom resources, but this workaround will be deprecated in favor of using the `label_selector` API. I added `get_current_node_accelerator_labels` as a function to the `AcceleratorManager` abstract class so that we can extend this to other accelerators in the future. --------- Signed-off-by: Ryan O'Leary <ryanaoleary@google.com> Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
This PR adds useful TPU accelerator information to the node labels of a Ray node when TPU resources are detected. These labels will enable fine-grained control over scheduling on TPU devices and support for SPMD workloads. This information is currently added to the resource configuration of Ray nodes as additional custom resources, but this workaround will be deprecated in favor of using the `label_selector` API. I added `get_current_node_accelerator_labels` as a function to the `AcceleratorManager` abstract class so that we can extend this to other accelerators in the future. --------- Signed-off-by: Ryan O'Leary <ryanaoleary@google.com> Signed-off-by: sampan <sampan@anyscale.com>
This PR adds useful TPU accelerator information to the node labels of a Ray node when TPU resources are detected. These labels will enable fine-grained control over scheduling on TPU devices and support for SPMD workloads. This information is currently added to the resource configuration of Ray nodes as additional custom resources, but this workaround will be deprecated in favor of using the `label_selector` API. I added `get_current_node_accelerator_labels` as a function to the `AcceleratorManager` abstract class so that we can extend this to other accelerators in the future. --------- Signed-off-by: Ryan O'Leary <ryanaoleary@google.com> Signed-off-by: jugalshah291 <shah.jugal291@gmail.com>
This PR adds useful TPU accelerator information to the node labels of a Ray node when TPU resources are detected. These labels will enable fine-grained control over scheduling on TPU devices and support for SPMD workloads. This information is currently added to the resource configuration of Ray nodes as additional custom resources, but this workaround will be deprecated in favor of using the `label_selector` API. I added `get_current_node_accelerator_labels` as a function to the `AcceleratorManager` abstract class so that we can extend this to other accelerators in the future. --------- Signed-off-by: Ryan O'Leary <ryanaoleary@google.com> Signed-off-by: Douglas Strodtman <douglas@anyscale.com>
Why are these changes needed?
This PR adds useful TPU accelerator information to the node labels of a Ray node when TPU resources are detected. These labels will enable fine-grained control over scheduling on TPU devices and support for SPMD workloads. This information is currently added to the resource configuration of Ray nodes as additional custom resources, but this workaround will be deprecated in favor of using the
label_selectorAPI.I added
get_current_node_accelerator_labelsas a function to theAcceleratorManagerabstract class so that we can extend this to other accelerators in the future.Related issue number
Checks
git commit -s) in this PR.scripts/format.shto lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/under thecorresponding
.rstfile.