Skip to content

[Bug] AMD: Unsloth Studio / Desktop VRAM tile reads Unknown when an unreadable shared iGPU sits beside discrete cards that report usage - #17523

Merged
danielhanchen merged 9 commits into
unslothai:mainfrom
LeoBorcherding:studio/vram-tile-igpu-unknown
Nov 14, 2026
Merged

danielhanchen merged 9 commits into
unslothai:mainfrom
LeoBorcherding:studio/vram-tile-igpu-unknown

Conversation

@LeoBorcherding

@LeoBorcherding LeoBorcherding commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

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 #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 #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 #17508.
17523

Before | after: the floating monitor moves the iGPU under "Shared with system RAM" next to the two R9700s. The NPU row is #17508.
17523

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".
17523 settings

Floating monitor: the iGPU moves under "Shared with system RAM" beside the two R9700 rows.
17523 floating

…GPU is unreadable

On a host with discrete cards plus an integrated GPU that has no usage counter,
resolveGpuVramUsedGb returned null, so Settings > Live monitor read
"Unknown / 65.7 GiB VRAM + 34.3 GiB shared" even though both discrete cards
reported. Sum the readable devices when every unreadable one shares host memory
and at least one discrete card is present; a host aggregate still wins.
…of folding it into VRAM used

Summing only the readable cards still paired that usage with the iGPU's capacity,
so its whole shared pool read as free. Move the iGPU to the display's shared group
instead, so used, free and capacity cover the same cards and the iGPU gets the
existing shared-RAM line.
An unreadable shared iGPU now sits under Shared with system RAM, but it has no free reading, so the VRAM tile and the floating monitor printed a dangling 'Estimated available: Unknown'. Keep the label and drop the estimate line when nothing reports free memory.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T10:54:11.901522Z 59e6c82 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: edadbff54a

ℹ️ 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".

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 13, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 13, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6ffe99a72f

ℹ️ 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 rest = devices.filter((device) => !hasSharedMemoryHeadroom(device));
const unread = rest.filter((device) => !Number.isFinite(device.vram_used_gb));
return unread.length > 0 &&
unread.every(sharesHostMemoryDevice) &&

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve dedicated APU memory when parking unreadable devices

On a Linux ROCm host with no usage aggregate, an APU can have unified_memory: true and shared_memory_host_backed_gb: 0, the measured dedicated-carve-out case covered by unified-memory-apu-totals.test.ts. If its usage counter is unavailable beside a readable discrete card, this predicate parks it because sharesHostMemoryDevice checks only the flags, ignoring the measured split. Removing it from usageDevices then makes Settings lose real dedicated capacity: a 64 GiB APU plus a 16 GiB card becomes a 16 GiB VRAM tile, with the APU incorrectly classified as shared system RAM. Retain devices whose measured host-backed portion is zero.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e07b17f: an unreadable device is parked as shared RAM only when its host-backed split is not measured as zero, so a dedicated carve-out APU stays on the VRAM tile. Test added.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e07b17f50c

ℹ️ 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".

// A measured zero host-backed split is a dedicated carve-out (Linux ROCm APU), not shared RAM.
function parkableSharedDevice(device: GpuDevice): boolean {
return (
sharesHostMemoryDevice(device) && device.shared_memory_host_backed_gb !== 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve large carve-outs with nonzero host-backed memory

When an unreadable Windows ROCm Strix Halo APU sits beside a readable discrete GPU and there is no host aggregate, this predicate also accepts APUs with substantial measured dedicated memory. A fresh reproduction using the 107.92 GiB total / 12.1 GiB host-backed fixture from strix-halo-memory-display.test.ts plus a 24 GiB card makes gpuMemoryDisplay park the APU, so Settings loses its 95.82 GiB carve-out and reports 24 GiB instead of 119.82 GiB. Besides protecting measured-zero splits, retain devices recognized as carve-outs by carveOutVramGb rather than classifying them entirely as shared system RAM.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 59e6c82: parking now uses the carve-out rule (dedicated >= shared stays VRAM), so the 107.92 / 12.1 GiB Strix Halo beside a 24 GiB card reads 119.82 GiB. Test added.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 59e6c82d46

ℹ️ 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".

rhsCZ pushed a commit to rhsCZ/unsloth that referenced this pull request Nov 14, 2026
…nitor (unslothai#17508)

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.

- For a resident NPU model, `/api/inference/status` reports
`resident_mib` as the RSS of lemond's process tree, floored at the
catalog size, with `resident_on_gpu: false`. The Loaded models label
gains an NPU case.
- An NPU card in both monitors, shown only when `/api/npu/status`
reports a supported XDNA 2 NPU: device, driver, and the resident model
with its size in system RAM.
- On Windows, `/api/system` adds `npu_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 5 `db8d450`. Shot at `db8d450`; this PR's head has since moved to
`2ed8460` (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 unslothai#17523.

![17508](https://raw.githubusercontent.com/LeoBorcherding/unsloth/213eeb5869056aa16d7170b41f6949f57ee3517a/npu-phases/phase-5/17508-17523-system-live-monitor.png)

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

![17508](https://raw.githubusercontent.com/LeoBorcherding/unsloth/213eeb5869056aa16d7170b41f6949f57ee3517a/npu-phases/phase-5/17508-17523-floating-monitor.png)


## 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.6b` and generating (11 runs, about 104
tok/s):

| reading | this PR | independent GPU Engine counter read |
|---|---|---|
| NPU load while generating, max / median | 98.8% / 94.4% | 99.3% /
97.9% |
| model loaded, idle | 0.0% | |
| after unload | 0.0% | |
| resident size | 2021 MiB, `resident_on_gpu: false` (catalog floor 619
MiB) | |
| resident size after unload | null | |

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.
![17508 floating
monitor](https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/17508/pr17508_pair_00_q-29cc4c250d81.png)

Settings > System > Live monitor: an NPU tile with the device, driver,
load and resident model.
![17508 system live
monitor](https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/17508/pr17508_pair_01_q-772f245ea2e5.png)

---------

Co-authored-by: oobabooga <[email protected]>
Co-authored-by: Daniel Han <[email protected]>
Co-authored-by: Daniel Han <[email protected]>
@danielhanchen
danielhanchen merged commit 33148e8 into unslothai:main Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants