mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3117] [Engine] gpustat: give each Intel card its own VRAM readings #4460
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4460
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/3117
Author: @beyondcr
Created: 10/19/2026
Status: 🔄 Open
Base:
main← Head:pr/gpustat-vram-total📝 Commits (1)
1e77009gpustat: read every card, and read each card correctly📊 Changes
3 files changed (+491 additions, -91 deletions)
View changed files
📝
sycl/serve/xe_telemetry.py(+13 -2)📝
sycl/tools/gpustat.py(+155 -89)➕
tools/test_gpustat_vram_total.py(+323 -0)📄 Description
Problem and result
Two Intel GPUs on one xe host, both behind the chipset's PCIe bridges: an Arc Pro B70 at
0000:0d:00.0, where the engine runs, and an Arc A770 at0000:11:00.0, driving the desktop.Resizable BAR is enabled on both, both are visible in
lspci, and the engine runs on the B70through Level Zero, so the hardware side is not in question.
The Monitor's VRAM card read 31.2 of 56.0 GB for the card the engine was on, which has 30.30
GiB usable. The total was almost double the card, and a sample taken with nothing loaded still read
56.0 GB, so it was not transient. Correcting the total alone then made the panel read 105
percent, which is how the second problem surfaced.
After this change each card reports its own capacity and its own clients, and a card the sampler did
not read reports no memory rather than another card's figures.
Related discussion
#3117 covered the first two readings and was closed by the 0.2.0-beta tracker reset rather than on
review; this is the same problem rebased on
mainand extended to the rest of it. Issue #2001 isthe mixed NVIDIA/Intel case, where the wrong card is shown; this is two Intel cards and does not
address it.
Approach
The total was a bridge window.
/sys/bus/pci/devices/<pci>/resourceholds thirteen lines: thecard's six BARs and its ROM at indices 0-6, then the bridge windows the card sits behind at 7-12. A
bridge window is sized for everything behind it and can be far larger than the card, and
max()over every line returned one. On this host, above 1 GiB:
Only the card's own BARs describe its memory, so the sizes now come from the first seven lines. The
module already documents the intended value as "the card's largest PCI BAR, which maps all of VRAM
with resizable BAR", and a bridge window is none of those things.
The used figure included the other card.
clients()accepted any/dev/dripath in/proc/*/fdinfoand never looked atdrm-pdev, so with two cards fitted the used figure was bothcards summed while the total was one. Measured here before the fix:
A client now has to name this card in
drm-pdev. A client that reports nodrm-pdevis stillcounted, so a kernel that does not publish it keeps the previous behaviour rather than reporting
nothing.
Every card is sampled, and the reader takes its own entry.
find_cards()returns every IntelGPU on xe, each sampled with its own hwmon directory matched by device path and its own
accumulators, and
/procis scanned once per sample for all of them rather than once per card. Thedocument keeps one entry per card under
cards, keyed by PCI address, and still writes the firstcard's fields at the top level, so a reader written before this continues to work.
The reader uses the entry for its own card. It previously applied the flat fields whatever card
wrote them, so on a two-card host one card's capacity and usage were shown for the other. When no
entry belongs to the card being read, it reports nothing for load and VRAM rather than another
card's figures.
The name.
card_name()splitlspci -mmon a quote-space-quote sequence, which mangled thedevice name and swallowed the fields after it. It tokenises the fields now.
GPUSTAT_OUTnames the JSON path, so the sampler can be run as a normal user against a scratch fileto check its output without installing it.
Neither the capacity nor the client change is specific to a card model. Both apply to any Intel GPU
whose host fits a second card, which is a property of the platform rather than of the model or the
amount of VRAM.
Compatibility: the JSON keeps its existing keys and the flat top level is unchanged on a single-card
host. No build change; both changed files are Python.
Validation
Passed:
main(e88ee39d) and at this commit: runningsycl/tools/gpustat.pyfrommainreportsvram_total_mb57344; at this commit it reports32768. Both write the same 20 top-level keys, so the change is confined to the values.
python3 -m unittest tools.test_gpustat_vram_total, revision1e770091onmain(e88ee39d),Linux 7.2.11, Python 3.14: 18 tests, OK.
[:7]slice fails the bridge-window test;removing the
drm-pdevfilter fails the client test; restoring the flat read fails thecard-matching test; restoring the old
lspcisplit fails the name test; taking the firstxehwmon fails the hwmon test.
package temperatures, and the reader returns each card's own entry on three consecutive samples.
Busy percent, power and the PCIe link still report.
GPUSTAT_PCIpinning one card, gives that card its entry and theother card nothing, rather than lending it the wrong figures.
Failed: none observed.
Not run: no CUDA, HIP, SYCL or Metal build, since the change is Python only and touches no
compiled code. Not run on a single-Intel-GPU host, and not on Windows, where the SYCL serve layer is
not used.
Limits
Every Intel xe card is sampled by default and the document carries one entry per card, so the reader
takes the entry for the card it is reading without any configuration.
GPUSTAT_PCIis still therefor a sampler limited to one card; a reader whose card the sampler did not cover reports no load or
VRAM rather than another card's figures.
Load and VRAM stay root-only across users, because another user's
/proc/<pid>/fdinfoneedsCAP_SYS_PTRACE; the existing install notes already say so.Notes
serve/telemetry.pyis untouched. The sampler's document keeps its existing keys and gains onecardsmap; the flat top level still describes the first card.been.
power of two: 32 GiB for 30.30 GiB usable, 16 GiB for 15.11 GiB. That is the module's documented
intent and this change does not alter it.
GPUSTAT_VRAM_MBstill overrides everything.#2001is the mixed NVIDIA/Intel case; this is two Intel cards and does not address it.number here was checked against the source or against command output, and I can explain every
changed line. Both cards are fitted here, so further checks can be run on request.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.