Skip to content

Studio: list each on-disk quant of a multi-quant GGUF in GET /v1/models - #13422

Merged
danielhanchen merged 5 commits into
mainfrom
studio-list-quant-pins
Oct 12, 2026
Merged

danielhanchen merged 5 commits into
mainfrom
studio-list-quant-pins

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Fixes #9340

Problem

A model with several downloaded quants (the report: Q8_0 and Q4_K_M of one repo) appears once in GET /v1/models, naming a single quant. Chat completions already accept "model": "<repo>:<quant>", and since #12727 GET /v1/models/<repo>:<quant> resolves too, but clients that only offer a dropdown built from /v1/models (Open WebUI style pickers) have no way to pick the other quant, and everyone else has to load the model in Studio first to learn the exact name.

Change

GET /v1/models now also lists <repo>:<quant> for every on-disk quant of a GGUF repo that has more than one, right after the repo's bare row:

unsloth/SmolLM2-135M-Instruct-GGUF          quant Q4_K_M  (unchanged, still serves the preferred quant)
unsloth/SmolLM2-135M-Instruct-GGUF:Q4_K_M
unsloth/SmolLM2-135M-Instruct-GGUF:Q8_0
  • Each pin row is built by the same helper GET /v1/models/<repo>:<quant> uses, so retrieving a listed id returns the identical object. The resident quant's row is loaded: true with its context fields; the others are loaded: false without them.
  • A row is only listed when the resolver honours that pin, so every listed id is one chat completions accepts. The check reads the resolver's published index and never rebuilds it per request (its TTL is 5 s, and a rebuild is the multi-root scan the catalog caches exist to avoid); only a listing that arrives before the index was ever built builds it once, so a client that reads the list once at connect still sees every quant.
  • Repos with a single quant, standalone .gguf files, non-GGUF checkpoints and TTS / media rows are unchanged (the bare id already names them).
  • Managed accounts only see pins of repos already in their own listing.
  • Only the public listing changes. The internal catalog used for 404 messages and for GET /v1/models/{id} is untouched, as are the Studio chat picker, unsloth start (it reads /api/inference/loaded-models) and notebooks.

Loading a quant other than the resident one still needs Settings > Model auto-switch > Switch model by request, as before.

Verification

Live Studio on a GPU (backend from main vs this branch, same install and llama-server, isolated HF cache holding unsloth/SmolLM2-135M-Instruct-GGUF Q8_0 + Q4_K_M, auto-switch on), choosing each id straight from the listing:

step main this branch
GET /v1/models (SmolLM2 rows) GGUF (quant Q4_K_M) GGUF, GGUF:Q4_K_M, GGUF:Q8_0
chat with GGUF:Q4_K_M from the list not listed 200, llama-server serves Q4_K_M
chat with GGUF:Q8_0 from the list not listed 200, llama-server switches to Q8_0, GET /v1/models/...GGUF:Q8_0 reports loaded: true
chat with bare GGUF 200, Q4_K_M 200, Q4_K_M (unchanged)

GET /v1/models on the real catalog scan (in process, 200 calls after warmup, two interleaved rounds): main 5.8 / 4.5 ms median, this branch 5.2 / 4.7 ms, within noise.

Tests: four new cases in tests/test_openai_catalog.py (every quant listed after the bare row and retrievable as the same object, only the resident pin marked loaded, a pin the resolver would not honour is not listed, the index is built for pins only when it never was). The listing cases fail on main and pass here; the index case fails when the listing is pointed back at the rebuilding lookup. Across the 19 backend test files that touch /v1/models, the resolver or auto-switch (1600 tests), the failing test IDs are identical on main and this branch (28 pre-existing failures on this host, the same IDs on both).

@danielhanchen danielhanchen self-assigned this Oct 12, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 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-10-12T13:36:48.008336Z 0adfe54 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 chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 688916e1aa

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

wanted = {m.strip() for m in (output_modalities or "").split(",")}
if not wanted & {"all", "decisions"}:
return {"object": "list", "data": await _openai_catalog_objects()}
return {"object": "list", "data": await _openai_catalog_objects(quant_pins = True)}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Update the existing zero-argument catalog test double

When openai_list_models is exercised by test_studio_lists_its_decision_models_only_when_asked, that existing test replaces _openai_catalog_objects with the zero-argument coroutine chat_catalog (studio/backend/tests/test_systemone_connections.py:509-511). Every non-decision listing now supplies quant_pins=True, so calls such as ids() and ids("text") raise TypeError: chat_catalog() got an unexpected keyword argument 'quant_pins' before their assertions, breaking the backend test suite; the test double must be updated as part of this signature change.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in f26caa8: the System One test double now accepts quant_pins (the test was not collected here without fastmcp; reproduced the TypeError after installing it).

Comment on lines +737 to +738
for mid in ("publisher/Qwen3:Q8_0", "publisher/Qwen3:Q4_K_M"):
assert _retrieve(mid) == rows[mid]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Freeze time before comparing separately generated model objects

This equality compares a row saved from one _listed() call with objects produced by later _retrieve() calls, while each path independently sets created = int(time.time()) in _openai_catalog_objects. If execution crosses a one-second boundary between those calls, the objects differ only in created and the test fails nondeterministically; freeze time.time() for this test or exclude the volatile field from the comparison.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in f26caa8: the cross-call comparison ignores created.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 12, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 0adfe5491e

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

@VTplus

VTplus commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Nice — seeing every on-disk quant listed now.

One gap we ran into while testing the new entries, though: the per-quant ids themselves don't load.

POST /api/inference/load with model_path = "unsloth/GLM-4.7-Flash-GGUF:UD-Q6_K_XL" (current main, 8d4d52b74):

  • The whole string is treated as one model id, and repo-id validation rejects the colon (Repo id must use alphanumeric chars, '-', '_' or '.' …), so the GGUF path is never selected — it falls through to transformers (tier 530, fresh inference subprocess) and fails after ~100 s (Both AutoConfig and PeftConfig loading failed).

  • Compounding it: the POST still completes with 200 (Model load failed with 500 after the response committed), so API clients keep waiting on a load that is already dead.

16:16:32  Could not check GGUF files for 'unsloth/GLM-4.7-Flash-GGUF:UD-Q6_K_XL' after 3 attempts: Repo id must use alphanumeric chars, '-', '_' or '.' …
16:16:32  Transformers tier 530 selected for unsloth/GLM-4.7-Flash-GGUF:UD-Q6_K_XL (substring match: glm-4.7-flash)
16:17:44  Model load failed with 500 after the response committed
16:17:44  request_completed POST /api/inference/load 200 (102504 ms)

Either way, the 200-on-failed-load seems worth a look.

(Context: hit while testing the scan-folder rewrite area of #13343 — unrelated to that change; the id passes through that rewrite untouched either way.)

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] Specific Quantization of the model is not listed in Model List API

2 participants