Repository navigation
Studio: Live monitor with CPU, memory and per-GPU rows, Unsloth's share by model, and a refresh rate - #15630
Conversation
… rate setting Drop the native CSS resize: at the default corner min and max size were equal so the grip did nothing, and elsewhere enlarging only added empty space. The card now sizes to its content. On a unified pool (Apple silicon) RAM and VRAM were two bars of the same memory reading 50% and 2%. They are now one Memory row with GPU in use and the space left for models underneath. The device name moves to its own line instead of being truncated inside the label. Add a refresh rate (1, 2, 5 or 10 s, default 5 s) under Settings > Resources.
|
The Chat UI lanes ( That is |
The native CSS resize this PR dropped was the only way to size the monitor, and the Playwright geometry check drives it. Bring sizing back as eight edge and corner handles on the shared floating-panel hook (opt-in, the API monitor is unchanged). Width is the one user-set size. The content zooms with it through --panel-scale, so a top or bottom drag makes the card taller instead of leaving empty space. Left and top drags move the card, and a corner the panel is anchored to stays anchored. The width is saved, cleared with the other floating panel spots, and double-clicking a handle resets it. Each move writes the node before state: the panel is a motion.div whose style props land a frame late, and reading that stale box on release pinned the card one move short of the pointer. The geometry check now grabs the handle itself (the 24px corner radius clips the old 2px-inset grab) and asserts the width-driven behaviour.
…s growth +5,067 B raw / +1,447 B transfer against 06314b9 (Node 26, unchanged at 85 chunks): the unified memory row, refresh rate setting, edge resize on the floating panel hook and their strings in the eager en locale.
…idth-only resize The floating monitor always shows CPU, then one Memory row on unified memory or RAM plus VRAM on a discrete GPU. Two new toggles, in the monitor and in Settings > System: Unsloth's share splits used memory into Unsloth (the server's process tree), other apps and free; the model breakdown lists each loaded model's resident memory plus the rest of the app. Both are off by default and only poll loaded models while on. Resizing now changes the width only. The content no longer zooms with it, and the height follows the content, so the top and bottom handles are gone.
…onitor's formatter now lives
On Apple the process tree's RSS does not always count Metal buffers, so it read 2.26 GiB under a model reporting 2.57 GiB and the app row showed 0.00 GiB. The models' own figure is now the floor, and the app row is hidden when the two cannot be told apart.
"Break down by model" no longer adds a separate By model list. It splits Unsloth's segment of the same memory bar and legend into each loaded model and the rest of the app, next to other apps and free, and stays its own toggle. With nothing loaded the bar keeps a single Unsloth segment. On a discrete GPU the split is on the VRAM bar, where the models are.
…s loaded The whole card is now a grip; buttons, links, the resize edges and the grip itself keep their own pointer, and a classic scrollbar still scrolls. With the model split on and nothing loaded, the legend says "No model loaded" under Unsloth instead of looking identical to the share alone.
An idle Apple GPU draws well under 1 W, so the rounded "0 W" read as a broken sensor. A device with no power reading still gets no Power row.
On GR33N (two R9700s and an iGPU, Windows ROCm) the VRAM row read "-- / 65.7 GiB VRAM + 34.3 GiB shared": the iGPU has no usage reading, which blanked the whole total, and the long capacity string pushed the label out. The VRAM row now counts dedicated cards (the iGPU borrows system RAM, already in the RAM row), shows used / total, and lists each card with its own thin bar when there is more than one. Unsloth's share and the model split use the same total, in the floating monitor and in Settings.
The per-card list under VRAM used a smaller bar and text. Each card is now a row of its own, the same size as CPU, RAM and VRAM: GPU N, used / total, its name under the bar. The combined VRAM row stays only when Unsloth's share or the model split is on, since that split is over all cards.
On GR33N a training run on GPU 0 and gemma's KV cache both landed under "Other apps": on a discrete GPU only model weights are measured per process, so the rest of used VRAM has no known owner. It is labelled "Other in use" with a tooltip saying why. RAM keeps "Other apps", where the process tree is measured.
Padding measured 13 px on the sides and bottom but 17.5 px at the top (the header's 24 px buttons), tight against the 24 px corner radius. It is now 16 px on every side, the top trimmed for the buttons' inner offset. The drag painted its transform on the next animation frame, so the card trailed a fast pointer by 30-45 px in WebKit (the Unsloth Desktop engine on macOS). It now paints in the pointer handler: 0 px behind, still one transform per frame.
…eaper /api/system cached GPU readings for 10 s, so at the 1 s refresh VRAM still moved every 10 s. The floating monitor now passes gpu_max_age (its refresh rate; the backend clamps it to 1-10 s, one probe per second at most). Settings and every other caller keep the 10 s cache. The call itself was 45 ms on a Mac with ~1,100 processes, profiled: - 60%: psutil walking every process to find the server's children (the Unsloth share). The child list is reused for 5 s off Linux; RSS is still read on each call. - 15%: parsing package metadata for ml_packages. Cached for 60 s, keyed on the reader so a patched importlib.metadata.version is never served stale. - the dense-quant probe ran a device op on every call; re-probed at most every 5 s, the old poll interval, so a later kernel failure still shows. - llama.cpp pin support (filesystem + settings DB) is reused inside the 10 s window instead of re-scanned on each fast GPU read. Server time, cached GPU: 26 -> 6.9 ms median. A fresh GPU read on the Mac is ~50 ms, most of it the ioreg subprocess that is the reading itself.
…-redesign # Conflicts: # studio/frontend/src/features/settings/tabs/resources-tab.tsx
Both computed the same models / Unsloth / other / free split in ~40 lines each; they now call poolSplit in monitor-share.ts.
…grow a squeezed card - About 90 comment lines removed or shortened across the PR's files. - startDrag, nudge and startResize each refuse while either session is live, so a second pointer or an arrow key mid-resize no longer gives the geometry two writers. - With no chosen width, a card squeezed by a narrow window grows back to its CSS width (w-64 in the current root font size) instead of staying at the 232 px floor.
…en a model has no size A masked device was GPU 2 on its VRAM row and GPU 0 on its detail row; both now use the visible ordinal Settings uses. A loaded transformers chat model reports no size, so the VRAM split read as Unsloth holding 0 GiB; the plain bar shows instead. [skip ci]
|
@codex review |
Codex Review Summary: ✅ CompletedThis 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. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8be57bbad3
ℹ️ 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".
| name: status.repo_id, | ||
| ...(status.display_repo_id ? { label: status.display_repo_id } : {}), | ||
| ...residentMib(status.resident_mib), | ||
| ...(status.device && status.device !== "cpu" ? { residentOnGpu: true } : {}), |
There was a problem hiding this comment.
Exclude unallocated media headroom from the VRAM share
When an idle Diffusers image/video model gets its resident_mib from media_owner_held_mib(), that value is an admission budget, not allocated GPU memory: gpu_residency.py sums weights plus generation headroom and explicitly counts the idle headroom as unallocated in media_unallocated_mib(). Marking that budget GPU-resident makes the new chart attribute unrelated allocations to the model. For example, 4 GiB of weights plus 4 GiB of unallocated headroom alongside 6 GiB of other allocations becomes an 8 GiB model segment and only 2 GiB of “Other in use.” Clamping against total GPU usage cannot correct that attribution. Use resident weights rather than the admission budget for this split, or leave it unknown.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in a52cf01: an idle media owner's fallback size now leaves out the unallocated generation headroom (full need while generating, unknown while loading).
| const models = modelShares(input.entries, modelsInVram, input.inferenceGpuElsewhere); | ||
| const modelsGb = models.reduce((sum, model) => sum + model.gb, 0); |
There was a problem hiding this comment.
Restrict model attribution to the displayed GPU memory pool
When a GGUF is explicitly pinned to a ROCm iGPU on a mixed iGPU/dGPU host, _llama_resident() still marks its buffers resident_on_gpu=True. vramCards() excludes that iGPU from the VRAM total, yet modelsInVram is true merely because a dedicated card exists, so this calculation bills the iGPU model’s shared-RAM allocation to the dedicated cards. The subsequent clamp only absorbs unrelated dGPU usage; it does not fix the attribution. Retain the model’s device/pool information and count only buffers belonging to the cards in the displayed VRAM total.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Needs a GGUF explicitly pinned to the iGPU on a mixed iGPU and dGPU host; the default placement keeps llama.cpp on the dedicated cards, so this stays out of scope for this PR.
…eration headroom The status fallback reported the admitted need (weights plus generation headroom), which the Live monitor now draws as the model's VRAM. Idle, the headroom is unallocated (as media_unallocated_mib already counts it), so it is subtracted; generating keeps the full need, loading reads unknown.
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a52cf01ed2
ℹ️ 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 unsized = input.entries.some((entry) => !((entry.residentMib ?? 0) > 0)); | ||
| const vramShare = | ||
| modelsInVram && !unsized && input.vramUsedGb !== null | ||
| ? memoryShare(input.vramUsedGb, input.vramTotalGb, modelsGb) |
There was a problem hiding this comment.
Leave the VRAM split unknown for unparsed GPU model sizes
On a Vulkan-only dedicated-GPU host, _llama_resident() returns a nonzero child-RSS resident_mib with resident_on_gpu=None, since Vulkan buffers are not parsed. modelShares(..., true) therefore drops the model, but this unsized test is false because RSS is present. Both views then display an Unsloth 0.00 GiB VRAM segment and place the running model's allocation in “Other in use.” Treat missing GPU-size attribution as unknown, separately from a proven CPU-only model, so this path leaves the VRAM bar unsplit instead of claiming zero.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in eb57884: status now separates a CPU run (false) from an unknown pool (null, Vulkan), and an unknown-pool model leaves the VRAM bar unsplit.
| minHeight: Math.min(layout.minHeight, layout.maxHeight), | ||
| maxWidth: layout.maxWidth, | ||
| maxHeight: layout.maxHeight, | ||
| width: width ?? undefined, |
There was a problem hiding this comment.
Preserve the preferred width when dragging a squeezed panel
When a resized monitor is clamped by a narrower viewport, such as a stored 500px width within 368px constraints, startDrag() still overwrites monitor.style.width with the clamped width while width and widthRef remain 500. Because this JSX width prop has not changed, subsequent renders do not restore the inline width. After widening the viewport, geometry reserves 500px but the element stays 368px wide, losing the requested width and leaving a gap at the anchor. Skip the old native-resize width normalization for state-controlled panels, or explicitly restore the preferred width.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in eb57884: startDrag skips the native-resize width sync when the width is held in state.
… a squeezed card's width - Status now says false for a CPU llama.cpp run and null only when the pool is unknown (Vulkan, buffers not parsed); image and video rows say false on CPU. An unknown-pool model leaves the VRAM bar unsplit instead of reading as Unsloth holding 0 GiB. - startDrag no longer clamps the inline width of a panel whose width is held in state, so a card squeezed by a narrow window regains its chosen width when the window widens. [skip ci]
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eb57884283
ℹ️ 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".
| return mib, True | ||
| from core.inference.llama_cpp import LlamaCppBackend as _Llama | ||
|
|
||
| return mib, (None if _Llama._is_vulkan_backend() else False) |
There was a problem hiding this comment.
Reserve false residency for a confirmed CPU run
When a non-Vulkan GPU run has no physical-ID mapping, such as a SYCL/XPU server, reclaimable_gpu_memory_gb() returns None and resident_memory_mib() falls back to RSS, but this branch marks that size as definitively CPU-resident. The new evidence beyond the earlier Vulkan case is the unconditional early return for missing _child_gpu_physical_ids in llama_cpp.py:8685–8687; missing parsed buffers is not proof of a CPU run. poolSplit consequently skips its unknown-pool guard and renders Unsloth as 0 GiB of VRAM in both views despite the GPU-resident model. Return False only for a confirmed CPU run; otherwise leave the pool unknown.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in b455527: false only for a CPU-only llama.cpp build; a GPU build without parsed buffers stays unknown.
| ? memoryShare(input.vramUsedGb, input.vramTotalGb, modelsGb) | ||
| : null; | ||
| return { | ||
| ram: ramShare && memorySegments(ramShare, modelsInVram ? null : breakdown), |
There was a problem hiding this comment.
Keep CPU-resident models in the RAM breakdown on GPU hosts
With a known CPU-resident GGUF on a machine that also has a dedicated GPU, both callers set modelsInVram from the card inventory rather than the model's placement. modelShares(..., true) then drops the residentOnGpu: false entry, and this branch disables the RAM breakdown too. Consequently, “Break down by model” shows no row for that loaded model in either RAM or VRAM, even when its residentMib is known; the same omission occurs when CPU and GPU models coexist. Partition models by actual residency and pass the CPU models to the RAM breakdown independently of whether dedicated cards exist.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in b455527: poolSplit partitions models by residency, CPU ones broken down in RAM and GPU ones in VRAM.
…d is a CPU run - poolSplit breaks GPU models down in VRAM and proven CPU models in RAM on a GPU host, so a CPU-resident model no longer drops out of both bars. - Status says false only for a CPU-only llama.cpp build; a GPU build without parsed buffers (Vulkan, SYCL) stays unknown. [skip ci]
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! 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". |
What changes for users
The floating Live monitor is rebuilt around one row per resource: CPU, then RAM (or Memory on unified-memory machines), then VRAM, then a full-size row per card when there's more than one GPU.
Screenshots
All 3x captures. Mac shots are at
a3a372b7cf(after the merge of main); GR33N, Mint and Colab at36f7fce0a9(no floating-monitor change since). Every shot, CSV and trace.Mac, Apple M5, 32 GB unified memory, gemma-4-12b loaded
No model loaded, by model on:
GR33N, 2x Radeon AI PRO R9700 (Windows 11, ROCm), gemma-4-12B split across both cards
GR33N, chat on GPU 1 while training Qwen3-1.7B on GPU 0 and GR33N with one GPU visible (
HIP_VISIBLE_DEVICES=0)Linux: RX 9060 XT (Mint) and NVIDIA L4 (Colab)
Settings > System (share cards and toggles; Floating window section with the refresh rate)
Are the numbers right?
Each machine ran the branch and sampled
/api/systemnext to the OS's own counters, idle, with a chat model, and (where the card fits it) with chat plus training. Backend at36f7fce0a9; the readings haven't changed since.vm_stat,psRSS over the server tree,ioregWin32_OperatingSystem, working sets,GPU Adapter Memorycounters/proc/meminfo, fdinfonvidia-smi,/proc/meminfo, RSSLag and latency
Measured on the Mac at a 1 s refresh, Chromium (CDP) and WebKit, before and after the two perf commits (
417a56aa74for the drag,36f7fce0a9for the backend):/api/systemserver time, cached path/api/systemat a 1 s refresh, measured on GR33N itself, where one fresh GPU read costs about 1.4 s:36f7fce0a9, GPU follows the polla5f0b24a54, probes spaced at 4x their own lengthSo on a slow-probe host the GPU rows refresh about every 6 s at the 1 s setting, at main's cost; on the Mac (a 50 ms probe) they refresh every second.
Tests
npm run typecheck,npm test(14403 pass, 0 fail ata3a372b7cf),npm run build, bundle budget (within, 2.1 KB transfer to spare).monitor-share.test.ts,monitor-cards.test.ts,backend/tests/test_system_gpu_max_age.py(age clamp, route, dense-quant throttle, process-tree cache, pin-support cache, slow-probe spacing). Updated:floating-monitor-resize,floating-monitor-redesign,drag-costs-no-render,resources-shared-memory-display,vram-total-gib-suffix, andtests/studio/playwright_chat_ui.py(a wider card must not grow taller).-k systemon the Mac: 904 pass, 4 fail; the 4 (test_dataset_tools_column, a broken-symlink case intest_llama_cpp_load_progress_matrix) fail the same way without this PR.Hardware coverage
Before / after (merge base 91935a1 vs this branch, Chromium, CPU-only host)
Live monitor with Unsloth's share and the model breakdown on, 1 s refresh. Before: a RAM bar with CPU load as a detail. After: CPU and RAM rows, the RAM bar split into Unsloth, other apps and free, and
/api/system?gpu_max_age=1polled at the chosen rate.