Skip to content

[Dashboard][NPU] Add NPU Provider to Dashboard - #56755

Open
zhaoch23 wants to merge 49 commits into
ray-project:masterfrom
Bye-legumes:npu_usage
Open

zhaoch23 wants to merge 49 commits into
ray-project:masterfrom
Bye-legumes:npu_usage

Conversation

@zhaoch23

@zhaoch23 zhaoch23 commented Sep 19, 2025 •

Copy link
Copy Markdown
Contributor

Why are these changes needed?

Related issue number

Second part of #55434

Checks


Note

Adds Huawei Ascend NPU support via DCMI, updates GPU provider interface to pass node IP for stable UUIDs, and integrates NPU into provider detection and tests.

  • Dashboard Reporter — GPU Providers:
    • Huawei NPU support: Add HuaweiNpuProvider using pynpudcmi; extend GpuProviderType with HUAWEI and include in provider detection.
    • API change: GpuProvider.get_gpu_utilization(ip) and GpuMetricProvider.get_gpu_usage(ip) now accept optional node IP; ReporterAgent passes self._ip.
    • NPU metrics: Collect per-card ai_core utilization, HBM memory usage/total, and per-process memory via DCMI; derive uuid by hashing card_id + ip.
  • Third-party bindings:
    • Add ray/_private/thirdparty/pynpudcmi with ctypes DCMI wrapper, error classes, and calls (dcmi_init, card/device queries, memory/utilization APIs).
  • Tests:
    • Update provider discovery to include Huawei; add comprehensive HuaweiNpuProvider tests; adjust counts and mocks; ensure IP-based UUID behavior.

Written by Cursor Bugbot for commit 006ec73. This will update automatically on new commits. Configure here.

zhaoch23 and others added 30 commits August 1, 2025 18:44
Signed-off-by: zhaoch23 <[email protected]>
Signed-off-by: zhaoch23 <[email protected]>
Signed-off-by: zhaoch23 <[email protected]>
Signed-off-by: zhaoch23 <[email protected]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: zhilong <[email protected]>
Signed-off-by: zhaoch23 <[email protected]>
Signed-off-by: zhaoch23 <[email protected]>
Signed-off-by: zhaoch23 <[email protected]>
Signed-off-by: zhilong <[email protected]>
Signed-off-by: zhilong <[email protected]>
Signed-off-by: zhilong <[email protected]>
Signed-off-by: zhilong <[email protected]>
Signed-off-by: zhilong <[email protected]>
Signed-off-by: zhilong <[email protected]>
Signed-off-by: zhilong <[email protected]>
Signed-off-by: zhilong <[email protected]>
Signed-off-by: zhilong <[email protected]>
Signed-off-by: zhilong <[email protected]>
Signed-off-by: zhilong <[email protected]>
Signed-off-by: zhilong <[email protected]>
Signed-off-by: zhilong <[email protected]>
@aslonnie
aslonnie removed request for a team September 26, 2025 17:22
cursor[bot]

This comment was marked as outdated.

Signed-off-by: zhaoch23 <[email protected]>
Signed-off-by: zhaoch23 <[email protected]>
cursor[bot]

This comment was marked as outdated.

@@ -0,0 +1 @@
from ray._private.thirdparty.pynpudcmi.pynpudcmi import *

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.

Can you add some comment saying that version of pynpudcmi is vendored here and how should we upgrade it in the future?

return gpu_utilizations


class HuaweiNpuProvider(GpuProvider):

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.

Nit: we should rename GpuProvide to AcceleratorProvider

@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 18, 2025
@jjyao

jjyao commented Oct 22, 2025

Copy link
Copy Markdown
Contributor

@zhaoch23 any updates on this PR?

@github-actions github-actions Bot added unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it. and removed stale The issue is stale. It will be closed within 7 days unless there are further conversation labels Oct 22, 2025
@Lcy0801

Lcy0801 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Hi maintainers and authors, thanks for the work in this PR. I have been working on Ascend NPU observability as well, and found this PR during the duplicate-work check. We have not opened a competing PR.

There is overlap in collecting Ascend metrics through DCMI, but our implementation takes a materially different approach and has a broader scope:

  • Models NPU as a separate accelerator type/provider instead of adding Huawei NPU support to the GPU provider abstraction. This allows GPU and NPU metrics to coexist in heterogeneous Ray clusters.
  • Adds a dedicated NPU schema and fail-soft DCMI collection for AI Core utilization, HBM used/total, health, temperature, board power, physical/logical IDs, and per-process NPU memory.
  • Propagates NPU process data through Reporter, Dashboard Head, worker/actor views, and component-level Prometheus metrics.
  • Adds NPU-specific Prometheus metrics and default Grafana panels, including per-device HBM, utilization, health, temperature, power, and component memory.
  • Extends the Dashboard UI for NPU-only and heterogeneous GPU+NPU clusters, including worker/actor accelerator memory display and legacy reporter payload compatibility.
  • Includes monitoring and scheduling documentation.

We have also validated the implementation on real hardware rather than mocks only:

  • 910C(Single card with two chips) and 910B environments in two containers, including DCMI collection as a non-root user.
  • Two detached Ray actors performing real NPU allocation and computation; DCMI PIDs, per-process HBM, ray_component_npu_memory_mb, Dashboard API data, and UI rows were correlated end to end.
  • A heterogeneous cluster with a NVIDIA B200 worker and an Ascend head node; GPU and NPU node metrics, Prometheus endpoints/service discovery, and the generic accelerator columns were verified together.
  • Container-visible PIDs matched the PIDs returned by DCMI in both tested environments. We are treating other PID namespace layouts as a compatibility risk rather than claiming universal coverage.

Would maintainers prefer that we coordinate with the authors and adapt/contribute these changes to #56755, or is a separate PR appropriate given the separate NPU model and the additional Prometheus, Dashboard, actor/process, heterogeneous-cluster, and documentation scope?

The implementation was developed with AI assistance. The submitting human will review every changed line and include the exact test commands and hardware validation results in any PR description.

@Lcy0801

Lcy0801 commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

@alanwguo @jjyao @zhaoch23 Could you please advise whether you would prefer us to coordinate and contribute the broader separate-NPU implementation to this existing PR, or open a separate PR for it? We have not opened a competing PR and would like to follow the maintainers’ preferred direction.

rueian pushed a commit that referenced this pull request Oct 29, 2026
## Description

This PR adds native Huawei Ascend NPU observability to Ray as a separate
accelerator path that can coexist with GPU monitoring in heterogeneous
clusters.

It:

- loads the read-only DCMI monitoring API from libdcmi.so with a
fail-soft ctypes provider;
- reports per-device AI Core utilization, HBM used/available, health,
temperature, board power, and logical/physical/card/device identifiers;
- obtains per-process NPU memory from DCMI and propagates it through
Reporter, component Prometheus metrics, Dashboard Head worker/actor
association, and the Dashboard UI;
- adds NPU Prometheus metrics and default Grafana panels, including
logical NPU used, total, and pending resources;
- makes the Cluster and Actor views handle NPU-only and mixed GPU/NPU
clusters, including missing-HBM fallback behavior;
- keeps older Reporter payloads compatible when the npus field is
absent; and
- documents driver/DCMI requirements, environment variables, units,
labels, fallback behavior, and the relationship to existing NPU
custom-resource scheduling.

This PR does not change Ray's core scheduling semantics. Ascend Tasks
and Actors continue to use the existing logical NPU custom resource
together with ASCEND_RT_VISIBLE_DEVICES.

## Related issues

Related to #56755.

### Duplicate-work check and difference from #56755

The open-PR searches for "NPU dashboard" and "Ascend DCMI" found #56755
as the only overlapping PR. Before opening this PR, I described the
implementation differences in [this
comment](#56755 (comment))
and asked the authors and maintainers for direction in [this
follow-up](#56755 (comment)).

#56755 adds Huawei NPU support inside the GPU provider abstraction. This
PR is a materially different alternative:

- NPU has an independent provider, schema, API payload, Prometheus
metric families, and UI representation, so GPU and NPU data can coexist.
- It covers node metrics, per-process/component memory, worker/actor
association, Prometheus, Grafana, Dashboard UI, compatibility, and
documentation end to end.
- It includes real-device validation on two Ascend product topologies
and a heterogeneous NVIDIA/Ascend cluster.

This PR does not claim to supersede #56755; maintainers can decide which
architecture should move forward.

## Hardware validation

Hostnames, addresses, and internal deployment details are intentionally
omitted.

| Environment | Hardware topology | Validation |
|---|---|---|
| Ascend 910C | Containerized Ray; one card with two chips | DCMI
enumerated both devices as a non-root user. Two detached Ray actors
allocated real HBM and repeatedly executed FP16 Add. DCMI PIDs, Ray
worker PIDs, per-process HBM, ray_component_npu_memory_mb, Dashboard API
data, and UI rows were correlated end to end. |
| Ascend 910B | Containerized Ray; two cards with one chip per card |
DCMI enumerated both cards/devices and collected device metrics as a
non-root user. |
| Heterogeneous cluster | Ascend NPU node plus NVIDIA B200 GPU node |
Prometheus service discovery included both nodes; GPU and NPU metrics
were collected simultaneously; generic accelerator columns and node
details displayed both accelerator types. |

In both tested container deployments, DCMI PIDs matched the PIDs visible
through /proc. Other container PID-namespace layouts remain a
compatibility risk rather than a claimed universal guarantee.

Screenshots are omitted because the metric/API correlation gives
stronger reproducible evidence and screenshots could expose internal
infrastructure. Redacted screenshots can be added if maintainers request
them.

## Tests

Passed:

.venv/bin/python -m pytest -q
python/ray/dashboard/modules/reporter/tests/test_npu_providers.py
python/ray/dashboard/modules/reporter/tests/test_reporter.py::test_report_stats_ascend_npu_metrics
python/ray/dashboard/modules/reporter/tests/test_reporter.py::test_stats_payload_accepts_legacy_reporter_without_npus
python/ray/dashboard/modules/reporter/tests/test_reporter.py::test_reporter_maps_npu_process_memory_to_worker_metrics
python/ray/dashboard/modules/node/tests/test_actor.py::test_actor_info_associates_npus_by_pid
python/ray/tests/test_metrics_head.py::test_cluster_npu_utilization_averages_reported_samples
\

python/ray/tests/test_metrics_head.py::test_cluster_npu_hbm_utilization_uses_reported_capacity
    # 14 passed

npm --prefix python/ray/dashboard/client test -- --watchAll=false
--runInBand src/components/ActorTable.component.test.tsx
src/pages/node/AcceleratorColumn.component.test.tsx
src/pages/node/AcceleratorMemoryColumn.component.test.tsx
src/util/accelerator.test.ts
    # 4 suites passed, 19 tests passed

    .venv/bin/pre-commit run --from-ref github/master --to-ref HEAD
    # All applicable hooks passed, including Ruff, Black, pydoclint,
    # docstyle/import checks, link checks, ESLint, and Prettier.

    git diff --check github/master...HEAD
    # Passed

The logical NPU resource panel follow-up was additionally validated:

.venv/bin/python -m pytest -q python/ray/tests/test_metrics_head.py -k
'not metrics_folder'
    # 6 passed, 4 deselected

    .venv/bin/pre-commit run --files \

python/ray/dashboard/modules/metrics/dashboards/default_dashboard_panels.py
\
      python/ray/tests/test_metrics_head.py
    # All applicable hooks passed

The generated default dashboard contains 50 panels and the new `Logical
NPU Usage` panel has `USED`, `MAX`, and `MAX + PENDING` queries. On the
Ascend 910C test cluster, Prometheus returned `USED=2` and `MAX=2`;
Grafana hot-reloaded the dashboard and visibly rendered both values as
`2 NPUs`. `MAX + PENDING` correctly remained absent because the cluster
had no pending NPU resources. Both real NPU actors remained alive during
validation.

On an Ascend server, the locked documentation dependencies passed
rtd-doctor. A targeted strict build of the three changed pages also
passed with zero warnings:

sphinx-build -W --keep-going -E -j 4 -b html doc/source <output-dir>
ray-observability/reference/system-metrics.md
core/scheduling/accelerators.md ray-observability/getting-started.md
    # build succeeded; all expected HTML files generated

A full make rtd-build was attempted but blocked while downloading
external collections from templates.ci.ray.io; this was an
external-network limitation, not a Sphinx parsing failure.

The complete Reporter and Actor test files were also attempted in the
local development wheel. Dashboard-starting cases could not run because
that wheel lacks ray/dashboard/client/build/static; one async Reporter
test also lacked its pytest async plugin. The NPU-specific tests listed
above do not require those missing artifacts and passed.

Separately from those local test-environment limitations, the generated
dashboard was deployed and validated end to end on a live Ray cluster
with Ascend NPUs. Prometheus returned the expected per-device and
per-component NPU metrics, and the embedded Ray Dashboard and Grafana
panels rendered the corresponding AI Core utilization, HBM, power,
temperature, health, and component-memory values correctly.

## AI assistance disclosure

AI assistance was used to implement, test, review, and prepare this
change. I reviewed every changed line, understand the end-to-end design
and test evidence, and can maintain and explain the contribution.

---------

Signed-off-by: linchaoying6 <[email protected]>
Co-authored-by: linchaoying6 <[email protected]>

This branch has not been deployed

No deployments
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 dashboard Issues specific to the Ray Dashboard docs An issue or change related to documentation observability Issues related to the Ray Dashboard, Logging, Metrics, Tracing, and/or Profiling unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants