Skip to content

fix(studio): retain GGUF quants across cache-folder switches - #11938

Merged
wasimysaid merged 18 commits into
unslothai:mainfrom
wasimysaid:mimir/gguf-cache-folder-variants-10438
Sep 25, 2026
Merged

wasimysaid merged 18 commits into
unslothai:mainfrom
wasimysaid:mimir/gguf-cache-folder-variants-10438

Conversation

@wasimysaid

Copy link
Copy Markdown
Collaborator

Fixes #10437. This is an upstream proposal of the already-reviewed fork PR #204, replacing—not modifying—the earlier #10438 proposal. Credit to @Imagineer99 for the original contribution and investigation.

Problem and fix

Changing Studio's active GGUF download folder could hide real quantizations that remained in a previously used cache folder. A repo-level row could then select the wrong copy for loading or deletion. Discover quants across remembered cache roots, retain each quant's source through the model picker and actions, and reject invalid targeted delete previews consistently with deletion.

Evidence at reviewed head 8872a8bf35afef8628f2e25241284e32f9b9141c

  • Regression: The four cache-switch assertions fail on the fork's baseline 525acb8 (only one quant visible, depending on active folder) and pass on the fix. At this final head, 668 focused GGUF/cache/companion tests passed, including four invalid-target delete-preview cases added after a valid review finding. Actual unsloth/gemma-3-270m-it-GGUF Q6_K and Q8_0 files were also checked in separate roots at the final head. Full fork verification.
  • New exact-head live Studio evidence (Linux, Chromium 1500×1000, CPU): Real Q6_K (282,975,264 bytes, SHA-256 9826846190dea7bdd334fb834d5a1d3b8bf95b14a9833fe792e0abbc49b4927f) and Q8_0 (291,546,144 bytes, SHA-256 d156a5159f2f79c1b1d53c7c1cc20f1ff28ab8d00f17a292620aad13399b9698) remained On device together after changing the active folder to a custom cache and back. Selecting Q6_K updated the picker. Separately, authenticated calls loaded and unloaded each real quant via CPU llama-server (HTTP 200; server logs identify the distinct files), and targeted Q8_0 delete-impact/deletion removed only its custom-cache file while preserving the Q6_K SHA-256 in the default cache. The screenshot depicts visibility and selection before those API actions, not a model-loading or deletion screen.

Chromium captures at the same pinned head, before loading and scoped deletion (these images do not depict inference or file deletion):

Studio model picker displays real Q8_0 and Q6_K as On device after cache-folder switch

Studio model picker shows Q6_K selected and On device

Fork PR #204's exact-head Codex review found no major issues. Its CI at this head finished with 59 passing checks, 4 skipped, and one failing CPU Studio repository-test check: the unrelated desktop UI-scale assertion (size-30px count 4 vs 3) was separately reproduced on unchanged fork main. This failure is disclosed, not counted as passing; upstream CI must be evaluated on this PR independently.

Scope and limitations: The upstream-main merge base is ed55faabd7da8616a7202e9f6c20e771c56c83a9; the GitHub three-dot comparison is 15 branch commits touching 32 GGUF/Studio files (+2,193/−105), not upstream-only commits since that base. The new screenshot proves two rendered rows and picker selection; CPU load/unload and scoped delete have separate authenticated logs/file hashes. No completion-generation turn, GPU run, reporter's Ornith model, or native Windows/desktop run was performed in this new validation. Original #10438 remains untouched.

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.
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.
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.
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.
…lone

`_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.
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.
…ence

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.
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.
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.
…rent 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.
@wasimysaid
wasimysaid force-pushed the mimir/gguf-cache-folder-variants-10438 branch from 8872a8b to eafca6b Compare September 25, 2026 17:24
@wasimysaid
wasimysaid merged commit 7af9386 into unslothai:main Sep 25, 2026
52 of 58 checks passed
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant