Skip to content

Studio: load the selected GGUF quant, not a cached sibling (Q6_K loaded UD-Q6_K_XL) - #18006

Merged
Lyxot merged 3 commits into
unslothai:mainfrom
oobabooga:worktree-gguf-variant-exact-quant
Nov 17, 2026
Merged

Lyxot merged 3 commits into
unslothai:mainfrom
oobabooga:worktree-gguf-variant-exact-quant

Conversation

@oobabooga

@oobabooga oobabooga commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Selecting a GGUF quant can load a different quant that is already in the cache. With UD-Q6_K_XL downloaded, selecting Q6_K loads the UD-Q6_K_XL file and downloads nothing, while the UI still shows Q6_K. The same happens for Q2_K (loads Q2_K_L or UD-Q2_K_XL) and Q4_K_M (loads UD-Q4_K_M).

_gguf_files_for_variant picks the file for a quant. It looks for an exact name match first. If none is found, it tries a looser match, and that one also accepts UD-Q6_K_XL for Q6_K.

Before downloading, Studio checks the local cache with this function. If the cache only has UD-Q6_K_XL, there is no exact match for Q6_K, so the loose match returns UD-Q6_K_XL and Studio loads it.

With this PR, the loose match skips files whose quant is different from the one requested. So Q6_K no longer matches UD-Q6_K_XL, and Studio downloads the real Q6_K. Requests that are not quant names, such as a folder path, still use the loose match. When offline, selecting a quant that is not cached now shows the normal download error instead of loading a different quant.

Verification

Studio before and after the fix, with unsloth/Qwen3-0.6B-GGUF:

Cached Selected Before After
UD-Q6_K_XL Q6_K loads UD-Q6_K_XL, no download downloads and loads Q6_K
UD-Q6_K_XL, UD-Q2_K_XL Q2_K loads UD-Q2_K_XL, no download downloads and loads Q2_K

Quants that are already cached still load from the cache.

New tests in tests/test_offline_gguf_cache_fallback.py cover these cases; six of the seven fail without the fix. All backend tests that use the matcher or the cache check pass (1646 passed, 1 skipped).

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T05:17:27.795967Z e6c8016 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.

@oobabooga

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 36b0363af6

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

llama.cpp has no _XL quant type, so a bare selector such as Q4_K_XL (the spelling used in repo:TAG references) can only name the UD-Q4_K_XL build; the sibling-quant filter now accepts that alias while still refusing UD- builds of real llama.cpp types such as Q4_K_M.
@Lyxot

Lyxot commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

Pushed e6c8016 on top of this PR:

  • Fix: the sibling-quant filter also stopped bare *_XL names from resolving. Q4_K_XL (the repo:Q4_K_XL spelling) no longer found UD-Q4_K_XL, and the preflight in from_identifier rejected it as "variant not found". llama.cpp has no _XL quant type, so a bare *_XL name can only mean the UD- build, and the filter now accepts that alias. Names of real llama.cpp types (Q4_K_M, IQ1_S, ...) still refuse a UD- sibling, so bare IQ1_S no longer loads UD-IQ1_S as it did on main.
  • Tests: added cases for the _XL alias (single file and split shards in a quant folder) and for keeping a loose match when the file has no quant token of its own. Split the bpw case out of test_non_quant_variant_keeps_loose_match.

Checked against the real file lists of 19 GGUF repos. Every variant the UI lists resolves to exactly its own files, with nothing else cached and with only sibling quants cached. All 93 UD-*_XL quants also resolve correctly by their bare name.

@Lyxot

Lyxot commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: e6c8016d23

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

@Lyxot

Lyxot commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

Codex review and CI check are done for head e6c8016d23.

  • Codex: Didn't find any major issues on e6c8016d23. There were no unresolved review threads.
  • CI: the upstream checks were stuck in the queue, so CI ran on a staging copy with the same head and base (upstream main at f90ecaa139): [staging] unslothai/unsloth#18006: load the selected GGUF quant, not a cached sibling Lyxot/unsloth#248. 53 passed, 6 failed, 4 skipped. None of the failures involve the two files this PR changes:
    • test_lint_risky_loaders (the Source lint, workflow-trigger lint and Repo tests rest-2 jobs) flags unsloth/models/rl.py:5481. It is already on the base and fails the same way on another staging PR with this base.
    • In Repo tests (CPU, studio), the only failure is the test_no_skip_guard_reads_a_spoofable_accelerator_probe lint, which also fails on that other PR. The tests this PR touches passed.
    • Core (HF=latest + TRL=latest) fails the same way on that other PR.
    • test_gemma2_decode_norm_scratch_only_on_layer_devices in Repo tests (CPU, rest-2) and Core zoo (HF=latest + TRL=latest, an unsloth_zoo layer_types config error) are in code this PR doesn't touch.
  • Changed in this round: one commit, e6c8016d23. Bare *_XL names such as Q4_K_XL resolve to their UD- build again, with test cases added. Details are in the comment above.

@Lyxot Lyxot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Verified against the real file lists of 19 GGUF repos: every quant now resolves to its own files, including bare *_XL names.

@Lyxot
Lyxot merged commit ec95a83 into unslothai:main Nov 17, 2026
danielhanchen added a commit that referenced this pull request Nov 17, 2026
… fixed 0.1 s sleep (#18103)

`studio/backend/tests/test_anthropic_admission.py` fails intermittently
in the Studio `a-f` shard on unrelated PRs (#18045, #18006, #18069,
#18075):

```
test_non_streaming_queued_then_admitted
E   AssertionError: assert 0 == 1
E    +  where 0 = LlamaAdmissionSnapshot(..., capacity=1, active=1, queued=0, ...).queued
test_capacity_enforced_from_effective_parallel_slots
E   AssertionError: assert (3 == 3 and 3 == 3 and 0 == 1)
```

## Cause

Each of these tests occupies every slot, starts a request as a task,
sleeps a fixed 0.1 s and then expects the request to be in the admission
queue. On a loaded runner the handler sometimes has not reached the
queue within 0.1 s, so the snapshot still shows `queued=0`. The
admission code is not at fault; the test raced it.

## Fix

`_until_queued(task)` polls the queue snapshot every 10 ms until the
request is queued, for up to 5 s. It still fails if the request finishes
without ever queueing (`task.done()`) or never queues within the
deadline, so a request that skips admission is still caught. It replaces
the fixed sleep at all five sites that assert `queued == 1` right after
starting the task. The assertions themselves are unchanged.

## Verification

- `tests/test_anthropic_admission.py`: 39 passed, twice.
- Slow handler simulated locally (`await asyncio.sleep(0.25)` at the top
of `anthropic_messages`, not committed):
- main: the five queued checks fail (plus
`test_uncontended_hot_path_is_fast`, which is meant to catch a slow
handler).
  - this branch: only `test_uncontended_hot_path_is_fast` fails.
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.

3 participants