Repository navigation
Count a unified-memory APU's window as shared host memory, not dedicated VRAM - #11366
Conversation
…ted VRAM gpuMemoryTotalsGb split the dedicated and shared pools on shared_memory alone. hardware.py sets that flag only on Windows, so on Linux the very same ROCm APU arrives as unified_memory: true, shared_memory: false, and its GTT window was counted as VRAM standing beside system RAM rather than as a view into it. Measured on a Strix Halo gfx1151 box (Radeon 8060S), whose ROCm inventory reports memory_total_gb 64.0, shared_memory false, unified_memory true on a machine with 122.2 GiB of RAM: before VRAM 1% 0.89 GiB / 64 GiB after VRAM 1% 0.89 GiB / 0 GiB VRAM + 64 GiB shared A discrete card beside such a part was worse: 16 GiB of real VRAM and a 48 GiB window read as one 64 GiB pool, which is the iGPU with overinflated VRAM that keeps being reported. Every caller that had learned this folded the two flags on its own way in: use-gpu-info for the system RAM subtraction, memory-fit for the independent total, resolveMemoryCapacityGb for the capacity ceiling. Folding inside gpuMemoryTotalsGb instead fixes the callers that had not, and is a no-op for the ones that had, since folding an already-folded flag returns it unchanged. The split moves and the aggregate does not. Every fit verdict is measured against the total, and it is unchanged in each case: 64 stays 64 for the single APU, 16 + 48 stays 64 for the mixed host. resolveMemoryCapacityGb returns the same 122.2 GiB ceiling before and after, because it already folded unified_memory itself. One behaviour does change beyond the label, and it is the point: on a mixed host the model memory bar now budgets against the discrete card's 16 GiB rather than 64 GiB that includes system RAM. use-model-memory records the old state in as many words, "Known gap: a ROCm APU reports its whole GTT pool and is not flagged as shared". Windows APUs, discrete cards, Vulkan iGPUs and empty inventories are untouched, asserted per case.
Codex Review SummaryThis 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: 52c38a062a
ℹ️ 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 sharedPool = devices | ||
| .filter((device) => device.shared_memory) | ||
| .filter(sharesHostMemoryDevice) |
There was a problem hiding this comment.
Aggregate unified-pool telemetry with the same rule
When multiple unified_memory devices expose the same host pool—the case covered by the new “two views” test—this now collapses their capacity to the largest view, but the live-monitor paths still aggregate telemetry additively: resources-tab.tsx:282-291 sums each device's free memory and resolveGpuVramUsedGb in gpu-vram.ts:381-382 sums each device's usage. For two 48 GiB views reporting 40 GiB free each, the UI therefore displays 80 GiB free against the new 48 GiB total, while duplicated usage can also produce an incorrect percentage. The free/used aggregation needs to follow the shared-pool semantics whenever these newly classified devices are present.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct against the commit this was reviewed on, and fixed in 1b92fdd before it came in.
52c38a0 put unified-only devices under the same largest-view collapse that shared_memory devices get, so your two-views case did read 48 GiB total against 80 GiB free. That collapse is wrong for them for a second reason too: unified_memory alone only says a device shares memory with its own CPU, so a multi-socket unified node (MI300A class) has one pool per socket and would have reported as a single card. 1b92fdd keeps the collapse for shared_memory, which does mean "this budget IS the host pool", and leaves unified_memory-only devices additive.
Measured on the same inventory, two 48 GiB unified views reporting 40 GiB free each:
| state | totals | used | free |
|---|---|---|---|
| main 3481bb3 | dedicated 96, shared 0, total 96 | 16 | 80 |
| 52c38a0 | dedicated 0, shared 48, total 48 | 16 | 80 |
| head 1b92fdd | dedicated 0, shared 96, total 96 | 16 | 80 |
So the free/used aggregation in resources-tab.tsx and resolveGpuVramUsedGb now sees the same total it saw on main for every inventory this PR reclassifies. A 1728-cell enumeration over the two flags, the host-backed field and the inventory shape confirms it: 135 cells change the dedicated/shared split, 0 change the aggregate.
The one place the mismatch you describe is still live is two devices that already carried shared_memory: true, which reads total 48 against free 80. That is identical on main and on this branch, so it is pre-existing rather than something this PR reaches, and fixing it means changing the telemetry path for the Vulkan duplicate-ICD case that two other open PRs are working in. Leaving it out of this one deliberately.
|
Ran this on the Strix Halo DevLab pool, base against head, so the before column is a real render of the old code rather than an argument about it.
The device the runner actually reported, read from That is the shape this change is about: unified, not flagged as shared, and a 64 GiB window on a machine with 122.2 GiB of RAM. Rendering each state's own
Verdict Two things worth stating precisely about that table:
What this host cannot answer, carried through from the run rather than written by hand: discrete GPU, multi GPU, NVIDIA, Intel XPU, Apple MLX, Windows, and Windows Docker. The Windows half of the pool is reachable with the Windows selector, but those boxes carry no ROCm torch, so the ROCm inventory this change reads is not available there. |
|
Confirmed the split in studio/frontend/src/hooks/gpu-vram.ts still keys on shared_memory alone while the rest of that file already folds unified_memory through sharesHostMemory, so a Linux ROCm APU's window lands in dedicated VRAM. Will get this reviewed. |
Folding unified_memory into the shared bucket also put those devices under the pool collapse, where the largest shared reading is taken as the one pool. That rule was written for duplicate Vulkan ICD rows describing one physical device. unified_memory alone says only that a device shares memory with its own cpu, which on a multi-socket unified node is a pool per socket, so collapsing them reported a four-socket node as a single card. An exhaustive sweep of the function over 1728 inventories found 45 cells where the aggregate moved, all of them two unified devices: 32 GiB became 16. The aggregate is what every fit verdict is measured against, so that is a change to what the app agrees to load, and it was not the point of this change. Devices carrying shared_memory still collapse, since that flag means the budget IS the host's own pool. Devices classified only by unified_memory stay additive, which is also how they were counted before they were classified as shared at all. The same sweep now reports 0 cells where the aggregate moves, and 135 where only the split does, every one of them inside the declared predicate.
|
Ran the simulation over this branch rather than only over the case it was written for, and it found a defect in my own first push. Fixed in 1b92fdd and re-proved below. What was wrongFolding The aggregate is what every fit verdict is measured against, so that was a change to what the app agrees to load, and it was not the point of this change. How it was caught
The fixDevices carrying Tests grew the multi-socket case, a duplicate-shared-rows case, and an explicit property that the aggregate equals the old dedicated sum for every shape. 9 tests, 4 of which fail on main. Full suite 8011 pass 0 fail, typecheck, eslint and build clean, and the new tests also pass on node 22.12.0. Re-proved on hardware
What I could not proveNo multi-socket unified host exists on this pool, so the case above is enumerated and reasoned from the device semantics rather than measured on an MI300A node. No integrated NVIDIA or Intel part was available either; both already carry |
|
@codex review |
|
@codex security review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c80d174480
ℹ️ 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".
| perDevice: | ||
| device.shared_memory === true | ||
| ? totals.perDevice | ||
| : totals.perDevice + hostBacked, |
There was a problem hiding this comment.
Preserve per-socket pools through pre-folded callers
When an inventory contains multiple unified_memory: true, shared_memory: false devices, this branch correctly adds their per-socket pools only while the raw shared_memory value remains false. However, use-gpu-info.ts:143-150 and both mappings in resolveMemoryCapacityGb (gpu-vram.ts:259-267 and 302-310) first fold each device to shared_memory: true and omit unified_memory, so those paths still collapse two 48 GiB pools to 48 GiB. This leaves systemRamAvailableGb overstated and makes a pin covering both devices report only half its GPU capacity; preserve the raw flag distinction through these callers rather than pre-folding it.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Checked both halves of this by measuring, and neither figure moves against main, so there is nothing here this branch introduces. One of the two mechanisms named is also not the one that produces the effect.
resolveMemoryCapacityGb. Removing the pre-fold at both mapping sites and passing the raw flags through leaves gpuCapacityGb at 48 for a pin covering two 48 GiB unified devices. The collapse is not the pre-folding: budgetedGpuMemoryGb does its own sharedPool = Math.max(sharedPool, hostBacked) over anything sharesHostMemory accepts, so the figure is 48 whichever shape it is handed. Main reports 48 for the same inventory.
use-gpu-info.ts. Here the mechanism is right, but the fold is load-bearing rather than redundant, and the value is unchanged:
| gpuSharedHostMemoryGb argument | main 3481bb3 | head c80d174 |
|---|---|---|
| pre-folded, as the call site does today | shared 48, systemRamAvailable 80 | shared 48, systemRamAvailable 80 |
| raw, if the fold were removed | shared 0, systemRamAvailable 128 | shared 96, systemRamAvailable 32 |
On main the raw row subtracts nothing at all, which is the bug the fold was added for. At head the fold is no longer required for a single APU but still collapses a multi-socket one, and 80 is what both states report.
So the residual is real but predates this PR and sits in budgetedGpuMemoryGb, not in the branch under review. Taking it separately rather than here: it is a fit-verdict path, the only hardware that reaches it is a multi-socket unified node, and I have none to measure it on, so it deserves its own change with its own evidence instead of riding along on a display fix that is proven not to move any budget.
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! 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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! 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". |
|
Hey @danielhanchen noticed something small, I see it correctly treats pure unified-memory devices as additive (so two 48 GiB sockets stay 96) but on the capacity path we fold both flags into shared_memory first, and that path then collapses them to the max (48). Same inventory, different totals depending on the call site. The new fold test only covers a single device, so this doesn’t show up there. Might be worth aligning those paths or adding a multi-device case to the test I guess |
The capacity path folded both flags into shared_memory before calling in, and budgetedGpuMemoryGb then collapsed those devices to the largest view, so a pin covering two 48 GiB sockets reported 48 GiB while the totals path reported 96. Pass the raw flags and give budgetedGpuMemoryGb the same rule gpuMemoryTotalsGb uses: shared_memory is one host pool and collapses, unified_memory alone is a pool per socket and stays additive. Reported by ItsRoy69.
|
Good catch @ItsRoy69, and you are right on both halves of it. Fixed in 539e69a. The divergence reproduced exactly as you described. Same inventory, two 48 GiB unified sockets, asked three ways at the old head:
Your second point is the one I am more grateful for. The fold test loops over devices but always calls One thing worth recording, because it caught me out. Removing the pre-fold alone does not fix it. I tried exactly that first and measured no change to After the fix, all three read 96, and the RAM tier subtracts 96 rather than 48 on that host. Two tests were added: one asserting every call site agrees on a multi-socket unified host, which fails without the fix, and one asserting the genuine one-pool case (duplicate Vulkan ICD rows) still collapses to 48, so the widening did not go too far. Blast radius, measured rather than argued: the 1728 cell enumeration over the two flags, the host-backed field and the inventory shape reports 0 cells where One existing test also had to change, and I want to be explicit about it rather than have it look like a quiet edit. |
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! 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". |
|
@danielhanchen thanks for chasing both halves. The fact that removing the pre-fold alone wasn’t enough and that the new multi-device tests now cover it is exactly what was needed. |
…ted VRAM (unslothai#11366) * Count a unified-memory APU's window as shared host memory, not dedicated VRAM gpuMemoryTotalsGb split the dedicated and shared pools on shared_memory alone. hardware.py sets that flag only on Windows, so on Linux the very same ROCm APU arrives as unified_memory: true, shared_memory: false, and its GTT window was counted as VRAM standing beside system RAM rather than as a view into it. Measured on a Strix Halo gfx1151 box (Radeon 8060S), whose ROCm inventory reports memory_total_gb 64.0, shared_memory false, unified_memory true on a machine with 122.2 GiB of RAM: before VRAM 1% 0.89 GiB / 64 GiB after VRAM 1% 0.89 GiB / 0 GiB VRAM + 64 GiB shared A discrete card beside such a part was worse: 16 GiB of real VRAM and a 48 GiB window read as one 64 GiB pool, which is the iGPU with overinflated VRAM that keeps being reported. Every caller that had learned this folded the two flags on its own way in: use-gpu-info for the system RAM subtraction, memory-fit for the independent total, resolveMemoryCapacityGb for the capacity ceiling. Folding inside gpuMemoryTotalsGb instead fixes the callers that had not, and is a no-op for the ones that had, since folding an already-folded flag returns it unchanged. The split moves and the aggregate does not. Every fit verdict is measured against the total, and it is unchanged in each case: 64 stays 64 for the single APU, 16 + 48 stays 64 for the mixed host. resolveMemoryCapacityGb returns the same 122.2 GiB ceiling before and after, because it already folded unified_memory itself. One behaviour does change beyond the label, and it is the point: on a mixed host the model memory bar now budgets against the discrete card's 16 GiB rather than 64 GiB that includes system RAM. use-model-memory records the old state in as many words, "Known gap: a ROCm APU reports its whole GTT pool and is not flagged as shared". Windows APUs, discrete cards, Vulkan iGPUs and empty inventories are untouched, asserted per case. * Keep a multi-socket unified host's pools additive Folding unified_memory into the shared bucket also put those devices under the pool collapse, where the largest shared reading is taken as the one pool. That rule was written for duplicate Vulkan ICD rows describing one physical device. unified_memory alone says only that a device shares memory with its own cpu, which on a multi-socket unified node is a pool per socket, so collapsing them reported a four-socket node as a single card. An exhaustive sweep of the function over 1728 inventories found 45 cells where the aggregate moved, all of them two unified devices: 32 GiB became 16. The aggregate is what every fit verdict is measured against, so that is a change to what the app agrees to load, and it was not the point of this change. Devices carrying shared_memory still collapse, since that flag means the budget IS the host's own pool. Devices classified only by unified_memory stay additive, which is also how they were counted before they were classified as shared at all. The same sweep now reports 0 cells where the aggregate moves, and 135 where only the split does, every one of them inside the declared predicate. * Tighten the comments added by this change * Cut the remaining comments to the facts the code does not state * Make every call site agree on a multi-socket unified host The capacity path folded both flags into shared_memory before calling in, and budgetedGpuMemoryGb then collapsed those devices to the largest view, so a pin covering two 48 GiB sockets reported 48 GiB while the totals path reported 96. Pass the raw flags and give budgetedGpuMemoryGb the same rule gpuMemoryTotalsGb uses: shared_memory is one host pool and collapses, unified_memory alone is a pool per socket and stays additive. Reported by ItsRoy69.
What this is
gpuMemoryTotalsGbsplits the dedicated and shared pools onshared_memoryalone.hardware.pysets that flag only on Windows, so on Linux the very same ROCm APU arrives asunified_memory: true, shared_memory: false, and its GTT window is counted as VRAM standing beside system RAM rather than as a view into it.The sibling helper in the same file already says so:
and
use-model-memory.tsrecords the consequence in as many words:Measured
On a Strix Halo gfx1151 box (Radeon 8060S). Its ROCm inventory reports
memory_total_gb 64.0,shared_memory false,unified_memory true, on a machine with 122.2 GiB of RAM. Settings > System, rendered from that reading:1%0.89 GiB / 64 GiB63.1 GiB free1%0.89 GiB / 0 GiB VRAM + 64 GiB shared63.1 GiB freeA discrete card beside such a part was worse. 16 GiB of real VRAM and a 48 GiB window read as one 64 GiB pool, which is the overinflated iGPU VRAM that keeps being reported (#8942, #8847, #7449).
Approach
Fold the two flags inside
gpuMemoryTotalsGbrather than at each call site. Every caller that had learned this rule folded on its own way in:use-gpu-infofor the system RAM subtraction,memory-fitfor the independent total,resolveMemoryCapacityGbfor the capacity ceiling. Folding in one place fixes the callers that had not. For a SINGLE device, folding an already-folded flag returns it unchanged, so it is a no-op for the callers that had. It is NOT a no-op for several unified devices, because the fold erases the distinction between one host pool and a pool per socket, so no caller pre-folds any more: they hand in the raw flags andgpuMemoryTotalsGbandbudgetedGpuMemoryGbapply the same rule. Reported by @ItsRoy69, whose point was that the earlier version left the capacity path answering 48 GiB for the inventory the totals path called 96.What does not move
The split changes; the aggregate does not. Every fit verdict is measured against the total, so a change there would be a change to what the app agrees to load.
Swept exhaustively rather than argued:
gpuMemoryTotalsGbover 1728 inventories, every combination ofmemory_total_gb,shared_memory,unified_memoryandshared_memory_host_backed_gbincluding the malformed and absent ones, crossed with three inventory shapes, run onmainand on this branch.Every one of the 135 has
unified_memory: trueandshared_memorynot true. The 1593 that do not move include the 270 with no usable total and the 27 reportingshared_memory_host_backed_gb: 0, which correctly stay dedicated.resolveMemoryCapacityGbreturns the same 122.2 GiB ceiling on both sides, because it already foldedunified_memoryitself. Vulkan iGPUs, Windows APUs, discrete cards and empty inventories render byte-identically, asserted per case.The first push of this branch did NOT hold that invariant, and the sweep is how it was caught. Folding
unified_memoryinto the shared bucket also put those devices under the pool collapse, where the largest shared reading is taken as the whole pool. That rule exists for duplicate Vulkan ICD rows describing one physical device.unified_memoryalone says only that a device shares memory with its own cpu, which on a multi-socket unified node is a pool per socket, so two 16 GiB devices reported 16 GiB instead of 32 and a four-socket node would have read as a single card. The second commit keeps the collapse for devices carryingshared_memory, and leavesunified_memorydevices additive, which is also how they were counted before being classified as shared at all.What does move, deliberately
On a mixed host the model memory bar now budgets against the discrete card's 16 GiB rather than 64 GiB that includes system RAM.
use-model-memorypicksdedicatedMemoryTotalGbwhen it is below the aggregate; previously the two were equal on such a host, so it fell back to the inflated figure. Smaller and truthful is the intended direction here.Tests
studio/frontend/tests/unified-memory-apu-totals.test.ts, 11 tests built from the measured readings above. They cover the Linux APU, the mixed host, the multi-socket unified host, duplicate shared rows, the Windows shape, the discrete-only host, the flag matrix, the single-device fold-idempotency property, the aggregate-survives property, and the two cross-call-site cases: every surface agrees on a multi-socket unified host, and a genuine single host pool is still counted once. They are not testing their own fixtures: 4 of the first 9 fail onmain, and the cross-call-site test fails against this branch's own previous head.Full frontend suite: 8002 pass 0 fail on
main, 8011 pass 0 fail here, same failing set (empty).npm run typecheck,npm run i18n:check:strict,eslintandnpm run buildall clean. The new tests also pass on node 22.12.0, the version CI pins.Relationship to the open iGPU work
Independent of #11305 and #11306, which both concern the Vulkan inference inventory and the
Unknown VRAMtile. This is the ROCm torch inventory and the dedicated/shared split, and it touches no file either of them touches. The Vulkan path renders identically before and after, checked rather than assumed.Related in subject to #10283, which fixes the same class of error for integrated NVIDIA parts on the budgeting side.
Not covered
No integrated NVIDIA or Intel part was available to read. The Windows ROCm shape is exercised from its reported values rather than from a Windows box, since the AMD Windows runners carry no ROCm torch.
What it looks like
Two isolated Studio installs, one built from this branch's merge base and one from its head, driven by the same Playwright scene. This box has no unified-memory APU, so both installs were served the
gpublock a Strix Halo gfx1151 box (Radeon 8060S) really reported under ROCm on Linux, captured on the self-hosted AMD runner:memory_total_gb 64.0,shared_memory false,unified_memory true,vram_used_gb 1.12. Everything else in the payload is each install's own live reading, and both sides received the identical injection, so the only thing that can differ between the halves is the code under test.The VRAM tile, closer:
3481bb3931.12 GiB / 64 GiB1.12 GiB / 0 GiB VRAM + 64 GiB shared62.9 GiB free62.9 GiB freeRadeon 8060S Graphics, 1.12 GiB used, 62.9 GiB free, 64 GiB totalThree things about the pair worth saying plainly. Re-shot after #11305 merged, so the BEFORE half now contains it. That is the interaction check, and it passes: the tile label stays
VRAMon both halves rather than becomingGPU MEMORY, because a ROCm APU reportsindex_kind: physicaland so never satisfies #11305'sindex_kind === "vulkan" && shared_memory === truepredicate. The two changes describe different devices and do not overlap on this surface.The CPU and RAM tiles differ (10% against 0%, 216.4 GiB against 221.7 GiB) because those are wall clock on a shared machine, not anything this change touches. At the settings dialog's fixed width the longer label ellipsises to
0 GiB VRAM + 64 GiB shar...in the tile itself; that is the existing truncation on that tile, which a Windows APU already reached, and the GPU devices row underneath carries the full figures. And the live backend both installs reported before the injection wascudaon both sides, which is what proves each Studio really served the replayed reading rather than photographing this host's own cards.