Skip to content

Fix Studio loaded-model GGUF quant label - #8238

Merged
danielhanchen merged 6 commits into
unslothai:mainfrom
Imagineer99:fix/loaded-models-q8-repro
Aug 9, 2026
Merged

danielhanchen merged 6 commits into
unslothai:mainfrom
Imagineer99:fix/loaded-models-q8-repro

Conversation

@Imagineer99

Copy link
Copy Markdown
Member

Summary

  • report the selected image GGUF quantization in diffusion status
  • show that quantization in the Loaded models indicator instead of the pipeline compute dtype
  • cover both diffusers and native sd.cpp paths, with a fallback for older backends

Root cause

The image runtime retained the selected GGUF filename internally, but /api/inference/images/status exposed only model_kind: "gguf" and dtype: "bfloat16". The Loaded models indicator consequently rendered GGUF · BF16 when Q8_0 was selected. BF16 described the pipeline compute precision, not the GGUF checkpoint quantization.

User impact

A Z-Image Q8_0 load now displays GGUF · Q8_0 · cuda rather than GGUF · BF16 · cuda.

Validation

  • Targeted GitHub Actions repro and fix-verification run
    • fixed output: PASS selected=z-image-turbo-Q8_0.gguf indicator=z-image · GGUF · Q8_0 · cuda
  • 72 loaded-model frontend tests passed
  • 5 focused backend tests passed, covering diffusers and native sd.cpp status producers
  • frontend TypeScript typecheck passed
  • git diff --check passed

@Imagineer99
Imagineer99 force-pushed the fix/loaded-models-q8-repro branch from a4feb65 to 36ac29b Compare August 9, 2026 08:44
@danielhanchen

Copy link
Copy Markdown
Member

Reviewed this and pushed one commit to the branch: a34408d.

The image fix is right, and the gguf_filename guard you added on the sd.cpp path is the one I was going to ask for. Running the whole file rather than just the new tests catches it: _SdState.gguf_filename is Optional[str], _loaded_backend() leaves it unset, and the unguarded extract_quant_token call made status() raise AttributeError, which would have taken down /api/inference/images/status entirely. tests/test_sd_cpp_backend.py is green now (68 passed).

What I added is the same defect on the video runtime. VideoBackend.status() reports model_kind: "gguf" with dtype: "bfloat16", and transformer_quant is pipeline-only, so describeVideoStatus fell through to the compute dtype exactly like the image row did. A Q4_K_M LTX-2 load showed wan · GGUF · BF16 · cuda.

The commit mirrors your approach rather than inventing a second one:

  • video.py status() reports gguf_variant from extract_quant_token(state.gguf_filename), guarded on state.kind == "gguf" and a non-null filename
  • VideoStatusResponse carries the field
  • VideoStatus in features/video/api.ts carries it, and describeVideoStatus prefers it over transformer_quant / dtype, with model_kind === "gguf" || gguf_variant gating the GGUF tag so an older backend still renders one
  • tests: a backend one asserting Q4_K_M on load, null after unload, and null for a pipeline load; a response-model one; a frontend one asserting wan · GGUF · Q4_K_M · cuda

Verification on the branch as pushed:

  • tests/test_video_backend.py: 76 passed, 8 failed, and those 8 fail identically on the branch without my commit (unrelated, environment)
  • tests/test_sd_cpp_backend.py: 68 passed
  • tests/test_diffusion_backend.py -k "gguf or status": 17 passed
  • frontend npm run test: 1384 passed, npm run typecheck clean

@danielhanchen

Copy link
Copy Markdown
Member

Simulated this end to end before and after, across the OS and accelerator matrix, and pushed one more commit: 36f51b1.

Before and after

Before, /api/inference/images/status exposed model_kind: "gguf" and dtype: "bfloat16", and the indicator printed the compute dtype, so a Q8_0 pick read z-image · GGUF · BF16 · cuda. After, the selected checkpoint quant is reported separately and the row reads z-image · GGUF · Q8_0 · cuda. This is a real defect, not a cosmetic one: BF16 is the pipeline compute precision and is identical for every quant, so the indicator could not distinguish a Q2_K load from a Q8_0 one, which is exactly the thing a user picks a GGUF variant to control.

Does it break anything

No. It adds an optional field and changes one label. Specifically:

  • No hardware path is added or changed. gguf_variant is computed from the filename string that the load already stored. It never touches torch, a device, or a driver. My sandbox proves this: it renders the shipped expressions with only pydantic and structlog installed, no torch, no diffusers.
  • Non-GGUF loads are byte-identical. Single-file, pipeline, transformer_quant, and unnamed-quant GGUF rows all render exactly what they render today.
  • The wire change is purely additive: one optional, nullable field on two response models. Nothing removed, nothing renamed, nothing made required.

Simulations

Three harnesses in an isolated uv venv, 13,632 cells total, all green.

  1. Backend status producers, 12,960 cells. The gguf_variant expression is lifted out of diffusion.py, sd_cpp_backend.py and video.py with ast and evaluated directly, so the simulation cannot drift from the shipped code. The matrix is [Windows, Linux, WSL, Mac] x [NVIDIA cuda, AMD cuda/hip/rocm, Intel xpu, Apple mps, CPU] x [gguf, single_file, pipeline, unset kind] x 16 filename shapes, each as a bare name and as an OS-native absolute path. Zero exceptions, and every bare filename resolves to the expected token: Q8_0, Q4_K_M, UD-Q4_K_XL, IQ2_M, TQ1_0, MXFP4_MOE, split shards (-00001-of-00003 stripped), quant-only-in-parent-directory, no-quant, empty string, and None.
  2. Version matrix, 672 cells, rendered through the real frontend module rather than a copy, with the pre-PR module checked out in a second worktree so both builds run for real. Four wire combinations: new backend + new frontend, old backend + new frontend, new backend + old frontend (a browser or Tauri shell holding a cached bundle across an upgrade), and old + old as the control. Asserted: no exceptions; a stale bundle renders identically to today; an upgraded UI against an old backend renders identically to today; where no variant is reported the merged state matches today exactly; where a variant is reported it is named and no stale BF16/FP16/FP32 survives; the GGUF tag appears exactly once; the device always survives to the end of the row.
  3. Schema compatibility. The two response model bodies are lifted from both builds and exercised against real pydantic. Additive only, optional, nullable, old payload into the new model defaults to null, new payload into the old model is tolerated rather than rejected, and every pre-existing field decodes identically on both builds.

One defect the simulation found

extract_quant_token is re.IGNORECASE and returns the token with its original case, so a repo shipping z-image-turbo-q8_0.gguf rendered GGUF · q8_0 while every other quant label in the UI is upper-cased (pick_best_gguf compares extract_quant_label(...).upper()). 36f51b1 routes the variant through the existing precisionLabel, which upper-cases it and, as a bonus, drops an empty or "none" value back to the dtype instead of printing a blank segment. Test added. That was the only failure across all 13,632 cells, and the matrix is green now.

Browsers

No new syntax. The diff uses ?? and ?., both of which this file already used before the PR (6 and 4 times). Those are ES2020: Chrome 80, Edge 80, Firefox 72, Safari 13.1, all far below Vite 8's default baseline-widely-available target of chrome111/edge111/firefox114/safari16.4. vite.config.ts sets no build.target override. I ran a production build and confirmed the emitted chunk carries the logic untranspiled, so no polyfill or downlevel is involved:

detail:_7(e.family,t?`GGUF`:null,y7(e.gguf_variant)??y7(e.dtype),e.device)

Old installs

Studio ships the backend and the built bundle together, so a mixed pair only happens with a cached browser bundle or a stale desktop shell, which is combination 3 above and renders identically to today. An older install that never receives this change is unaffected: nothing it sends or expects has changed.

Test runs

  • test_diffusion_backend.py, test_video_backend.py, test_sd_cpp_backend.py: 361 passed, 9 failed. The same 9 fail at the PR's base commit 16fac7b1e with an identical failure set, and the base passes 356, so the branch is +5 passing and +0 failing.
  • test_diffusion_routes.py, test_video_routes.py: 136 passed.
  • Frontend: 1385 passed, npm run typecheck clean, npm run build clean.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: f36e3895a6

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

danielhanchen added a commit to Datta0/unsloth-staging-3 that referenced this pull request Aug 9, 2026
@danielhanchen

Copy link
Copy Markdown
Member

pre-commit.ci run

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 70377e22b8

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

@danielhanchen
danielhanchen marked this pull request as ready for review August 9, 2026 11:05
@danielhanchen
danielhanchen self-requested a review as a code owner August 9, 2026 11:05
@danielhanchen
danielhanchen merged commit 1357ee8 into unslothai:main Aug 9, 2026
43 of 52 checks passed
danielhanchen added a commit that referenced this pull request Aug 9, 2026
main's #8238 landed the same label fix under gguf_variant, including the
native sd.cpp status. Fold this branch's refinement onto that one field
instead of adding a second: drop gguf_quant and _resident_gguf_quant, and
let the row prefer transformer_quant when the dense fast path replaced the
picked GGUF.
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.

2 participants