Skip to content

Studio: answer a collapsed On Device row from disk, not the Hub - #16271

Merged
danielhanchen merged 6 commits into
unslothai:mainfrom
yannickloth:fix/on-device-picker-hub-probes
Nov 1, 2026
Merged

danielhanchen merged 6 commits into
unslothai:mainfrom
yannickloth:fix/on-device-picker-hub-probes

Conversation

@yannickloth

@yannickloth yannickloth commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #16267.

Summary

With Show all quantizations off (the default), every picker open issued one Hugging Face listing per cached GGUF repo. The sole-quant read answered from disk, and then a second listing without offline=true asked the Hub whether an update or a missing companion should send the row back to its expander. That follow-up is the probe #12460 added in review, and it sits on the popup's critical path: on the cache in the report (10 GGUF repos) opening On Device meant 10 Hub round-trips, and when the Hub was slow the whole endpoint stack queued — /api/models/gguf-variants p50 155 s, max 216 s, peak 18 concurrent, with the client giving up at 30 s.

A collapsed row now never asks the Hub. A sole-quant row renders the disk answer and carries the same chevron as every other On Device row, so the expander — which already merges the Hub listing and the update/companion state that comes with it — is reachable without asking the Hub to decide whether the row can be opened.

Change

Frontend

  • pickers.tsx: the post-commit probe, soleQuantNeedsExpander and its createTaskLimiter pool are gone. useSoleDownloadedQuants is disk-only.
  • renderSoleQuantGgufRow gets the expander every other On Device row has, and its inference-settings action moves into that expander (which already renders one per downloaded variant). The row keeps its single 38 px gutter — chevron plus the existing row menu — so columns do not shift between row types, and pin/delete/eject stay where they were.
  • renderGgufExpandRow is the shared expander block both row kinds now use.
  • gguf-discovery.ts: hubWithdrawsSoleQuant and createTaskLimiter are deleted; nothing else used them.

Backend

  • cache_inventory.py: the cached-inventory walk moves off asyncio.to_thread (the loop's default executor) onto its own two-thread pool, with context variables carried along. One cold walk over a large cache used to queue every other to_thread caller behind it — the starvation [Bug] unable to pick model when Hugging Face is not responding #14038 fixed for the variant listings, still open for the inventory scan. Two workers cover the two inventories; the existing flight table coalesces callers of the same one.

Not in this PR: the persistent variant index (item 4 in the issue). That is a storage change and deserves its own review.

Verification

Same 10-repo cache, both builds served against an unroutable HF_ENDPOINT (a stalled Hub), three fresh picker opens each, requests counted from the browser's resource timeline:

disk-only variant requests Hub listings chevrons on sole rows
main at caf0a3b 7 7 0
this branch 7 0 7

All three opens of each build produced identical rows, so this is not a first-open effect. Every collapsed row still shows its quant chip (IQ4_XS, UD-IQ3_XXS, UD-Q4_K_XL, P2Q_0, Q8_0, Q4_K_M).

Expanding a row issues that repo's disk listing plus exactly one Hub listing — for that repo only — and the expander shows the cached quant with downloaded, settings, pin and delete:

unsloth/Hy-MT2-1.8B-GGUF [disk]
unsloth/Hy-MT2-1.8B-GGUF [hub]

Also checked online, with the real Hub reachable: opening On Device is still 7 disk reads and 0 Hub listings, and expanding still runs the full remote discovery.

Tests

  • tests/studio/test_model_picker_contracts.py — the contract that required the probe now requires its absence, and pins the sole-quant reads to readSoleQuant (the only caller that passes offline=true). The "parent row has no gear" contract reads the shared expander call; 202 passed.
  • studio/frontend/tests/picker-gguf-discovery.test.ts — the two tests for the deleted helpers are removed; the remaining 12 pass.
  • studio/frontend/tests/model-picker-partial-downloads.test.ts — asserts the sole-quant row has no gear that spreads its selectMeta into a load.
  • studio/backend/hub/tests/test_model_services.py — new test_cached_inventory_scan_keeps_off_the_default_executor fails on main (asyncio's default pool names its threads asyncio_0) and passes here; the existing shared-scan test now stubs the new helper.
  • Gates: npm run typecheck, npm run i18n:check:strict, the full frontend suite (14520 pass, 1 pre-existing date-dependent failure in halloween-trick-or-treat that also fails on main), ESLint on the touched files (same 9 pre-existing errors as main, no new ones), and the backend files above (356 pass; the 12 failures in test_model_services.py also fail on main in this environment).

Biome reports pre-existing drift across pickers.tsx, so I did not run biome check --write over it — the diff stays scoped to this change.

Next step (not in this PR)

An expander still asks the Hub for what the disk cannot know — an update, a pending companion, the published default — and loses that answer whenever the Hub is slow or down. The follow-up keeps the Hub-derived fields of the last live answer beside the cache and replays them, marked cached, with the update/companion actions withheld while they cannot be verified. Design and open questions are in #16267; the implementation is written and verified on feat/on-device-hub-state-fallback, held back until this lands so nothing upstream is a stacked duplicate.

Maintainer update

Main moved the On Device rows into memoized components (#16316), so this branch now merges main and applies the same change to SoleQuantGgufDeviceRow. One part of the row change was adjusted so the collapsed row looks and behaves exactly as it does on main:

  • A single-quant row keeps its inference settings gear and its hover menu, and clicking the row still loads the model. The CI Playwright drivers (playwright_model_config.py, playwright_memory_estimate.py) open run settings from that gear, and keyboard users reach it with Tab.
  • The quant expander, which carries the Hub-only state (update available, pending companion), opens from a new Show quantizations item in the row menu instead of a chevron. Nothing asks the Hub until it is opened.
  • The collapsed row still reads disk only; the post-commit Hub probe stays removed. The backend inventory pool change is unchanged.

Before / after against a Hugging Face endpoint that accepts connections and never answers, three cached single-quant GGUF repos (Qwen3-0.6B, gemma-3-270m-it, SmolLM2-135M-Instruct, Q4_K_M each), base ea69b9cf2 vs head 0caba9251, each side its own fresh install:

before after
gguf-variants requests without offline=true when On Device opens 3 0
requests that reached the Hub endpoint while On Device opened 7 2
row gear present yes yes
row menu Pin, Delete Pin, Show quantizations, Delete
Hub listings after Show quantizations n/a 1 (that repo only)

Row menu on a single-quant row:

On Device row menu, before vs after

After choosing Show quantizations (before has no such item, so its list is unchanged):

On Device quant expander opened from the row menu

yannickloth added a commit to yannickloth/unsloth that referenced this pull request Oct 31, 2026
Stage 4 of unslothai#16267, stacked on unslothai#16271.

Opening an expander asks the Hub for what the disk cannot know: an update, a
pending MTP companion, the published default. When the Hub is slow or down, that
answer is lost and the row drops the badge and the action entirely.

Record the Hub-derived fields of every live answer beside the cache, and serve
them back when the Hub cannot answer, marked "cached": the row still shows what
the repo last said, and the update/companion actions are withheld because an
unreachable Hub cannot carry them out.

- hub/utils/variant_hub_state.py: per-repo JSON under the existing hub-state root,
  written atomically, stamped with observation time, credential identity and
  endpoint, so a gated listing is never served to another caller and a mirror
  switch starts clean. Holds Hub-only fields; downloaded/partial/sizes/cache
  paths always come from the cache walk, so a stale record cannot invent a row.
  Expires after 24 h.
- gguf_variants.py: get_gguf_variants_answer becomes a thin wrapper around the
  listing. The Hub verdict is stamped on the response inside the worker thread
  that computes it (thread-local, since the walk runs off the event loop), so a
  disk fallback is never recorded as a live answer. On failure the rows are
  re-read locally and the stored Hub state is merged over them.
- schemas: hub_state and observed_at on the response. Both response models carry
  them: routes/models.py rebuilds the response field by field and would otherwise
  drop them.
- pickers.tsx: a cached answer keeps the "update available" badge but offers no
  update and no companion download; an older server sends no hub_state and still
  reads as live.

Verified end to end against a switchable Hub endpoint: with the Hub reachable the
answer is "live" and a 21-quant record is written; with it cut, the same expander
answers "cached" in milliseconds from 1 on-disk row (never the 21 stored ones),
shows the badge for the recorded update, and offers no Update button.
yannickloth and others added 2 commits October 31, 2026 17:04
Fixes unslothai#16267.

Every picker open issued one Hugging Face listing per cached GGUF repo, from the
sole-quant probe unslothai#12460 added: a disk read filled the chip, then a second listing
without offline=true asked the Hub whether an update or a missing companion
should send the row back to its expander. With the Hub slow that is one
round-trip per installed repo on the popup path, and ten of them at once took
150-215 s server-side (client timeout 30 s) in the report.

The probe is gone. A sole-quant row renders the disk answer and carries the same
chevron as every other On Device row, so the expander — which already merges the
Hub listing and the update/companion state that comes with it — is reachable
without asking the Hub to decide whether the row can be opened. Its settings move
into that expander, keeping the row's one 38px gutter, as multi-quant rows do.

Also moves the cached-inventory walk off the loop's default executor onto its own
two-thread pool: asyncio.to_thread there queued every other to_thread caller
behind a cold walk, the starvation unslothai#14038 fixed for the variant listings.

Verified on a 10-repo cache against the same build: 7 disk-only variant requests
and 7 Hub probes per picker open before, 7 disk-only and 0 probes after, three
opens each. Expanding a row issues its disk listing plus one Hub listing, for
that repo only.

Tests: picker contracts updated for the removed probe and the moved gear; a new
backend test pins the walk to its own pool.
@yannickloth
yannickloth force-pushed the fix/on-device-picker-hub-probes branch from 995cb41 to 4c8969d Compare October 31, 2026 16:04
yannickloth added a commit to yannickloth/unsloth that referenced this pull request Oct 31, 2026
Stage 4 of unslothai#16267, stacked on unslothai#16271.

Opening an expander asks the Hub for what the disk cannot know: an update, a
pending MTP companion, the published default. When the Hub is slow or down, that
answer is lost and the row drops the badge and the action entirely.

Record the Hub-derived fields of every live answer beside the cache, and serve
them back when the Hub cannot answer, marked "cached": the row still shows what
the repo last said, and the update/companion actions are withheld because an
unreachable Hub cannot carry them out.

- hub/utils/variant_hub_state.py: per-repo JSON under the existing hub-state root,
  written atomically, stamped with observation time, credential identity and
  endpoint, so a gated listing is never served to another caller and a mirror
  switch starts clean. Holds Hub-only fields; downloaded/partial/sizes/cache
  paths always come from the cache walk, so a stale record cannot invent a row.
  Expires after 24 h.
- gguf_variants.py: get_gguf_variants_answer becomes a thin wrapper around the
  listing. The Hub verdict is stamped on the response inside the worker thread
  that computes it (thread-local, since the walk runs off the event loop), so a
  disk fallback is never recorded as a live answer. On failure the rows are
  re-read locally and the stored Hub state is merged over them.
- schemas: hub_state and observed_at on the response. Both response models carry
  them: routes/models.py rebuilds the response field by field and would otherwise
  drop them.
- pickers.tsx: a cached answer keeps the "update available" badge but offers no
  update and no companion download; an older server sends no hub_state and still
  reads as live.

Verified end to end against a switchable Hub endpoint: with the Hub reachable the
answer is "live" and a 21-quant record is written; with it cut, the same expander
answers "cached" in milliseconds from 1 on-disk row (never the 21 stored ones),
shows the badge for the recorded update, and offers no Update button.
@danielhanchen danielhanchen self-assigned this Nov 1, 2026
… row menu

The collapsed row stays as it was (gear, hover menu, click loads), so run settings
remain one click away and the Playwright drivers that open them from the row's gear
keep working. The expander, which carries the Hub-only update and companion state,
opens from a Show quantizations item in the row menu; nothing asks the Hub until then.

[skip ci]
Main moved the On Device rows into memo components (unslothai#16316). The sole-quant row
component keeps its gear and menu, drops the Hub follow-up probe, and opens the
shared quant expander from a Show quantizations item in its menu.

[skip ci]
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 1, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 1, 2026
@danielhanchen

Copy link
Copy Markdown
Member

Review record for #16271, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#671.

Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found.

Round 1: reviewed mirror d5dd6288c (no equivalent commit found on this PR)

chatgpt-codex-connector[bot] (on the mirror)

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

Reviewed commit: d5dd6288ce

No triage reaction was recorded on the mirror

Verdict

The round converged at mirror d5dd6288c (no equivalent commit found on this PR).

This is the review as it stood at that commit. Anything pushed to this PR afterwards was not part of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Studio: On Device model picker stalls ~20 min and times out — every cached GGUF is re-probed against Hugging Face on open

2 participants