Repository navigation
Studio: say how much VRAM and RAM the weights take in the partial-offload notice - #16064
debojyoti-dev wants to merge 1 commit into
Conversation
…load notice (fixes unslothai#16055) The "partly on CPU" / "on CPU" load notice only gave the layer split. The load response already carries gpu_weights_mib and host_weights_mib from the llama-server log, so offloadCountsFrom reads them and the notice now reads "9 of 25 layers are on the GPU (0.6 GiB in VRAM, 1.1 GiB in RAM)". When the load reports neither figure the text is unchanged.
|
thanks for this, could we label the memory figures as “model weights”, since they don’t include things like KV cache and compute buffers also, could we use “Related to #16055” instead of “Fixes”, this covers the load notice, but the request for a persistent memory display and more control over GPU usage still needs discussion |
There was a problem hiding this comment.
Thanks for picking this up. On a discrete GPU the sizes are exactly what users have been missing. I ran it on two machines, and it's right on one and wrong on the other.
What I ran (head e174d7c, through the real chat-load flow, auto GPU memory mode):
| machine | model | layers on GPU | notice with this PR | panel's Weight placement row |
|---|---|---|---|---|
| Colab Tesla T4 16 GB, CUDA 13.0, llama.cpp b11985 | Qwen3.8-27B UD-Q5_K_M | 45 / 66 | "(12 GiB in VRAM, 5.7 GiB in RAM)" | – |
| M5 MacBook Pro 32 GB, macOS 26, Metal, llama.cpp b11985 | Qwen3.8-27B UD-Q6_K_XL | 54 / 66 | "(19 GiB in VRAM, 4.7 GiB in RAM)" | "24 GiB in unified memory" |
On the T4 the figures match llama-server's own buffers (CUDA0 model buffer size = 12677.16 MiB, CPU_Mapped model buffer size = 5833.19 MiB), and a 4B control that fit 37/37 shows no notice, same as before.
The problem. On the Mac the toast and the panel describe the same load differently, and the toast calls Apple unified memory "VRAM". The panel already handles this: describeWeights takes a pool and prints one "in unified memory" (Apple) or "in shared memory" (other single-pool machines) figure. weightsClause always passes null (partial-offload.ts:131 at e174d7c), so the notice never takes that path. The same thing will hit AMD APUs and integrated GPUs, which is likely the issue reporter's setup and also your Vega test box. The notice should get the same pool the placement row gets.
Before/after on the M5, two separate installs (merge base 7af6ba3 vs this PR's head e174d7c), same model and the same 55/66 split on both. Today's load landed one layer more on the GPU than the one in the table above, because free memory moved a little:
Main moved under this branch. partial-offload.ts conflicts after #16452, which made describeWeights take a translator t (L173 on main). The notice strings in offloadWarning are still English (L92, L97), so the rebase needs either t passed into offloadWarning or the whole notice translated. Translated fragments spliced into an English sentence would read oddly.
From the earlier comment, still open:
- Label the figures as model weights ("model weights: 12 GiB in VRAM, 5.7 GiB in RAM"). The KV cache and compute buffers aren't counted: on the T4 there were another ~950 MiB of those on the GPU.
- Change "Fixes #16055" to "Related to #16055".
CI: "Frontend build + bundle sanity" was also failing on main around when this ran, and the Windows unit-test failures match the hub-gguf-card-unified-budget ones you noted, so I don't read either as this PR's. A rebase should settle both.
tests/partial-offload.test.ts passes 15/15 at e174d7c on the Mac.
|
Hey @LeoBorcherding, I did not understand one thing, in your screenshots, you mentioned that you are on Macbook M5, but in the dialog boxes, it is showing X GiB in VRAM and Y GiB in RAM. I think this is another bug for Macs, because there is no dedicated VRAM or RAM, as both GPU and CPU shared unified memory architecture which is one of the main selling point of M-series chips. It might be Y GiB in Storage! |
Related to unslothai#16055. ## Problem Studio knows where a loaded GGUF's weights are, but the only lasting readout is the "Weight placement" row in Run settings (unslothai#14909), and it sits behind a switch that is off by default. In a [Reddit thread](https://www.reddit.com/r/unsloth/comments/1xra6ua/inference_speed_cratered_after_recent_update/) about slow generation, people could not tell whether the model had spilled to the CPU. They tried to read it from the memory estimate, which is a forecast. ## Fix - The "Weight placement" row always shows for the loaded GGUF, in the same grey text for every placement. - The switch that used to gate it now only controls the live speed lines, so "Detailed speed and loading info" becomes "Detailed speed info" in all 25 locales. That label is from unslothai#16888, so please say if you prefer another name. - The "partly on CPU" and "none of the layers fit" warnings now end with the weight amounts, for example "Model weights: 1.9 GiB on the GPU, 2.8 GiB on the CPU." These are totals, and they count the weights only. This is the idea from unslothai#16064 (thanks @debojyoti-dev), worded so it is also correct with unified memory. - A MoE load with expert weights in RAM, which llama.cpp counts as fully on the GPU, now says so on its success toast. - A load that llama.cpp logs as fully offloaded while every buffer is in system memory, on a machine with a GPU, now gets the existing "llama.cpp could not use it" warning. There are no backend changes, and which loads get a warning is otherwise the same. ## Before and after Main (`011129b355`) vs this PR (`7e9fd96cc5`), with the same real load on both sides. A model that is fully on the GPU: <img width="3504" height="1072" alt="placement_01_fully_on_gpu" src="https://raw.githubusercontent.com/oobabooga/unsloth/pr-media/pr/studio-gguf-placement-visible/placement_01_fully_on_gpu-b3ed33f4ace9.png" /> 14 of 37 layers on the GPU: <img width="3504" height="1124" alt="placement_02_partly_on_cpu" src="https://raw.githubusercontent.com/oobabooga/unsloth/pr-media/pr/studio-gguf-placement-visible/placement_02_partly_on_cpu-a21ce5ab7fd0.png" /> A MoE model with the expert weights of 24 layers in RAM: <img width="3504" height="1124" alt="placement_03_moe_expert_weights_in_ram" src="https://raw.githubusercontent.com/oobabooga/unsloth/pr-media/pr/studio-gguf-placement-visible/placement_03_moe_expert_weights_in_ram-94f22098f15b.png" /> ## Testing - Live in Studio on Linux with an RTX 3090: the three loads above, and the row after a page reload. A small tool makes the card report less free VRAM than it has, so a model that would fit lands partly on the CPU. - 7 new frontend tests. The failed GPU backend case is covered by these tests only. - `typecheck`, `i18n:check:strict` and the frontend and `tests/studio` tests that cover these files pass. - Not tested on Windows or macOS. ## Before and after, separate installs Merge base `011129b355` vs this PR `dbd790c8ed`, each built from its own tree, "Detailed speed info" left at its default (off). Run settings with gemma-3-270m GGUF loaded on an NVIDIA L4. Main shows no placement; this PR shows all 19 layers on the GPU and the weight split: <img width="620" alt="pr17449_gpu_l4" src="https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/17449/pr17449_gpu_l4_crop-95099eb1a905.png" /> Run settings with Qwen3-0.6B GGUF loaded on a CPU-only Linux machine. This PR says all 29 layers are on the CPU, with 0.5 GiB in RAM: <img width="660" alt="pr17449_cpu_only" src="https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/17449/pr17449_run_settings_crop-4524523ed93c.png" />
|
#17449 fixes it - thanks for the PR! |

Fixes #16055
What was wrong
When a GGUF doesn't fit on the GPU, the load notice says how many layers went where ("9 of 25 layers are on the GPU. The rest run on CPU...") but not how much memory the model takes. Studio already reads the weight buffer sizes from the llama-server log (
gpu_weights_mib/host_weights_mib) and shows them in the model panel's "Weight placement" row, but only when generation details are switched on, and the load notice never used them.What changed
offloadCountsFromalso readsgpu_weights_mibandhost_weights_mibfrom the load response, so every load path that builds the notice (chat, compare, auto-load, audio, recipes) gets them without further changes.9 of 25 layers are on the GPU (0.6 GiB in VRAM, 1.1 GiB in RAM). The rest run on CPU, ...None of the 60 layers fit on the GPU (22 GiB in RAM), so the model runs entirely on CPU ...describeWeightstakes an optional separator so the notice and the panel share one formatter.LoadModelResponsedeclares the two fields (the backendLoadResponsealready returns them via_InferenceRuntimeFields).The issue's other ask, freeing GPU memory held by other programs, is outside what Studio controls, so it's not part of this PR.
Testing
tests/partial-offload.test.ts: new cases for the split, all-on-CPU and MiB-sized figures, plus missing/zero/negative/NaN figures leaving the text unchanged; the existing response-mapping test covers the new fields. All offload-related suites pass (partial-offload, generation-details, offload-warning-load-paths, spec-fallback-partial-offload-copy, auto-load-cpu-fallback-toast: 47/47).parse_weight_placement, then intooffloadWarning(offloadCountsFrom(...)), produces9 of 25 layers are on the GPU (0.6 GiB in VRAM, 1.1 GiB in RAM). ...npm run typecheckand eslint on the changed files: clean.node --experimental-strip-types --test "tests/**/*.test.ts"): 14448 pass, 4 fail, 11 skipped. The 4 failures are all inhub-gguf-card-unified-budget.test.ts("no stub for import @/lib/folder-icons" after Studio: one set of sort and filter icons, shorter chat cards, toolbar tooltips #15958) and fail identically on a clean copy of main.