[PR #4623] [GUI] Monitor: each GPU tile gets its own PCIe readings on a two-card PC #5117

Open
opened 2026-11-07 16:32:50 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4623
Author: @lamboJw
Created: 10/29/2026
Status: 🔄 Open

Base: main ← Head: fix/monitor-pcie-per-gpu


📝 Commits (1)

  • 333e1f1 serve telemetry: each card's PCIe link and traffic in "gpus"; the machine's link is the narrowest card's

📊 Changes

2 files changed (+31 additions, -2 deletions)

View changed files

📝 serve/telemetry.py (+14 -2)
📝 serve/test_server.py (+17 -0)

📄 Description

Problem and result

On a PC with two graphics cards, every PCIe tile in the Monitor is empty. Each GPU tile is built from that card's own record in /metrics, and the two-card gpus list carried only util, mem_used, mem_total, temp and power — no pcie_gen, pcie_width, pcie_rx_mb, pcie_tx_mb. The app reads those keys (apps/host/server/monitor-dashboard.mjs, apps/host/src/lib/native-monitor.ts), so the tiles fell back to - / "unavailable" and the caption dropped to the transfer totals. The link generation and width are only shown when a single card is selected, because there the app can fall back to the machine-wide gpu_pcie_* totals; a second card makes that fallback disappear.

After the change each card carries its own link and its own traffic, so both tiles show their readings. This PC (RTX 4060 Ti + RTX 4070 SUPER, both behind a x8 hop) before and after, from serve/telemetry.py unchanged / changed:

before:  gpus: [{index 0, RTX 4060 Ti, util 3, mem_used …, temp 55, power 62.9}]
         gpus: [{index 1, RTX 4070 SUPER, util 0, mem_used …, temp 50, power 109.0}]   (no PCIe keys)
after:   gpus: [{index 0, RTX 4060 Ti,   …, pcie_gen 3, pcie_gen_max 3, pcie_width 8, pcie_rx_mb 7.06, pcie_tx_mb 2.19}]
         gpus: [{index 1, RTX 4070 SUPER, …, pcie_gen 3, pcie_gen_max 3, pcie_width 8, pcie_rx_mb 0.0,  pcie_tx_mb 0.0}]

The machine-wide link figures are now the narrowest card's instead of the first card's: gpu_pcie_gen, gpu_pcie_gen_max and gpu_pcie_width used to come from reads[0], which reads high whenever a Gen4 card is plugged into a Gen3 slot or a x8 card sits next to a x16 one. A link is not a sum, so it is the only kind of reading that cannot be totalled; here both cards happen to read Gen3 x8, so the totals are the same either way on this PC — the difference is covered by the new check, where the two fake cards are Gen4 x16 and Gen3 x8.

none. I searched the open and closed issues and pull requests first: #1734 (the PCIe tile asking for pcie_rx_mb where amdgpu only exposes a total), #3157 (GPU tiles silently showing - when a Linux HIP config lacks backend: hip) and #4496 (per-card PCIe in the Prometheus export) are related but cover other backends or the export, not this gap.

Approach

sample() already reads every card's full record, including its link — the reader produces pcie_gen, pcie_gen_max, pcie_width, pcie_rx_mb and pcie_tx_mb (_Nvml.read, _Amd.read). Only the aggregate g dict kept them; the per-card gpus list dropped them when it was built. Restoring them there is a producer-side fix, so no app-side change is needed and single-card machines behave exactly as before (their readings already came from the gpu_* totals).

One compatibility note: gpu_pcie_gen, gpu_pcie_gen_max and gpu_pcie_width change for a two-card machine where the cards differ. If a single narrow card is present, the value is the same as before; a machine with mixed links now reports the conservative one. gpu_pcie_rx_mb / gpu_pcie_tx_mb keep being sums. The AMD reader's pcie_own_gen and pcie_path are still aggregate-only (from the first card) — I left them out of the per-card list because no app reads them, and I did not want to widen the change; see Limits.

Validation

Revision: origin/main @ 46c152a1 with the single commit of this branch (333e1f1a). Environment: Windows 11 x64, RTX 4060 Ti 16 GB + RTX 4070 SUPER 12 GB (both on a Gen3 x8 hop), Python 3.13.14 in the repo's .venv, no GPU build involved (no C/C++ file touched).

Passed:

  • python -m unittest serve.test_server.AmdTelemetry -v → Ran 4 tests … OK (includes the new test_each_card_has_its_own_link_in_gpus: the two fake cards report (0, 4, 4, 16) and (1, 3, 3, 8), the machine figures report (3, 3, 8)).
  • python C:\...\probe_gpu_pcie.py against the changed serve/telemetry.py with Telemetry(gpu_index=0, gpu_indices=[0, 1]) on the PC above → the numbers quoted above: each card has its own pcie_gen 3 / pcie_width 8 and its own rx/tx (card 1 reads 0.0 while card 0 reads 7.06 MB/s instead of sharing the first card's figures).
  • The same probe against the unmodified serve/telemetry.py in the same checkout → the gpus records have no PCIe keys at all (the "before" output above), which is what the Monitor tiles had nothing to read from.

Failed:

  • The new check run with the serve/telemetry.py change stashed (git stash push -- serve/telemetry.py, then the same unittest command) → FAILED (errors=1): KeyError: 'pcie_gen' on the per-card record. This is the check failing without the fix, not a failure of the submitted code.

Not run:

  • The macOS (_Metal) reader and the Windows AMD path: no Mac and no AMD card here. The AMD per-card link readings are exercised only through the fake amdgpu sysfs tree in the new check, which establishes the aggregation, not driver correctness.
  • serve/test_server.py in full (it is a 6.3k-line file) and the app's npm test suite: neither touches these keys, and running them here would be evidence for a revision I did not change. Say which of them a reviewer wants and I will run them.
  • No CUDA/HIP/SYCL build was made or needed: the change is in the Python telemetry sampler and its test.

Limits

  • The engine's own /metrics and the app's dashboard are separate producers of the same tiles; only the Python sampler is changed here. A released Control has to be rebuilt to pick this up (the packaged serve/telemetry.py in an installed app is a copy of this file).
  • pcie_gen is NVML's current link, which drops to a power-saving generation while the card is idle, so a tile can read Gen3 at an idle desktop and Gen4 while the model runs. pcie_gen_max is the card's own maximum; pcie_width is the current width. The existing AMD link() reports the narrowest hop on its own path, which is a different figure.
  • gpu_pcie_own_gen and gpu_pcie_path remain the first card's readings for a two-card machine; they are not per-card in this PR.

🔄 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/Niko1221/Strata/pull/4623 **Author:** [@lamboJw](https://github.com/lamboJw) **Created:** 10/29/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/monitor-pcie-per-gpu` --- ### 📝 Commits (1) - [`333e1f1`](https://github.com/Niko1221/Strata/commit/333e1f1a00d91002325a389b951cc5ca3da8b75b) serve telemetry: each card's PCIe link and traffic in "gpus"; the machine's link is the narrowest card's ### 📊 Changes **2 files changed** (+31 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `serve/telemetry.py` (+14 -2) 📝 `serve/test_server.py` (+17 -0) </details> ### 📄 Description ## Problem and result On a PC with two graphics cards, every PCIe tile in the Monitor is empty. Each GPU tile is built from that card's own record in `/metrics`, and the two-card `gpus` list carried only `util`, `mem_used`, `mem_total`, `temp` and `power` — no `pcie_gen`, `pcie_width`, `pcie_rx_mb`, `pcie_tx_mb`. The app reads those keys (`apps/host/server/monitor-dashboard.mjs`, `apps/host/src/lib/native-monitor.ts`), so the tiles fell back to `-` / "unavailable" and the caption dropped to the transfer totals. The link generation and width are only shown when a single card is selected, because there the app can fall back to the machine-wide `gpu_pcie_*` totals; a second card makes that fallback disappear. After the change each card carries its own link and its own traffic, so both tiles show their readings. This PC (RTX 4060 Ti + RTX 4070 SUPER, both behind a x8 hop) before and after, from `serve/telemetry.py` unchanged / changed: ```text before: gpus: [{index 0, RTX 4060 Ti, util 3, mem_used …, temp 55, power 62.9}] gpus: [{index 1, RTX 4070 SUPER, util 0, mem_used …, temp 50, power 109.0}] (no PCIe keys) after: gpus: [{index 0, RTX 4060 Ti, …, pcie_gen 3, pcie_gen_max 3, pcie_width 8, pcie_rx_mb 7.06, pcie_tx_mb 2.19}] gpus: [{index 1, RTX 4070 SUPER, …, pcie_gen 3, pcie_gen_max 3, pcie_width 8, pcie_rx_mb 0.0, pcie_tx_mb 0.0}] ``` The machine-wide link figures are now the **narrowest** card's instead of the first card's: `gpu_pcie_gen`, `gpu_pcie_gen_max` and `gpu_pcie_width` used to come from `reads[0]`, which reads high whenever a Gen4 card is plugged into a Gen3 slot or a x8 card sits next to a x16 one. A link is not a sum, so it is the only kind of reading that cannot be totalled; here both cards happen to read Gen3 x8, so the totals are the same either way on this PC — the difference is covered by the new check, where the two fake cards are Gen4 x16 and Gen3 x8. ## Related discussion none. I searched the open and closed issues and pull requests first: #1734 (the PCIe tile asking for `pcie_rx_mb` where amdgpu only exposes a total), #3157 (GPU tiles silently showing `-` when a Linux HIP config lacks `backend: hip`) and #4496 (per-card PCIe in the Prometheus export) are related but cover other backends or the export, not this gap. ## Approach `sample()` already reads every card's full record, including its link — the reader produces `pcie_gen`, `pcie_gen_max`, `pcie_width`, `pcie_rx_mb` and `pcie_tx_mb` (`_Nvml.read`, `_Amd.read`). Only the aggregate `g` dict kept them; the per-card `gpus` list dropped them when it was built. Restoring them there is a producer-side fix, so no app-side change is needed and single-card machines behave exactly as before (their readings already came from the `gpu_*` totals). One compatibility note: `gpu_pcie_gen`, `gpu_pcie_gen_max` and `gpu_pcie_width` change for a two-card machine where the cards differ. If a single narrow card is present, the value is the same as before; a machine with mixed links now reports the conservative one. `gpu_pcie_rx_mb` / `gpu_pcie_tx_mb` keep being sums. The AMD reader's `pcie_own_gen` and `pcie_path` are still aggregate-only (from the first card) — I left them out of the per-card list because no app reads them, and I did not want to widen the change; see Limits. ## Validation Revision: `origin/main` @ `46c152a1` with the single commit of this branch (`333e1f1a`). Environment: Windows 11 x64, RTX 4060 Ti 16 GB + RTX 4070 SUPER 12 GB (both on a Gen3 x8 hop), Python 3.13.14 in the repo's `.venv`, no GPU build involved (no C/C++ file touched). **Passed:** - `python -m unittest serve.test_server.AmdTelemetry -v` → `Ran 4 tests … OK` (includes the new `test_each_card_has_its_own_link_in_gpus`: the two fake cards report `(0, 4, 4, 16)` and `(1, 3, 3, 8)`, the machine figures report `(3, 3, 8)`). - `python C:\...\probe_gpu_pcie.py` against the changed `serve/telemetry.py` with `Telemetry(gpu_index=0, gpu_indices=[0, 1])` on the PC above → the numbers quoted above: each card has its own `pcie_gen` 3 / `pcie_width` 8 and its own rx/tx (card 1 reads 0.0 while card 0 reads 7.06 MB/s instead of sharing the first card's figures). - The same probe against the unmodified `serve/telemetry.py` in the same checkout → the `gpus` records have no PCIe keys at all (the "before" output above), which is what the Monitor tiles had nothing to read from. **Failed:** - The new check run with the `serve/telemetry.py` change stashed (`git stash push -- serve/telemetry.py`, then the same unittest command) → `FAILED (errors=1)`: `KeyError: 'pcie_gen'` on the per-card record. This is the check failing without the fix, not a failure of the submitted code. **Not run:** - The macOS (`_Metal`) reader and the Windows AMD path: no Mac and no AMD card here. The AMD per-card link readings are exercised only through the fake amdgpu sysfs tree in the new check, which establishes the aggregation, not driver correctness. - `serve/test_server.py` in full (it is a 6.3k-line file) and the app's `npm test` suite: neither touches these keys, and running them here would be evidence for a revision I did not change. Say which of them a reviewer wants and I will run them. - No CUDA/HIP/SYCL build was made or needed: the change is in the Python telemetry sampler and its test. ## Limits - The engine's own `/metrics` and the app's dashboard are separate producers of the same tiles; only the Python sampler is changed here. A released Control has to be rebuilt to pick this up (the packaged `serve/telemetry.py` in an installed app is a copy of this file). - `pcie_gen` is NVML's *current* link, which drops to a power-saving generation while the card is idle, so a tile can read Gen3 at an idle desktop and Gen4 while the model runs. `pcie_gen_max` is the card's own maximum; `pcie_width` is the current width. The existing AMD `link()` reports the narrowest hop on its own path, which is a different figure. - `gpu_pcie_own_gen` and `gpu_pcie_path` remain the first card's readings for a two-card machine; they are not per-card in this PR. --- <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
Niko1221/Strata#5117
No description provided.