[PR #227] feat(npu): add Ascend NPU support via npu-smi (nvitop-npu) #225

Open
opened 2026-10-02 23:15:09 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/XuehaiPan/nvitop/pull/227
Author: @Ruijie-Ysp
Created: 8/3/2026
Status: 🔄 Open

Base: main ← Head: dev_ysp_npu


📝 Commits (5)

  • 850864c feat(npu): add Ascend NPU support via npu-smi (nvitop-npu)
  • e275515 test(npu): rewrite cli_npu tests to match the final CLI API
  • 583a134 feat(npu): improve interactive monitor UI
  • d0ca012 fix(npu): stabilize monitor input and pause
  • a8a70f1 feat(npu): add full-screen monitoring dashboard

📊 Changes

20 files changed (+3920 additions, -0 deletions)

View changed files

📝 README.md (+56 -0)
📝 nvitop/__init__.py (+4 -0)
📝 nvitop/api/__init__.py (+37 -0)
➕ nvitop/api/libnpu.py (+610 -0)
➕ nvitop/api/npu_device.py (+706 -0)
➕ nvitop/cli_npu.py (+369 -0)
➕ nvitop/npu_monitor.py (+396 -0)
➕ nvitop/npu_ui.py (+841 -0)
📝 pyproject.toml (+1 -0)
➕ tests_npu/samples/info--m.txt (+17 -0)
➕ tests_npu/samples/info--t-board--i-0.txt (+19 -0)
➕ tests_npu/samples/info--t-common--i-0.txt (+15 -0)
➕ tests_npu/samples/info--t-memory--i-0.txt (+11 -0)
➕ tests_npu/samples/info--t-power--i-0.txt (+6 -0)
➕ tests_npu/samples/info--t-proc-mem--i-0.txt (+6 -0)
➕ tests_npu/samples/info--t-temp--i-0.txt (+10 -0)
➕ tests_npu/samples/info--t-usages--i-0.txt (+19 -0)
➕ tests_npu/samples/info.txt (+49 -0)
➕ tests_npu/test_cli_npu.py (+549 -0)
➕ tests_npu/test_libnpu.py (+199 -0)

📄 Description

Summary

Add Ascend NPU support to nvitop. A new nvitop-npu command monitors
Huawei Ascend NPUs through the npu-smi CLI (no extra runtime dependencies),
mirroring the nvitop Device / GpuProcess API and rendering an
nvidia-smi-style report, plus a full-screen monitoring dashboard.

Changes

  • nvitop/api/libnpu.py: dependency-free npu-smi parsing layer with TTL
    caches and parallel per-card batch queries
  • nvitop/api/npu_device.py: NpuDevice / NpuProcess data model mirroring
    the Device / GpuProcess API of nvitop
  • nvitop/cli_npu.py: nvitop-npu CLI (one-shot report, monitor mode,
    device/process filtering, ASCII & colorful output)
  • nvitop/npu_ui.py / nvitop/npu_monitor.py: responsive renderers and the
    full-screen monitoring dashboard
  • tests_npu/: 41 unit tests against real npu-smi samples (8x Ascend 910B3)
  • pyproject.toml: register the nvitop-npu console script
  • README.md: document Ascend NPU support

Test

  • 41/41 unit tests pass (pytest tests_npu/, stub-based, no NPU required)
  • Verified on a server with 8x Ascend 910B3 (npu-smi 25.5.1): full report in
    ~5.4s; monitor mode refreshes every 2 seconds

Implementation notes

  • A single global npu-smi info call covers all cards (health / memory /
    power / temperature / process table incl. per-process memory)
  • npu-smi requires -i for per-card detail queries; these are parallelized
    with a thread pool
  • TTL caches (5s global / 30s detail) keep each monitor refresh down to two
    batches of npu-smi calls

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/XuehaiPan/nvitop/pull/227 **Author:** [@Ruijie-Ysp](https://github.com/Ruijie-Ysp) **Created:** 8/3/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `dev_ysp_npu` --- ### 📝 Commits (5) - [`850864c`](https://github.com/XuehaiPan/nvitop/commit/850864cab38d2f4faeb4ebf8d34b17f57ed34280) feat(npu): add Ascend NPU support via npu-smi (nvitop-npu) - [`e275515`](https://github.com/XuehaiPan/nvitop/commit/e275515c8f1f8f1538b4c6c3b115e93bb6591253) test(npu): rewrite cli_npu tests to match the final CLI API - [`583a134`](https://github.com/XuehaiPan/nvitop/commit/583a134e3906b1a5455c85415a98d2c6496e7a2d) feat(npu): improve interactive monitor UI - [`d0ca012`](https://github.com/XuehaiPan/nvitop/commit/d0ca01290f4c6daf01105ac8ac5398ee9aa0e670) fix(npu): stabilize monitor input and pause - [`a8a70f1`](https://github.com/XuehaiPan/nvitop/commit/a8a70f14e78850c553e7372c78c5d15ef2bcc6e5) feat(npu): add full-screen monitoring dashboard ### 📊 Changes **20 files changed** (+3920 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+56 -0) 📝 `nvitop/__init__.py` (+4 -0) 📝 `nvitop/api/__init__.py` (+37 -0) ➕ `nvitop/api/libnpu.py` (+610 -0) ➕ `nvitop/api/npu_device.py` (+706 -0) ➕ `nvitop/cli_npu.py` (+369 -0) ➕ `nvitop/npu_monitor.py` (+396 -0) ➕ `nvitop/npu_ui.py` (+841 -0) 📝 `pyproject.toml` (+1 -0) ➕ `tests_npu/samples/info--m.txt` (+17 -0) ➕ `tests_npu/samples/info--t-board--i-0.txt` (+19 -0) ➕ `tests_npu/samples/info--t-common--i-0.txt` (+15 -0) ➕ `tests_npu/samples/info--t-memory--i-0.txt` (+11 -0) ➕ `tests_npu/samples/info--t-power--i-0.txt` (+6 -0) ➕ `tests_npu/samples/info--t-proc-mem--i-0.txt` (+6 -0) ➕ `tests_npu/samples/info--t-temp--i-0.txt` (+10 -0) ➕ `tests_npu/samples/info--t-usages--i-0.txt` (+19 -0) ➕ `tests_npu/samples/info.txt` (+49 -0) ➕ `tests_npu/test_cli_npu.py` (+549 -0) ➕ `tests_npu/test_libnpu.py` (+199 -0) </details> ### 📄 Description ## Summary Add **Ascend NPU support** to nvitop. A new `nvitop-npu` command monitors Huawei Ascend NPUs through the `npu-smi` CLI (no extra runtime dependencies), mirroring the nvitop `Device` / `GpuProcess` API and rendering an `nvidia-smi`-style report, plus a full-screen monitoring dashboard. ## Changes - `nvitop/api/libnpu.py`: dependency-free `npu-smi` parsing layer with TTL caches and parallel per-card batch queries - `nvitop/api/npu_device.py`: `NpuDevice` / `NpuProcess` data model mirroring the `Device` / `GpuProcess` API of nvitop - `nvitop/cli_npu.py`: `nvitop-npu` CLI (one-shot report, monitor mode, device/process filtering, ASCII & colorful output) - `nvitop/npu_ui.py` / `nvitop/npu_monitor.py`: responsive renderers and the full-screen monitoring dashboard - `tests_npu/`: 41 unit tests against real `npu-smi` samples (8x Ascend 910B3) - `pyproject.toml`: register the `nvitop-npu` console script - `README.md`: document Ascend NPU support ## Test - 41/41 unit tests pass (`pytest tests_npu/`, stub-based, no NPU required) - Verified on a server with 8x Ascend 910B3 (npu-smi 25.5.1): full report in ~5.4s; monitor mode refreshes every 2 seconds ## Implementation notes - A single global `npu-smi info` call covers all cards (health / memory / power / temperature / process table incl. per-process memory) - `npu-smi` requires `-i` for per-card detail queries; these are parallelized with a thread pool - TTL caches (5s global / 30s detail) keep each monitor refresh down to two batches of `npu-smi` calls --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github-starred/nvitop#225
No description provided.