Skip to content

Studio: lighter system polling and clearer unified-memory monitor - #14592

Merged
danielhanchen merged 18 commits into
mainfrom
studio-system-monitor-audit
Oct 22, 2026
Merged

danielhanchen merged 18 commits into
mainfrom
studio-system-monitor-audit

Conversation

@shimmyshimmer

@shimmyshimmer shimmyshimmer commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

What changes for users

  • Less background work while Studio is idle. The Live Monitor no longer polls /api/system from hidden tabs; it polls once as soon as the tab is visible again. Before, opening the monitor once (its open state is saved) meant every Studio tab, including background ones, sent 12 requests a minute forever.
  • No more re-render on every poll. The GPU hooks compared a snapshot that included free RAM to 0.01 GB, so every 3-5 s poll re-rendered the Hub, Images and Video pages and the model picker for no visible change. Free RAM now has to move by 0.25 GiB (or anything else has to change) before subscribers update.
  • Vulkan discovery retry backs off. On hosts where the Vulkan build lists no devices, the frontend re-asked every 3 s indefinitely. It now backs off from 3 s to a 60 s cap, resets on success, and waits while the tab is hidden.
  • Idle export status poll slowed down. Every tab polled export status every 5 s from the app root. It now polls every 30 s while nothing is exporting (skipped while hidden) and keeps 5 s during an export. An unchanged status no longer notifies store listeners.
  • The monitor shows "--" instead of fake zeros. While loading, or after a failed first request, the RAM row read "0%, 0 GiB / 0 GiB". /api/system requests now time out after 15 s, so a hung request can no longer freeze the monitor or block the model picker's memory refresh.
  • Clearer unified memory on Apple Silicon. The VRAM row read "7.03 GiB / 0.00 GiB VRAM + 64.0 GiB shared", which suggested ~57 GiB was free. It now reads "7.02 GiB / 64.0 GiB", "Shared with system RAM", "Estimated available: 17.9 GiB" (the backend's own free figure). Settings > Resources matches. Vulkan iGPUs, Linux ROCm APUs and Windows carve-outs are unchanged.
  • GiB labels in picker tooltips. "tight fit on 23.99GB" now reads "tight fit on 24 GiB".

How it was verified

  • npm run typecheck, npm test (13402 pass, 0 fail), npm run build. New tests: system-poll-visibility, export-backend-status-identity, plus cases in gpu-memory-display, dense-quant-schemes-identity, export-status-poll-stall-guard, resources-shared-memory-display, on-device-dot-and-header-alignment.
  • Live on an isolated Studio (Apple M3 Max, 64 GB) driven with Playwright: the monitor renders the new unified-memory text; with the tab hidden for 16 s there were 0 /api/system requests, and one request fired immediately when the tab became visible again.

Live Monitor on an M3 Max after this change (no model loaded):

Live monitor on Apple Silicon after this change

Not tested here

  • Vulkan and Windows hosts (no such hardware on this machine); the Vulkan backoff is covered by unit tests only.

Before / after

Two isolated Studio installs, BEFORE at the merge base and AFTER at this branch's head, both answering /api/system with the same Apple M3 Max reading (64 GiB unified memory, 7.02 GiB in use, 17.9 GiB available), since this machine has no Apple GPU. Only the frontend rendering of that one reading differs.

Live Monitor: the VRAM row no longer reads "7.02 GiB / 0.00 GiB VRAM + 64.0 GiB shared"; it reads "7.02 GiB / 64.0 GiB", "Shared with system RAM" and "Estimated available: 17.9 GiB".

Live Monitor on an Apple unified-memory reading, before and after

Settings > System: the VRAM card matches the monitor.

Settings System VRAM card on an Apple unified-memory reading, before and after

shimmyshimmer added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Oct 22, 2026
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T12:35:58.375866Z f23d649 Manual request
🔒 Security Review ✅ Completed 2026-10-22T03:05:30.188274Z 2bf14c3 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 2bf14c3404

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

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: 2bf14c3404

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@danielhanchen

Copy link
Copy Markdown
Member

"Frontend build + bundle sanity" fails here (job 119610693488, base 77e742c8e2):

over the startup budget: transfer 2023.8 KB > 2023.4 KB, raw 6720.0 KB > 6718.3 KB

Main is within budget at that base: 2,071,823 B transfer / 6,879,345 B raw (2023.3 / 6718.1 KB) against 2,072,012 / 6,879,589, and no frontend change has landed since #14571 set that. The growth comes from this PR's changes in the startup set (floating-monitor.tsx, export-runtime-store.ts, pickers.tsx, ...). Either load the new pieces on use, or raise BUDGET in studio/frontend/scripts/check-bundle-budget.ts in this PR with the measured build after merging main, as the checker's message describes.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

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

…-audit

# Conflicts:
#	studio/frontend/scripts/check-bundle-budget.ts
Stacked on #14592 (same files); the diff below is against that branch.

## What changes for users

**Loaded models card**
- **Real model names for image and video rows.** A model loaded from a
local snapshot showed `snapshots/<sha>`; rows now show the Hub id the
backend already sends as `display_repo_id`. Eject still matches on the
real `repo_id`.
- **Kept models no longer look idle.** With "Keep multiple models
loaded", models answering requests from extra slots were labelled "Still
in memory" and treated as inactive. They now show "Also serving" and
eject by their own checkpoint, never the active model.
- **Memory per model.** The chat, image and video status routes report
an additive, best-effort `resident_mib`:
- GGUF: llama.cpp's GPU buffers when logged, else the llama-server RSS.
  - Image and video: the budget the GPU scheduler admitted.

Rows append it, e.g. "Chat · GGUF · Q4_K_M · 1.0 GiB". Unknown stays
hidden.
- **The RAG embedding model is listed** (owner only, while resident) and
can be ejected from the card.
- **Managed accounts:** when another account's model holds the GPU, the
card shows one "In use by another account" row instead of nothing.
- **Small fixes:**
- Turning the card on with nothing loaded shows "No models loaded" for a
few seconds instead of nothing.
  - An unchanged poll no longer re-renders the card.
- The first Enter on the collapsed pill after a header drag is no longer
swallowed.
  - The card's text goes through i18n, in all 14 locales.

**Live monitor**
- **No more frozen readings.** After two failed polls in a row the
values dim and the header says "Reconnecting..." until the server
answers again. Before, a dead server left the last numbers on screen as
if live.
- **No longer covers the Loaded models card.** Both rested in the
bottom-right corner, so the monitor hid the card. While the monitor is
at its default spot it now rests just above the card; positions you
dragged it to are never moved.
- **Keyboard and screen readers.**
- Both panels are labelled regions, and Esc closes them when focus is
inside.
- The drag handles are focusable and labelled; arrow keys move the panel
(Shift for bigger steps).
- Double-click the monitor's handle to put it back in its corner, and a
drop within 16 px of the corner snaps back.

## How it was verified

- **Frontend:** `npm run typecheck`, `npm run i18n:check:strict`, the
full `npm test` (13423 pass, 0 fail) and `npm run build` all pass. New
tests: `loaded-models-floating-polish`, `loaded-models-eject-serving`,
`floating-monitor-polish`, plus a case in `loaded-models-dismiss`.
- **Backend:** new `tests/test_loaded_model_resident_mib.py`; related
status and media tests pass (390). `ruff check` is clean.
- **Live on an M3 Max** with `unsloth/Qwen3-0.6B-GGUF` Q4_K_M loaded
through llama.cpp:
- `/api/inference/status` returns `resident_mib: 983`, and the card row
reads "Chat · GGUF · Q4_K_M · 1.0 GiB".
  - With both panels open their boxes do not overlap.
- Arrow keys move the monitor, double-click returns it to the corner,
and Esc closes it.
- Stopping the server mid-session turns the monitor to
"Reconnecting...", and no llama-server process is left behind.

Both panels with a model loaded:

![Live monitor resting above the Loaded models
card](https://raw.githubusercontent.com/shimmyshimmer/unsloth-staging-4/pr-media/pr/14601/panels_crop_q-d14a8a5b6c65.png)

The monitor after the server stops:

![Live monitor showing
Reconnecting](https://raw.githubusercontent.com/shimmyshimmer/unsloth-staging-4/pr-media/pr/14601/monitor_stale_q-89ef7d0e7ee4.png)

## Not tested here

- Image and video sizes and labels, extra-slot "Also serving" rows, the
CUDA GPU-buffer path, and the managed-account row. These need GPU models
or a second account with a resident model; they are covered by unit
tests only.
- Some row details are still English: kind labels ("Chat", "Image") and
runtime names ("GGUF", "BF16") come from a pure sources module whose
tests assert on them.
…-audit

# Conflicts:
#	studio/frontend/scripts/check-bundle-budget.ts
…o studio-system-monitor-audit

# Conflicts:
#	studio/frontend/scripts/check-bundle-budget.ts
…-audit

# Conflicts:
#	studio/frontend/scripts/check-bundle-budget.ts
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 804d5e50e9

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

The Loaded models card polls /api/inference/status every 5 s, and resident_mib
rescanned the whole stdout buffer (up to 20k lines on a busy server) on the
event loop each time. The model buffer lines are startup output, so the answer
is fixed once the server is healthy: memoise it per process.
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 196d665667

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

@danielhanchen danielhanchen self-assigned this Oct 22, 2026
danielhanchen added a commit that referenced this pull request Oct 22, 2026
…ds mid-case (#14647)

The composer icon alignment step in Studio Frontend CI fails
intermittently on the Windows leg with:

```
File "tests/studio/playwright_composer_icons.py", line 99, in main
    page.evaluate(
playwright._impl._errors.Error: Page.evaluate: Execution context was destroyed, most likely because of a navigation
```

Seen on main (run 39678763807, job 119495424607) and on #14592 (job
119703801606), which does not touch the composer, the smoke page or the
script. The vite dev page navigates after its buttons have rendered, and
the next evaluate loses its context.

### Change

- Each display case (font scale, zoom, dark, direction) is now applied
and measured in one `evaluate`. Before, the case was applied in one call
and measured in a second; a reload between them resets the case, so
retrying only the measurement would record the default layout under the
case's name.
- `measure_case` re-runs the whole case on a fresh render when the
context is lost, up to 3 attempts. Any other evaluate error fails at
once, and a page that keeps navigating still fails.
- When it does re-measure, it prints the dev server's recent output so
the next occurrence names what triggered the reload. I could not
reproduce the reload on Linux with a cold `node_modules/.vite`, so the
trigger on Windows is not proven yet.

### Verification

- `tests/studio/test_composer_icons_navigation.py` (new, collected by
the Backend CI `studio` shard) uses a fake page whose reload resets the
applied case and kills the evaluate in flight. It checks that one
evaluate applies and measures, that a reload on the first or second
attempt still returns the requested case, that persistent navigation
fails after 3 attempts, and that other errors are not retried.
- Against main's script: 5 of 5 fail. Against a naive fix that keeps the
separate apply call and retries only the measurement: 3 of 5 fail,
including the reload mid-case test.
- Ran the real driver locally in Chromium: `PASS: 1296 rendered icons
centered`, and the measured widths scale with each case (20.80 at font 1
/ zoom 1, 32.5 at 1.25 / 1.25), so the case is applied inside the
measuring call.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

# Conflicts:
#	studio/frontend/scripts/check-bundle-budget.ts
#	studio/frontend/tests/loaded-models-drag-restore.test.ts
#	studio/frontend/tests/on-device-dot-and-header-alignment.test.ts

[skip ci]
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@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: 50c7c69ebf

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

Comment on lines +173 to +177
const heldByOther = heldByAnotherAccount([
inference as { yours?: boolean } | null,
diffusion as { yours?: boolean } | null,
video as { yours?: boolean } | null,
]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve hidden-resident state across failed polls

When a managed account is showing the “in use by another account” card, any transient failure or timeout from the status endpoint that supplied yours: false turns that result into null, so heldByAnotherAccount returns false and the card disappears even though the resident is still holding memory. The row-preservation logic above correctly treats an unreadable source as no new evidence; the hidden-resident verdict needs equivalent per-source preservation until that source returns a successful status.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Leaving as is: one failed poll hides the card until the next successful one a few seconds later; it is a display card, and nothing is unloaded or lost.

Comment on lines +173 to +176
const heldByOther = heldByAnotherAccount([
inference as { yours?: boolean } | null,
diffusion as { yours?: boolean } | null,
video as { yours?: boolean } | null,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include hidden STT residents in the other-account verdict

When another managed account owns a dictation sidecar, /api/inference/audio/stt/status reports loaded: true, yours: false inside the affected transformers, mtmd, gguf, or audiocpp block while clearing loaded_model. describeSttStatus therefore produces no row, and because this check examines only the chat, image, and video top-level statuses, heldByOther remains false and the card incorrectly disappears even though the foreign STT model still reserves memory.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Leaving as is: it needs a managed account viewing while another account holds only a dictation sidecar; the card covers chat, image and video residents, which is what users load and eject from it.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@unslothai unslothai deleted a comment from shimmyshimmer Oct 22, 2026
@unslothai unslothai deleted a comment from shimmyshimmer Oct 22, 2026
@unslothai unslothai deleted a comment from shimmyshimmer Oct 22, 2026
@unslothai unslothai deleted a comment from shimmyshimmer Oct 22, 2026
@unslothai unslothai deleted a comment from shimmyshimmer Oct 22, 2026
@unslothai unslothai deleted a comment from shimmyshimmer Oct 22, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: f23d6498ba

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

danielhanchen added a commit to LeoBorcherding/unsloth that referenced this pull request Oct 22, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 22, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 22, 2026
# Conflicts:
#	studio/frontend/scripts/check-bundle-budget.ts
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.

2 participants