Skip to content

fix(studio): preserve chat GGUF variants across cache-folder changes - #10438

Closed
Imagineer99 wants to merge 37 commits into
unslothai:mainfrom
Imagineer99:fix/gguf-cache-location-variants
Closed

Imagineer99 wants to merge 37 commits into
unslothai:mainfrom
Imagineer99:fix/gguf-cache-location-variants

Conversation

@Imagineer99

@Imagineer99 Imagineer99 commented Sep 7, 2026 •

Copy link
Copy Markdown
Member

A user reported on Discord that chat GGUF quantizations downloaded into different folders stop appearing together after switching the download folder back to default. Their Q6 variant was in the default cache and Q8 in a custom cache.

Keep one repository row and discover complete chat variants across remembered caches, preferring the active cache for duplicates. A completed recorded download takes precedence over an interrupted duplicate. Loading, copying, quant deletion, memory estimates, and per-quant context metadata resolve the selected source. Startup uses the logical repository identity. The shared Hub configuration flow receives the selected quant directly.

Pins survive while another complete downloaded copy remains, including cache folders with different repository-ID casing. Pin cleanup retains request credentials and avoids removing pins on unconfirmed scans. Explicit filesystem listings retain their scope. Image/video GGUF loading is outside this change; shared media lookup and pin callbacks retain their prior cache scope.

Online listings reuse successful Hub metadata within the request and apply the existing snapshot readiness/update checks. Complete remembered chat sources can answer transient Hub failures, while HTTP 401/403/404/429 errors still surface.

Closes #10437.

Validation on preceding commit bb8abccb9 (integrated main 4953744e4):

  • Backend regression suite: 1,394 passed, 1 skipped. Python compatibility: all 8 checks passed.
  • Full frontend suite: 7,116 passed. Production and test TypeScript checks passed. Repository contracts: 179 passed.
  • Latest A/B: 12 backend failures before the media-scope/projector-duplicate fixes and 3 missing-token callback failures before token forwarding. All corrected paths and their controls pass afterward, including offline download-worker reuse.
  • Coverage includes both folder-switch directions, duplicate survival, last-copy deletion, split/incomplete downloads, selected-source actions and metadata, and interrupted projector downloads recorded in manifests.
  • Worktree and pre-push gates passed. The prior head 47ba1bca1 had 49 successful and 10 skipped CI checks; Upstream CI on this head was cancelled by a maintainer. Fork validation on the exact head finished with 17 successful workflows, one skipped workflow, and one failed workflow. Frontend CI passed 7,116 tests on both Linux and Windows; both backend Python jobs passed. The CPU suite had 17,985 passes and two failures reproduced identically on base 4953744e4: missing ruff in the test environment, and two unencoded read_text() calls in tests/test_wheel_smoke_publish_guard.py. The Rust lock test and browser-dependency installation passed targeted retries. These results do not replace upstream required checks or approval. The anonymous pin-reconciliation finding is fixed in c411b2dd6: a public variant listing cannot invalidate a complete copy confirmed by disk inventory. The download-card observation was verified as pre-existing.

Validation on current commit c411b2dd6:

  • Anonymous pin regression A/B: 2 failed / 20 passed before; all 22 passed after. Confirmed absence and partial-only inventory still remove stale pins.
  • Full frontend suite: 7,120 passed. Production and test TypeScript checks passed; repository contracts: 179 passed. Existing backend authentication/cache-switch controls: 4 passed.
  • Worktree checks against main 999dd8500 and the pre-push gate passed. The full backend suite and fork CI above belong to the preceding commit; current-head upstream CI and review remain pending.

Original cache-switch A/B evidence on narrowed candidate 76821802750a65abf3b46b11229702867509133a:

  • Identical behavioral probes: baseline 8 failed / 2 passed; candidate 10 passed. Covers both folder-switch directions, both listing APIs, inactive-quant deletion, and offline download-worker reuse.
  • Live Chromium: one repository row on both sides; Q6_K only before, Q6_K and Q8_0 selectable after. Separate Studio homes, processes, and fresh frontend bundles with commit stamps.

UI evidence uses isolated 256-byte cache fixtures, not full model inference. Validation ran locally on Linux under WSL. Existing PR history is preserved.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 7, 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-09-08T16:19:37.109286Z c411b2d 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[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 7, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 7, 2026
@wasimysaid

Copy link
Copy Markdown
Collaborator

Live Studio A/B — the missing-quant bug reproduces on main, head fixes it

Head c411b2dd6c vs main 64e4d52d4, two real Studio installs. Seeded a real HF cache layout for two quantizations of the same repo (sparse files at true Hub sizes, since Studio decides "downloaded" from on-disk bytes), then pointed the models dir at the folder, switched back, and re-listed.

  • main: only Q8_0 is listed — Q4_K_M is missing. That is the original bug.
  • head: both quants are listed, each with its own cache_path.

Confirmed; no blockers seen on this head in the live run.

wasimysaid added a commit to wasimysaid/unsloth-pr-ui-evidence that referenced this pull request Sep 21, 2026
wasimysaid added a commit to wasimysaid/unsloth-pr-ui-evidence that referenced this pull request Sep 21, 2026
@wasimysaid

Copy link
Copy Markdown
Collaborator

Screenshots for the live A/B above — on-device listing after switching the models dir away and back, head c411b2dd6c vs main 64e4d52d4.

main — the repo collapses to a single variant and only Q8_0 survives:

main on-device list

The seeded cache held two quants (Q8_0 and Q4_K_M); main shows one row, Q8_0 only. That is the #10437 bug.

head — both quants present, each with its own cache_path:

head on-device quants

Both Q8_0 (downloaded, 1.1GB) and Q4_K_M (downloaded, 806MB) are listed for gemma-3-1b-it-GGUF.

Confirmed; no blockers seen on this head. Caveat as before: the cache files were seeded as sparse placeholders at the true Hub sizes, since Studio decides "downloaded" from on-disk bytes.

wasimysaid pushed a commit to wasimysaid/unsloth that referenced this pull request Sep 22, 2026
The variant listing resolved a repo against one cache folder at a time, so moving
the download folder (or switching back to the default) dropped quants that were
still on disk in another remembered folder, and the surviving rows lost the
cache_path of the copy they describe.

List logical quants across the active cache and every remembered folder, keeping
each quant's own cache_path, and reconcile them with the download-state rows so
the picker shows one row per quant no matter which folder holds it. Deletes and
loads then resolve the same copy the listing named.

Closes unslothai#10437

Adapted from unslothai#10438 onto current main.
wasimysaid pushed a commit to wasimysaid/unsloth that referenced this pull request Sep 22, 2026
The variant listing resolved a repo against one cache folder at a time, so moving
the download folder (or switching back to the default) dropped quants that were
still on disk in another remembered folder, and the surviving rows lost the
cache_path of the copy they describe.

List logical quants across the active cache and every remembered folder, keeping
each quant's own cache_path, and reconcile them with the download-state rows so
the picker shows one row per quant no matter which folder holds it. Deletes and
loads then resolve the same copy the listing named.

Closes unslothai#10437

Adapted from unslothai#10438 onto current main.
@danielhanchen danielhanchen self-assigned this Sep 25, 2026
Resolve conflicts with main: keep host-path redaction and cache authorization on the
variants routes alongside include_cache_locations, drop shard_count removed upstream,
restore the is_anonymous import, and adapt the cache-switch tests to the API-key
dependency and the Hub access probe.
Windows identifies cache blobs by size when the hash is unreadable, so the
update-available precondition is POSIX only; the merged-vs-direct parity stays
on every platform. macOS tmp_path lives under /private/var, which the download
folder guard denies, so exempt the test's own tmp_path.
shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Sep 25, 2026
wasimysaid added a commit to wasimysaid/unsloth that referenced this pull request Sep 25, 2026
The variant listing resolved a repo against one cache folder at a time, so moving
the download folder (or switching back to the default) dropped quants that were
still on disk in another remembered folder, and the surviving rows lost the
cache_path of the copy they describe.

List logical quants across the active cache and every remembered folder, keeping
each quant's own cache_path, and reconcile them with the download-state rows so
the picker shows one row per quant no matter which folder holds it. Deletes and
loads then resolve the same copy the listing named.

Closes unslothai#10437

Adapted from unslothai#10438 onto current main.
wasimysaid added a commit that referenced this pull request Sep 25, 2026
* fix(studio): keep every chat GGUF quant listed across cache folders

The variant listing resolved a repo against one cache folder at a time, so moving
the download folder (or switching back to the default) dropped quants that were
still on disk in another remembered folder, and the surviving rows lost the
cache_path of the copy they describe.

List logical quants across the active cache and every remembered folder, keeping
each quant's own cache_path, and reconcile them with the download-state rows so
the picker shows one row per quant no matter which folder holds it. Deletes and
loads then resolve the same copy the listing named.

Closes #10437

Adapted from #10438 onto current main.

* fix(studio): judge merged offline GGUF sources by their own state

A remembered cache's quants are merged into the listing when the request
is local-only or offline, and there the Hub readiness pass cannot run.
Every merged source was therefore reported as downloaded, so a copy whose
main shards are complete but whose projector or drafter never finished was
advertised as a model the picker could load, while the same snapshot
requested directly reported it partial and offered the resume.

Judge each source against its own snapshot instead, with the same local
manifest, marker and blob check the direct listing uses, and fall back to
a partial row when it does not pass.

Reported-by: Codex review (P2) on #204.

* test(studio): accept the cache-location flag in the boundary stub

The route now forwards `include_cache_locations` to the variants service, so
the inventory boundary test's stub of that service has to accept it; otherwise
the call raises inside the endpoint and the route answers 500.

* fix(studio): rank duplicate GGUF sources by their own partial state

A remembered copy of a quant could shadow a healthy duplicate when the
shadowed copy was verified complete by its manifest but still marked
partial by its own snapshot state, such as a cancellation marker: the
merge then reported the quant as unusable and offered a retry while the
loadable duplicate was omitted from the listing.

Rank duplicates on the full per-snapshot partial verdict in addition to
the completed-vs-incomplete manifest rule.

Reported-by: Codex review (P2) on #204.

* fix(studio): rank loader candidates by snapshot state, not manifest alone

`_cached_variant_candidates` ordered cached copies by manifest completeness
only, so an active snapshot a cancellation marker had already invalidated was
yielded before a healthy duplicate in a remembered folder; the merged listing
picked the healthy copy but `cached_gguf_for_load` could still open the
cancelled one and fail offline on the interrupted companion.

Rank on the same full per-snapshot verdict the listing uses.

The delete preview also named the folder it would delete, so an API-key
authenticated request read the host's absolute cache directory out of
`/api/hub/delete-impact`. It now passes through the host-path boundary and
answers with the opaque `cache_ref` the delete call already accepts; a
browser session still reads the path.

Reported-by: Codex review (P1/P2) on #204.

* fix(studio): keep remembered-cache quants reachable and referenced

Four follow-ups from the same review area:

- The merged-listing pass had a second anonymous test after
  `hub_cached_read_refused` had already authorized this caller, so a public
  repo's authorized anonymous read lost quants that exist only in a
  remembered folder. The authorization verdict decides; trust it.
- A quant the snapshot lists but does not complete -- an interrupted split
  download -- was dropped from the merge entirely, so it could neither be
  marked partial nor keep its folder. It is now a fallback source that the
  merge reports as a resume, not as a loadable copy.
- Merging can change which rows are root-level, and the default is chosen
  among root rows; keep the merged set's own answer instead of the one the
  active cache picked alone.
- Both variant response models now declare the opaque `cache_ref` sibling
  the host-path boundary adds, so FastAPI serialization keeps the only
  handle an API-key caller has for pinning a later delete to a listed copy.

Reported-by: Codex review on #204.

* fix(studio): judge merged cached sources by their own state and reference

Addresses the review findings on the remembered-cache merge:

- Rank duplicate sources on the current revision's companion readiness, which
  only that copy's own Hub answer knows, so a usable duplicate is not discarded
  for one the snapshot judges partial.
- Apply that same local partial verdict to a quant the current revision no
  longer lists, instead of keeping the synthesized loadable row.
- Prefer downloaded non-partial rows when recomputing the merged default.
- Carry partial transport, resumability and remaining bytes from the copy's own
  folder so a remembered partial keeps its resume affordance.
- Forward the redacted cache reference as the delete target, and declare it on
  the variant model so it survives response serialization.

Focused regressions cover each; reverting the fixes fails them.

* fix(studio): delete the cached GGUF copy the row names

A logical quant delete carries no folder, so the server re-resolved its
target with the local-only duplicate ranking while the listing had ranked
those duplicates by their own scoped companion readiness. The two can
disagree, and the delete then removed a copy the row never showed.

Carry the listed copy's own cache path through the expander row, the
pinned-quant row (from the validation listing) and the delete preview, so
preview and delete act on the copy the user sees.

* fix(studio): keep redacted GGUF deletes on the listed copy

Host-path redaction nulls cache_path and answers with the opaque cache_ref,
so a picker row that forwards only the cleared path sends nothing and the
server re-ranks duplicates by local-only state. The chat variant model now
declares cache_ref, the expander, sole-quant, and pinned-copy rows prefer it
for both the delete and its preview, and the disk card previews the same
identity its delete sends.

* fix(studio): settle the GGUF replacement's review findings at the current baseline

Restore the deleted useDeleteConfirmAction invocation that left the download
card's confirm dialog unparsable, judge a remembered partial's resume affordance
against the cache root a resume really continues in, keep the bare repo pin while
a runnable non-GGUF copy survives, and type the pinned-variant map so the frontend
projects compile.

* fix(studio): resolve GGUF quants across remembered cache folders

* test(studio): keep cache-aware picker contracts current

* fix(studio): retain single-cache GGUF snapshot pins and normalize formatting

* fix(studio): reject invalid targeted GGUF delete previews

* test(studio): group GGUF cache-switch regressions by scenario
@wasimysaid wasimysaid closed this Sep 25, 2026
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…ai#11938)

* fix(studio): keep every chat GGUF quant listed across cache folders

The variant listing resolved a repo against one cache folder at a time, so moving
the download folder (or switching back to the default) dropped quants that were
still on disk in another remembered folder, and the surviving rows lost the
cache_path of the copy they describe.

List logical quants across the active cache and every remembered folder, keeping
each quant's own cache_path, and reconcile them with the download-state rows so
the picker shows one row per quant no matter which folder holds it. Deletes and
loads then resolve the same copy the listing named.

Closes unslothai#10437

Adapted from unslothai#10438 onto current main.

* fix(studio): judge merged offline GGUF sources by their own state

A remembered cache's quants are merged into the listing when the request
is local-only or offline, and there the Hub readiness pass cannot run.
Every merged source was therefore reported as downloaded, so a copy whose
main shards are complete but whose projector or drafter never finished was
advertised as a model the picker could load, while the same snapshot
requested directly reported it partial and offered the resume.

Judge each source against its own snapshot instead, with the same local
manifest, marker and blob check the direct listing uses, and fall back to
a partial row when it does not pass.

Reported-by: Codex review (P2) on unslothai#204.

* test(studio): accept the cache-location flag in the boundary stub

The route now forwards `include_cache_locations` to the variants service, so
the inventory boundary test's stub of that service has to accept it; otherwise
the call raises inside the endpoint and the route answers 500.

* fix(studio): rank duplicate GGUF sources by their own partial state

A remembered copy of a quant could shadow a healthy duplicate when the
shadowed copy was verified complete by its manifest but still marked
partial by its own snapshot state, such as a cancellation marker: the
merge then reported the quant as unusable and offered a retry while the
loadable duplicate was omitted from the listing.

Rank duplicates on the full per-snapshot partial verdict in addition to
the completed-vs-incomplete manifest rule.

Reported-by: Codex review (P2) on unslothai#204.

* fix(studio): rank loader candidates by snapshot state, not manifest alone

`_cached_variant_candidates` ordered cached copies by manifest completeness
only, so an active snapshot a cancellation marker had already invalidated was
yielded before a healthy duplicate in a remembered folder; the merged listing
picked the healthy copy but `cached_gguf_for_load` could still open the
cancelled one and fail offline on the interrupted companion.

Rank on the same full per-snapshot verdict the listing uses.

The delete preview also named the folder it would delete, so an API-key
authenticated request read the host's absolute cache directory out of
`/api/hub/delete-impact`. It now passes through the host-path boundary and
answers with the opaque `cache_ref` the delete call already accepts; a
browser session still reads the path.

Reported-by: Codex review (P1/P2) on unslothai#204.

* fix(studio): keep remembered-cache quants reachable and referenced

Four follow-ups from the same review area:

- The merged-listing pass had a second anonymous test after
  `hub_cached_read_refused` had already authorized this caller, so a public
  repo's authorized anonymous read lost quants that exist only in a
  remembered folder. The authorization verdict decides; trust it.
- A quant the snapshot lists but does not complete -- an interrupted split
  download -- was dropped from the merge entirely, so it could neither be
  marked partial nor keep its folder. It is now a fallback source that the
  merge reports as a resume, not as a loadable copy.
- Merging can change which rows are root-level, and the default is chosen
  among root rows; keep the merged set's own answer instead of the one the
  active cache picked alone.
- Both variant response models now declare the opaque `cache_ref` sibling
  the host-path boundary adds, so FastAPI serialization keeps the only
  handle an API-key caller has for pinning a later delete to a listed copy.

Reported-by: Codex review on unslothai#204.

* fix(studio): judge merged cached sources by their own state and reference

Addresses the review findings on the remembered-cache merge:

- Rank duplicate sources on the current revision's companion readiness, which
  only that copy's own Hub answer knows, so a usable duplicate is not discarded
  for one the snapshot judges partial.
- Apply that same local partial verdict to a quant the current revision no
  longer lists, instead of keeping the synthesized loadable row.
- Prefer downloaded non-partial rows when recomputing the merged default.
- Carry partial transport, resumability and remaining bytes from the copy's own
  folder so a remembered partial keeps its resume affordance.
- Forward the redacted cache reference as the delete target, and declare it on
  the variant model so it survives response serialization.

Focused regressions cover each; reverting the fixes fails them.

* fix(studio): delete the cached GGUF copy the row names

A logical quant delete carries no folder, so the server re-resolved its
target with the local-only duplicate ranking while the listing had ranked
those duplicates by their own scoped companion readiness. The two can
disagree, and the delete then removed a copy the row never showed.

Carry the listed copy's own cache path through the expander row, the
pinned-quant row (from the validation listing) and the delete preview, so
preview and delete act on the copy the user sees.

* fix(studio): keep redacted GGUF deletes on the listed copy

Host-path redaction nulls cache_path and answers with the opaque cache_ref,
so a picker row that forwards only the cleared path sends nothing and the
server re-ranks duplicates by local-only state. The chat variant model now
declares cache_ref, the expander, sole-quant, and pinned-copy rows prefer it
for both the delete and its preview, and the disk card previews the same
identity its delete sends.

* fix(studio): settle the GGUF replacement's review findings at the current baseline

Restore the deleted useDeleteConfirmAction invocation that left the download
card's confirm dialog unparsable, judge a remembered partial's resume affordance
against the cache root a resume really continues in, keep the bare repo pin while
a runnable non-GGUF copy survives, and type the pinned-variant map so the frontend
projects compile.

* fix(studio): resolve GGUF quants across remembered cache folders

* test(studio): keep cache-aware picker contracts current

* fix(studio): retain single-cache GGUF snapshot pins and normalize formatting

* fix(studio): reject invalid targeted GGUF delete previews

* test(studio): group GGUF cache-switch regressions by scenario
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.

[Studio Bug] GGUF quantizations disappear after switching the model download folder

3 participants