Repository navigation
[Feature] AMD NPU: show the NPU and its resident model in the live monitor - #17508
Conversation
Settings > System > Live monitor and the floating monitor get an NPU card when /api/npu/status reports a supported XDNA 2 NPU: the device, its driver, and the NPU model resident in system RAM. On Windows /api/system now reports npu_load_percent from the GPU Engine counters of the NPU's own adapter, matched by the LUID its PnP node carries; Linux has no counter for it, so the card shows no load there.
With no model loaded Windows lists no GPU Engine instances for the NPU, so every poll cleared the LUID and respawned Get-PnpDevice. Only a failed counter read clears it now; an empty counter list is an idle reading.
An Infinity sample was clamped to 100% and read as a fully busy NPU. Reject it as the GPU counter parser already does.
…invariant An idle NPU and a stale LUID both list no counters, so the LUID is now looked up again once it has been silent for 60 s. Counter values are formatted with the invariant culture so comma-decimal hosts still parse.
|
Screenshots of this PR's change: Settings > System > Live monitor: the NPU card shows the device, its driver, and the resident model with its size in system RAM.
|
[skip ci]
|
@codex review |
1 similar comment
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2baaac5923
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "\\Utilization Percentage' -ErrorAction SilentlyContinue).CounterSamples;" | ||
| "if($s){$s|ForEach-Object{'{0}|{1}' -f $_.InstanceName,$_.CookedValue.ToString([cultureinfo]::InvariantCulture)}}else{'__NONE__'}" | ||
| ) | ||
| stdout = _rocm_windows_counter_stdout_uncached(ps) |
There was a problem hiding this comment.
Suppress console windows for the recurring NPU probes
On Windows desktop installations with a supported NPU, this adds recurring unhidden PowerShell launches to /api/system, including CUDA/NVIDIA hosts that previously avoided the ROCm counter path. _rocm_windows_counter_stdout_uncached() calls subprocess.run without creationflags or startupinfo, while the desktop backend is launched without a console in studio/src-tauri/src/process.rs:3413; consequently, fresh samples create visible console windows even when no NPU model is loaded. Apply the existing hidden-window subprocess kwargs to both the LUID and engine probes so routine system polling does not repeatedly flash windows.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not reproducible as described: Desktop starts the backend (unsloth.exe, a console launcher) with CREATE_NO_WINDOW (process.rs), so it owns a windowless console, and powershell.exe children inherit that console by default rather than creating one (Microsoft Learn, Creation of a Console). No new console window is created, and the existing ROCm counter path has used this same helper on Desktop all along.
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…ales (de-DE, fr-FR) because Get-Counter values are formatted with the host culture (unslothai#17520) On AMD Windows, Unsloth Studio reads GPU utilization from the `GPU Engine` performance counters through PowerShell. The value was printed with `-f`, which formats with the host culture, so on de-DE, fr-FR and other comma-decimal locales each sample came out as `12,5`. Python's `float()` rejects that, every 3D engine sample was skipped, and GPU utilization showed as missing. The counter value is now formatted with `ToString([cultureinfo]::InvariantCulture)`, in both the shared display read and the standalone read. It's the same fix the NPU load reader in unslothai#17508 uses. Infinite, NaN and negative samples are still dropped. ## Tests `test_rocm_windows_gpu_util_locale.py` uses a fake PowerShell that prints comma decimals unless the script asks for the invariant culture. It covers the combined and standalone paths, filtering by adapter, comma output being skipped rather than misread, and invariant `Infinity`/`NaN` being dropped. 4 of its 6 tests fail without the fix. Tested on Windows 11, Ryzen 9 9950X + 2x R9700: the new tests plus the existing `test_rocm_windows_*` suite (151 passed), and the real counter scripts run under PowerShell 5.1 with the thread culture forced to de-DE (the old format printed `12,5`; the new one printed `12.5` and returned a utilization). Not run on a Windows install whose system locale is de-DE. --------- Co-authored-by: Daniel Han <[email protected]>
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6a551e3408
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ); | ||
| const wantsModels = showShare || showBreakdown; | ||
| const [loadedModels, setLoadedModels] = useState<LoadedModelEntry[]>([]); | ||
| const [npuStatus] = useNpuStatus(); |
There was a problem hiding this comment.
Refresh the monitor's NPU status after enabling the runtime
If the floating monitor is already open when the user enables the NPU from Hub or the model picker, its NPU card stays hidden even after a model loads. useNpuStatus() fetches only on mount when called with its default active = true; its updater changes only the calling component's state and the module cache, without notifying other mounted consumers. This monitor therefore retains ready: false, making npuActive() and npuCard() remain false/null until the monitor is closed and reopened. Subscribe this consumer to shared status updates or refresh its status after NPU setup completes.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 647582b: useNpuStatus now publishes every status update (fetch or setter) to all mounted consumers, so an open monitor picks up ready once the NPU is set up. Test covers two consumers.
…r sees the NPU once it is set up [skip ci]
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…nreadable shared iGPU sits beside discrete cards that report usage (unslothai#17523) On a Windows host with 2x Radeon AI PRO R9700 plus the CPU's integrated Radeon Graphics, Settings > System > Live monitor reads "Unknown / 65.7 GiB VRAM + 34.3 GiB shared". `/api/system` reports real `vram_used_gb` for both R9700s (21.75, 1.97), but the iGPU's is null and there's no host aggregate, so `resolveGpuVramUsedGb` returns null for the whole tile. `gpuMemoryDisplay` now moves a shared device with no usage counter into the shared group when every discrete card reports usage and there's no host aggregate. The tile then reads 23.7 / 63.7 GiB with free taken from the same cards, and the iGPU shows on the existing "Shared with system RAM" line. A host aggregate, an unreadable discrete card, or an APU on its own behave as before. It doesn't touch unslothai#17509's carve-out logic and merges cleanly with it. ## Tests `vram-tile-unreadable-igpu.test.ts` uses the reporter's device list: it fails on main and passes here. The existing `gpu-memory-display`, `rocm-windows-vram-aggregate` and `gpu-vram-split` suites still pass, and so do unslothai#17509's tests on a merge with it. Tested on Windows 11, Ryzen 9 9950X + 2x R9700 + integrated Radeon Graphics: frontend unit tests and typecheck. Not checked in the running app. ## Screenshots NPU spoofed: fake Lemonade/FastFlowLM on a Windows 11 PC with no NPU; no speed numbers. Before | after: fork phase stack, phase 4 `49a3094` | phase 5 `db8d450`. Shot at `db8d450`; this PR's head has since moved to `80154bb` (`06a0c5d` and `80154bb` drop the "Estimated available: Unknown" line still visible in these shots). Light mode, mint theme, glass on, same on both sides. Before | after, 2x R9700 plus an unreadable iGPU: the VRAM tile reads "16.4 GiB / 63.7 GiB" instead of "Unknown", with the iGPU on a "Shared with system RAM" line. The NPU tile is unslothai#17508.  Before | after: the floating monitor moves the iGPU under "Shared with system RAM" next to the two R9700s. The NPU row is unslothai#17508.  ## Before / after (Studio built from merge base and from this branch) `/api/system`'s `gpu` block stubbed with the reporter's 2x R9700 + unreadable iGPU reading; everything else is the real server. The VRAM tile goes from "Unknown / 65.7 GiB VRAM + 34.3 GiB shared" to "23.7 GiB / 63.7 GiB, 40 GiB free, Shared with system RAM".  Floating monitor: the iGPU moves under "Shared with system RAM" beside the two R9700 rows.  --------- Co-authored-by: Daniel Han <[email protected]> Co-authored-by: Daniel Han <[email protected]>

With a GGUF model loaded, the live monitor (floating and Settings > System) splits the memory bars per model. With an AMD Ryzen AI NPU model loaded (FastFlowLM through Unsloth Studio's private Lemonade server) there was no breakdown, and no sign of the NPU at all.
/api/inference/statusreportsresident_mibas the RSS of lemond's process tree, floored at the catalog size, withresident_on_gpu: false. The Loaded models label gains an NPU case./api/npu/statusreports a supported XDNA 2 NPU: device, driver, and the resident model with its size in system RAM./api/systemaddsnpu_load_percent, read from the GPU Engine counters for the NPU's adapter LUID (DEVPKEY_GPU_LUID), the source Task Manager's NPU graph uses. Linux has no counter (amdxdna exposes no busy file; fdinfo busy time arrives in kernel 7.4), so the card shows no load there rather than 0%.Tests: new backend tests (process-tree RSS, catalog floor, unloaded NPU, 9 for the load reading) and frontend tests for the label, the card and its strings in all 25 locales. Typecheck is clean. Run on Windows 11, Ryzen 9 9950X, two R9700, no NPU: the LUID-to-counter lookup returned a real R9700's load. Not run on a Ryzen AI NPU.
Screenshots
NPU spoofed: fake Lemonade/FastFlowLM on a Windows 11 PC with no NPU; no speed numbers. Before | after: fork phase stack, phase 4
49a3094| phase 5db8d450. Shot atdb8d450; this PR's head has since moved to2ed8460(LUID lookup throttle and an import path, no visible change). Light mode, mint theme, glass on, same on both sides.Before | after: Settings > System > Live monitor gets an NPU tile with the device, driver and the resident model's size in system RAM. The VRAM tile change is #17523.

Before | after: the floating Live monitor gets an NPU row with the resident model.

Real NPU and before/after evidence
Run on a real XDNA 2 NPU (Ryzen AI Max+ 395, Windows 11, NPU driver 32.0.20102.4480, Lemonade 2026.44.1, FastFlowLM 1.0.12), with Studio's own NPU backend loading
qwen3:0.6band generating (11 runs, about 104 tok/s):resident_on_gpu: false(catalog floor 619 MiB)The NPU's DEVPKEY_GPU_LUID is one of the adapter LUIDs Windows lists under GPU Adapter Memory, and the merge base has no NPU reading at all. On Linux (same hardware, amdxdna 2.25) the NPU is detected and the load reads null, as intended.
Before (merge base) | after (this PR), Chromium. NPU responses spoofed per side with what each side's backend returns for a resident FastFlowLM model; hardware fields are the real box's.
Floating live monitor: an NPU row with the load and the resident model's size in system RAM.

Settings > System > Live monitor: an NPU tile with the device, driver, load and resident model.
