Skip to content

Unsloth Studio (AMD/Windows): report an iGPU's used VRAM when a discrete card sits beside it - #11871

Merged
danielhanchen merged 3 commits into
unslothai:mainfrom
LeoBorcherding:amd-win-igpu-used-beside-dgpu
Sep 27, 2026
Merged

danielhanchen merged 3 commits into
unslothai:mainfrom
LeoBorcherding:amd-win-igpu-used-beside-dgpu

Conversation

@LeoBorcherding

Copy link
Copy Markdown
Collaborator

part of #8942

what's broken

if you have a windows PC with an AMD graphics card and an AMD CPU that has its own built-in graphics (an "iGPU"), and ROCm can see both, the System tab's VRAM tile says Unknown:

VRAM   Unknown / 16.4 GiB VRAM + 76.3 GiB shared

the graphics card's own row right underneath shows a real number (4.28 GiB used), so Studio clearly knows how much memory is in use. the tile just refuses to add it up. the iGPU's row says "Unknown VRAM" too.

this was reported on #8942 (RX 9070 XT + iGPU; the reporter confirmed on 09-03 that the total got fixed by #9247 but the iGPU row was still Unknown) and again on discord today by a tester on an RX 6800 + Ryzen iGPU.

why it happens

quick background: on windows there's no amd-smi to ask, so Studio reads VRAM usage from windows' own performance counters (the same ones task manager uses). there's one set of counters per graphics adapter, named by an ID windows calls a LUID.

an iGPU doesn't have its own memory. it borrows system RAM, so its usage is split across two counters: "Dedicated Usage" (the small slice reserved for it in the BIOS) and "Shared Usage" (everything past that). its real usage is the two added together.

Studio already does that sum, but only when the iGPU is the only GPU it can see. the code that does it (_rocm_windows_unified_used_bytes) has no way to tell adapters apart, so it takes "the one busy adapter" and assumes that's the iGPU. once a graphics card is also plugged in there are two busy adapters, so it gives up, and the iGPU gets no number.

then the frontend (resolveGpuVramUsedGb) only adds up the rows if every GPU has a number. one Unknown row, so the whole tile goes Unknown.

the fix

HIP (AMD's GPU runtime) already tells us the LUID of each GPU, and Studio already uses that to match counters to cards (#8863). so when more than one GPU is visible, Studio now reads Dedicated + Shared for the iGPU's own LUID only. the graphics card's numbers can't leak into the iGPU's, because it's matched by ID and not guessed.

once every row has a number, the tile's total is just their sum.

  • a PC with only one GPU: unchanged, same code path as before
  • HIP doesn't report a LUID: the iGPU stays Unknown, same as today (see gaps below)
  • the Shared Usage read fails: the iGPU stays Unknown, on purpose. past the BIOS slice, all the extra usage lives in Shared, so treating a failed read as zero would say the iGPU has way more free memory than it does

one file changed in the backend (studio/backend/utils/hardware/hardware.py), no frontend change needed.

tests

5 new tests in test_rocm_windows_vram_7072.py, using the numbers from the discord screenshot (RX 6800 16 GiB + iGPU with a 76.8 GiB pool):

test main this PR
graphics card + iGPU: each gets its own used figure (4.28 and 1.5), total is 5.78 fails, iGPU is None passes
same, checked on what the System tab actually receives fails passes
iGPU listed first instead of second fails passes
Shared Usage read fails: iGPU stays Unknown passes passes
HIP gives no LUID: iGPU stays Unknown passes passes

whole file: main 3 failed / 103 passed, this PR 106 passed. measured at 95ffe9dd85.

the 14 other test files that touch this hardware code have 9 failures that happen on main too (on this dev box), none new. measured at d72627a9df, before the last two tests were added; that commit only added tests.

hardware coverage

the checks on this PR run on github's hosted runners, and none of those have an AMD GPU. the self-hosted amd_ci runner is a single Strix Halo APU on linux, so it can't reproduce a windows PC with a graphics card + iGPU. this table is the test report.

everything that ran so far was mocked: fake torch, fake counters, fake HIP. no real card was involved.

setup changed by this PR? what ran still needed
windows, AMD graphics card + AMD iGPU, both visible to ROCm yes, this is the fix mocked tests only a real run. the discord tester's RX 6800 + iGPU is the box for it
windows, AMD graphics card only no, single-GPU path untouched existing tests pass nothing
windows, AMD APU only (Strix Halo etc.) no, single-GPU path untouched existing tests pass nothing
windows, two AMD graphics cards, no iGPU no, the new code only runs for an iGPU-type device existing tests pass nothing
windows, graphics card + iGPU, HIP returns no LUID no, still Unknown mocked test confirms it stays Unknown a follow-up: the fallback matcher would need to hand back a LUID per device
linux, graphics card + iGPU no, different code (amd-smi) nothing not checked whether linux has the same problem
any OS, iGPU on Vulkan no, already fixed by #11305 n/a nothing

bottom line: the logic is covered by tests that fail on main and pass here. the biggest open question is whether HIP actually reports a LUID on a real windows RX 6800 + iGPU box. if it doesn't, the tile stays Unknown for that user and this PR doesn't help them.

not in this PR

the other half of #8942: the iGPU row shows the whole shared pool as its total and calls it "VRAM". that's a labeling question for the frontend, and it's why this says "part of" and not "fixes".

… sits beside it

The Dedicated + Shared sum a pool-scoped APU needs was computed only on a
one-device host, so beside a discrete card the iGPU read Unknown and the
System tab's VRAM tile went Unknown with it. HIP's LUID names the iGPU's own
counters, so use it there. Part of unslothai#8942.

@LeoBorcherding LeoBorcherding left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Codex findings, via a mirror

Codex does not answer on this repository, so it ran against a copy of this pull request's commits at LeoBorcherding/unsloth-staging-review#17. It looked at fcc05f25e7 there, which is this PR's 95ffe9dd8 replayed onto main 1ecc01a30. Nothing was reviewed or resolved on the copy: the findings are here, in Codex's words, to be worked through on this pull request.

Codex found no major issues. Its comment: https://github.com/LeoBorcherding/unsloth-staging-review/pull/17#issuecomment-5823846618

@shimmyshimmer

Copy link
Copy Markdown
Member

Review record for #11871, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#138.

Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found.

Round 1: reviewed mirror 85237203d0 (this PR's 5a0caf6c2)

chatgpt-codex-connector[bot] (on the mirror)

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 85237203d0

No triage reaction was recorded on the mirror

Verdict

The round converged at mirror 85237203d0 (this PR's 5a0caf6c2).

This is the review as it stood at that commit. Anything pushed to this PR afterwards was not part of it.

@danielhanchen
danielhanchen merged commit 79856a6 into unslothai:main Sep 27, 2026
39 of 46 checks passed
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…ete card sits beside it (unslothai#11871)

* Studio (AMD/Windows): report an iGPU's used VRAM when a discrete card sits beside it

The Dedicated + Shared sum a pool-scoped APU needs was computed only on a
one-device host, so beside a discrete card the iGPU read Unknown and the
System tab's VRAM tile went Unknown with it. HIP's LUID names the iGPU's own
counters, so use it there. Part of unslothai#8942.

* Test the System tab payload and an iGPU enumerated first

* Trim comments in the iGPU beside discrete card path

---------

Co-authored-by: Daniel Han <[email protected]>
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.

3 participants