Skip to content

fix(studio): distinguish dedicated vram from shared gpu memory (#9242) - #9247

Merged
mahiatlinux merged 39 commits into
unslothai:mainfrom
yzxcj797:fix/vram-shared-split-9242
Aug 27, 2026
Merged

mahiatlinux merged 39 commits into
unslothai:mainfrom
yzxcj797:fix/vram-shared-split-9242

Conversation

@yzxcj797

Copy link
Copy Markdown
Contributor

Closes #9242.

The mislabel

A Windows ROCm system with a discrete GPU (15.92 GiB) plus an iGPU using shared memory (12.15 GiB) showed the sum (28 GiB) labeled as VRAM. The Vulkan visibility path already flags shared-memory devices — but the torch fallback, the path ROCm Windows actually takes, reported the unified pool with no marker, so the UI could only print one number.

The fix — three small layers

  1. Backend: the torch device inventory records unified_memory per device (reusing the same ROCm APU classifier the carve-out correction already trusts), and the visibility fallback surfaces it as the shared_memory flag the Vulkan path sets.
  2. gpu-vram.ts: dedicatedGpuMemoryTotalGb / sharedGpuMemoryTotalGb — the two halves of the existing aggregate, at the same 2dp precision so their sum still equals it exactly (the aggregate stays the usage-percentage denominator; only the caption changes).
  3. Floating monitor: renders {vram} VRAM + {shared} shared when a shared pool is present (new i18n key vramWithShared); all-dedicated systems are byte-identical to before.

This gives exactly the reporter's suggested readout shape: 16 GiB VRAM + 12 GiB shared + 32 GiB RAM.

Tests

Four in tests/gpu-vram-split.test.ts: the 15.92 + 12.15 split sums exactly to the aggregate; a GTT pool shared by several device views counts once (mirrors the aggregate's own max-not-sum rule); all-dedicated reports zero shared; 2dp float error does not leak into the halves. 4/4 green, and the existing gpu-memory-aggregate suite still passes (9/9 together). tsc --noEmit clean; touched files lint clean.

Note: I can only verify the split logic on this machine (no ROCm iGPU attached) — the classifier reuse means the flag on real APU hardware follows the same path the carve-out correction has been exercising since it shipped.

@danielhanchen

Copy link
Copy Markdown
Member

The VRAM split itself is right, the torch fallback in studio/backend/utils/hardware/hardware.py really does drop the shared_memory flag the Vulkan path sets. Could you narrow this to just that flag plus gpu-vram.ts and the monitor caption, and move the diffusion from_pipe, mlx_repair, native_tls and composer queue changes into their own PRs?

…thai#9242)

A Windows ROCm system with a discrete GPU plus an iGPU using shared
memory showed the SUM (28 GiB: 15.92 dedicated + 12.15 shared) labeled
as VRAM. The Vulkan visibility path already flags shared-memory devices,
but the torch fallback — the path ROCm Windows actually takes — reported
the unified pool with no marker, so the UI could only print one number.

- The torch device inventory now records unified_memory (the same ROCm
  APU classifier the carve-out correction uses), and the visibility
  fallback surfaces it as the shared_memory flag the Vulkan path already
  sets.
- gpu-vram gains dedicatedGpuMemoryTotalGb/sharedGpuMemoryTotalGb: the
  halves of the existing aggregate, same 2dp precision so their sum
  still equals it exactly.
- The floating monitor keeps the aggregate as the usage denominator but
  renders the caption as '{vram} VRAM + {shared} shared' when a shared
  pool is present (new i18n key; all-dedicated systems unchanged).

Four tests: the 15.92+12.15 split sums to the aggregate, a GTT pool
shared by several device views counts once, all-dedicated reports zero
shared, and 2dp float error does not leak into the halves.
@yzxcj797
yzxcj797 force-pushed the fix/vram-shared-split-9242 branch from ff29e08 to 3e550bc Compare August 20, 2026 03:12
@yzxcj797

Copy link
Copy Markdown
Contributor Author

Narrowed and rebased off main — the PR is now exactly hardware.py's shared_memory carry-through, gpu-vram.ts, the monitor caption + en.ts strings, and tests/gpu-vram-split.test.ts (single commit 3e550bc). The diffusion from_pipe, mlx_repair, native_tls and composer queue work are each in their own PRs now. Suite: 4/4 locally.

@mahiatlinux

Copy link
Copy Markdown
Contributor

Pushed five focused follow-up commits after reviewing the ROCm classification path and every Studio GPU-capacity display.

Findings and fixes:

  1. 704683b6a fix rocm shared-memory classification

    • The original torch fallback treated an unclassified ROCm device, an old runtime, or a classifier exception as unified memory. That could mark a discrete GPU as shared memory.
    • hardware.py now sets shared_memory only when the ROCm properties positively identify a unified APU. The visibility endpoint propagates that exact field.
    • Regression cases cover a confirmed APU, a discrete GPU, missing runtime properties, classifier failure, and endpoint propagation.
  2. f73c84096 consolidate gpu memory display totals

    • The frontend independently recomputed dedicated, shared, and aggregate capacity. That duplicated device classification and made inconsistent labels easier to introduce.
    • gpuMemoryTotalsGb() now computes all three values in one pass. Existing aggregate helpers delegate to it, and GpuInfo exposes the dedicated and shared display totals.
  3. 7bff6d4a show shared memory in model hub

    • The original change only updated the floating monitor. Model Hub still labeled dedicated plus shared capacity as VRAM, including the screen from the reported issue.
    • Model Hub now renders the dedicated VRAM total and adds the shared-memory suffix only when present.
  4. cd49bafff show shared memory in resources

    • The Resources live monitor had the same incorrect aggregate VRAM label.
    • Its capacity label now uses the dedicated and shared split from GpuInfo.
  5. ad89e7926 translate shared gpu memory labels

    • The new interpolation key existed only in English despite strict locale parity requirements.
    • The key is present in all 12 locale overlays and preserves both {vram} and {shared} placeholders.

Verification completed before push:

  • Studio frontend full suite: 5,206 passed, 0 failed.
  • Frontend typecheck, production build, and bundle budget check passed.
  • Focused shared-memory frontend regression tests passed.
  • Backend system-poll module: 57 passed, 1 skipped.
  • Timing-sensitive backend tranche: 2,064 passed.
  • CI-shaped backend run: 32,698 passed, 218 skipped, 34 failed. Of the 34 failures, 31 require the repository-pinned Diffusers MiniMax-H3 revision absent from the local Diffusers 0.39.0 environment, two xdist-only failures passed when rerun serially, and one unchanged current-main source-contract test remained reproducible outside this PR's files.
  • Ruff passed on the changed backend files.
  • The new locale key passes parity across every overlay. The repository-wide strict locale check still reports four unrelated English-only agent keys already present on current main.
  • No ROCm device was available locally. The ROCm paths were validated with focused mocked hardware-property tests. No GPU training or model download was attempted.
  • The repository-level CPU suite was stopped before completion and is not reported as passed.

The PR head is now 2ea4aeae8.

@mahiatlinux

Copy link
Copy Markdown
Contributor

@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: 2ea4aeae89

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

@mahiatlinux

Copy link
Copy Markdown
Contributor

Post-push review found and fixed two more correctness issues:

  1. Shared GPU framebuffer reservations were displayed as shared host memory. A 100 GiB unified pool with 68 GiB host-backed memory and 32 GiB reserved framebuffer memory rendered as 0 GiB dedicated plus 100 GiB shared. d6a4e29006 splits each shared device into its reserved and host-backed portions. 6e6c59e313 sums each GPU's independent reserved heap while counting the common host pool once.

  2. MLX reported Apple unified memory as independent GPU memory. The frontend then budgeted the full MLX total plus the same system RAM. 0e34a436da marks MLX memory as shared and host-backed, so unified RAM is counted once.

bfb84e4667 also corrects the multi-device fixture description to match the tested memory model.

Verification on bfb84e4667:

  • ROCm and backend focused tests: 154 passed, 1 skipped
  • MLX regression: 1 passed
  • shared-memory frontend tests: 7 passed
  • related frontend GPU and fit tests: 30 passed
  • frontend typecheck and focused ESLint: passed
  • Ruff checks for changed backend files: passed

No ROCm hardware was available, so ROCm behavior was verified with the repository's mocked hardware tests. The empty HIP_VISIBLE_DEVICES plus non-empty CUDA_VISIBLE_DEVICES candidate was discarded after checking ROCclr source: explicit empty HIP values still take precedence and hide all devices.

@mahiatlinux

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: bfb84e4667

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

@mahiatlinux

Copy link
Copy Markdown
Contributor

@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: f9e562646c

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

@mahiatlinux

Copy link
Copy Markdown
Contributor

@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: e37e58f1c7

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

@mahiatlinux

Copy link
Copy Markdown
Contributor

@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: 7344c1742d

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

@mahiatlinux

Copy link
Copy Markdown
Contributor

@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: 5ec76a9759

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

@mahiatlinux mahiatlinux changed the title fix(studio): distinguish dedicated VRAM from shared GPU memory (#9242) fix(studio): distinguish dedicated vram from shared gpu memory (#9242) Aug 27, 2026
@mahiatlinux

Copy link
Copy Markdown
Contributor

@mahiatlinux mahiatlinux left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM.

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.

Studio: distinguish dedicated VRAM from shared GPU memory

3 participants