Repository navigation
Unsloth Studio (AMD/Windows): report an iGPU's used VRAM when a discrete card sits beside it - #11871
Conversation
… 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
left a comment
There was a problem hiding this comment.
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
|
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
|
…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]>
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:
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.
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):Nonewhole 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_cirunner 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.
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".