Skip to content

feat(npu): add Ascend NPU support via npu-smi (nvitop-npu) - #227

Open
Ruijie-Ysp wants to merge 5 commits into
XuehaiPan:mainfrom
Ruijie-Ysp:dev_ysp_npu
Open

feat(npu): add Ascend NPU support via npu-smi (nvitop-npu)#227
Ruijie-Ysp wants to merge 5 commits into
XuehaiPan:mainfrom
Ruijie-Ysp:dev_ysp_npu

Conversation

@Ruijie-Ysp

Copy link
Copy Markdown

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

- nvitop/api/libnpu.py: dependency-free npu-smi parsing layer with TTL
  caches and parallel 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 and colorful output)
- tests_npu/: 12 unit tests against real npu-smi samples (8x Ascend 910B3)
- pyproject.toml: register the nvitop-npu console script
- README.md: document the Ascend NPU support
The previous test file referenced the early dashboard design
(render_summary / refresh_devices) which no longer exists, and ran
silently without exercising anything. Rewrite it against the final
render_header / render_devices_table / collect_processes APIs:
12 tests covering table borders, ASCII fallback, terminal-width
fitting, process merging and filtering (24/24 with test_libnpu.py).
@Ruijie-Ysp

Copy link
Copy Markdown
Author
image

@Ruijie-Ysp
Ruijie-Ysp marked this pull request as ready for review August 3, 2026 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant