Skip to content

[dashboard] Use pynvml for GPU metrics and add NPU provider support - #55434

Closed
zhaoch23 wants to merge 12 commits into
ray-project:masterfrom
Bye-legumes:accelerator_dashboards
Closed

zhaoch23 wants to merge 12 commits into
ray-project:masterfrom
Bye-legumes:accelerator_dashboards

Conversation

@zhaoch23

@zhaoch23 zhaoch23 commented Aug 8, 2025

Copy link
Copy Markdown
Contributor

Why are these changes needed?

Switched to use NVML interface for GPU usage, which is claimed to be backward compatible.
Also added NPU DCMI support for NPU usage monitoring.

Related issue number

Follow up for #52102

Checks

Signed-off-by: zhaoch23 <[email protected]>
Signed-off-by: zhaoch23 <[email protected]>
Signed-off-by: zhaoch23 <[email protected]>
Signed-off-by: zhaoch23 <[email protected]>
@zhaoch23
zhaoch23 requested a review from a team as a code owner August 8, 2025 21:56

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

Summary of Changes

Hello @zhaoch23, 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!

I've updated the dashboard's GPU metric collection to improve accuracy and expand hardware compatibility. The primary change involves moving NVIDIA GPU monitoring from nvidia-smi to the pynvml library, which offers more detailed per-process utilization data. Additionally, I've introduced support for Huawei NPUs, enabling their metrics to be collected and displayed within the dashboard. These changes aim to provide a more comprehensive and reliable overview of accelerator resource usage.

Highlights

  • NVIDIA GPU Metrics Transition: I've transitioned the NVIDIA GPU metrics collection from relying on nvidia-smi command-line parsing to using the pynvml library. This change provides a more robust and direct interface for querying GPU information and per-process utilization.
  • Enhanced Per-Process GPU Metrics: I've enhanced the pynvml integration to leverage new NVML functions that provide more detailed per-process GPU utilization (SM and memory usage), which was not readily available with previous methods.
  • Huawei NPU Support: I've added support for Huawei NPUs (Neural Processing Units) by integrating a new pynpudcmi library. This allows Ray's dashboard to collect and report metrics for Huawei NPU devices, including utilization and memory usage, similar to how GPUs are monitored.
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

  1. 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. ↩

@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 switches GPU metrics collection from nvidia-smi to pynvml and adds support for Huawei NPUs via pynpudcmi. The changes are generally well-implemented. My main concern is a potential regression in the NVIDIA GPU provider where GPUs with no running processes might not be reported in the metrics. I've also provided some suggestions to improve the maintainability of the new Huawei NPU provider code by using context managers for locks and decorators to reduce boilerplate. Additionally, there's a minor issue in the new tests with a duplicated test method name that should be corrected.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: zhilong <[email protected]>
@ray-gardener ray-gardener Bot added community-contribution Contributed by the community core Issues that should be addressed in Ray Core observability Issues related to the Ray Dashboard, Logging, Metrics, Tracing, and/or Profiling labels Aug 9, 2025
Bye-legumes and others added 4 commits August 11, 2025 23:09
@jjyao jjyao added the go add ONLY when ready to merge, run all tests label Aug 12, 2025
@jjyao

jjyao commented Aug 15, 2025

Copy link
Copy Markdown
Contributor

@zhaoch23 could you separate the GPU and NPU parts into two PRs?

else self._get_pynvml_gpu_usage()
)

def _get_nvsmi_gpu_usage(self) -> List[GpuUtilizationInfo]:

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.

Nice!!

self.assertEqual(gpu_info["processes_pids"][5678]["gpu_memory_usage"], 512)


class TestHuaweiNpuProvider(unittest.TestCase):

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.

Separate PR

@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 Sep 24, 2025
@github-actions

github-actions Bot commented Oct 8, 2025

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no more activity in the 14 days
since being marked stale.

Please feel free to reopen or open a new pull request if you'd still like this to be addressed.

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

Thanks again for your contribution!

@github-actions github-actions Bot closed this Oct 8, 2025
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 core Issues that should be addressed in Ray Core go add ONLY when ready to merge, run all tests observability Issues related to the Ray Dashboard, Logging, Metrics, Tracing, and/or Profiling stale The issue is stale. It will be closed within 7 days unless there are further conversation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants