Repository navigation
Studio: answer a collapsed On Device row from disk, not the Hub - #16271
Merged
danielhanchen merged 6 commits intoNov 1, 2026
Merged
Conversation
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.
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
force-pushed
the
fix/on-device-picker-hub-probes
branch
from
October 31, 2026 16:04
995cb41 to
4c8969d
Compare
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.
… 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
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
|
This was referenced Nov 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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=trueasked 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-variantsp50 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,soleQuantNeedsExpanderand itscreateTaskLimiterpool are gone.useSoleDownloadedQuantsis disk-only.renderSoleQuantGgufRowgets 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.renderGgufExpandRowis the shared expander block both row kinds now use.gguf-discovery.ts:hubWithdrawsSoleQuantandcreateTaskLimiterare deleted; nothing else used them.Backend
cache_inventory.py: the cached-inventory walk moves offasyncio.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 otherto_threadcaller 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:mainat caf0a3bAll 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: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 toreadSoleQuant(the only caller that passesoffline=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 itsselectMetainto a load.studio/backend/hub/tests/test_model_services.py— newtest_cached_inventory_scan_keeps_off_the_default_executorfails onmain(asyncio's default pool names its threadsasyncio_0) and passes here; the existing shared-scan test now stubs the new helper.npm run typecheck,npm run i18n:check:strict, the full frontend suite (14520 pass, 1 pre-existing date-dependent failure inhalloween-trick-or-treatthat also fails onmain), ESLint on the touched files (same 9 pre-existing errors asmain, no new ones), and the backend files above (356 pass; the 12 failures intest_model_services.pyalso fail onmainin this environment).Biome reports pre-existing drift across
pickers.tsx, so I did not runbiome check --writeover 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 onfeat/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:playwright_model_config.py,playwright_memory_estimate.py) open run settings from that gear, and keyboard users reach it with Tab.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
ea69b9cf2vs head0caba9251, each side its own fresh install:gguf-variantsrequests withoutoffline=truewhen On Device opensRow menu on a single-quant row:
After choosing Show quantizations (before has no such item, so its list is unchanged):