Skip to content

Studio: name the quant a diffusion GGUF pick actually loaded, instead of the compute dtype - #8241

Merged
danielhanchen merged 2 commits into
mainfrom
q8label
Aug 9, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
q8label

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

The bug

Pick unsloth/Z-Image-Turbo-GGUF at Q8_0. The picker chip reads GGUF · Q8_0. The Loaded models row beside it reads:

unsloth/Z-Image-Turbo-GGUF
Image · z-image · GGUF · BF16 · cuda

The two disagree, and the row is the one that is wrong.

What is actually resident, since the label cannot be trusted to say

Loaded through the real backend on a B200, then inspected the module rather than the payload. Isolated, empty cache root; unsloth/Z-Image-Turbo-GGUF, z-image-turbo-Q8_0.gguf, everything else left on auto:

pipe.transformer                ZImageTransformer2DModel
parameter classes               GGUFParameter 276, Parameter 245
parameter dtypes                torch.uint8 276, torch.bfloat16 245
GGUF quant types                Q8_0 240, BF16 36      (ggml type 8 / 30)
resident bytes                  7,222,585,472  (7.22 GB)
z-image-turbo-Q8_0.gguf         7.23 GB on the Hub
hf_quantizer                    diffusers GGUFQuantizer

The Q8_0 GGUF is what ran. The transformer is 7.22 GB of uint8 Q8_0 blocks, not a 12.3 GB bf16 tensor in sight. So this is a display bug, not a substitution: nothing bf16 was loaded, and the row simply had nothing better to print.

dtype is the pipeline's COMPUTE dtype. It is bfloat16 for every CUDA diffusion load, GGUF or not, because that is what the GGUF blocks dequantise INTO per matmul. Reading it as a precision reports "BF16" for a Q6_K pick, a Q8_0 pick and a BF16 pick alike. Nothing on /images/status named the quant at all, so the row could not have shown it.

The chat runtime has published gguf_variant all along, which is why a chat row says GGUF · Q4_K_M and an image row does not.

The fix

Backend. /images/status gains gguf_quant: the quant of the GGUF that is actually backing the transformer. It is null whenever the GGUF is not what ran, so the field can never contradict the build:

  • a pipeline / single_file load carries no GGUF;
  • a GGUF pick the dense fast path took over is a torchao build of the base transformer, and transformer_quant already describes that one (its contract is "null = the GGUF ran as-is");
  • a checkpoint whose name holds no quant token reports null rather than a filename stem dressed up as a precision.

Frontend. The row reads the build in the order it is decided: the dense scheme when one engaged, else the GGUF quant, else the pipeline dtype. Video already did the first and last of those; this is the missing middle, applied to images.

It also stops calling a row GGUF when the dense fast path replaced the GGUF, because that names a file the pipeline never opened. That case is real and measured: with the hosted pre-quant checkpoint already cached, the same Q8_0 pick loads unsloth/Z-Image-Turbo-FP8 instead, pipe.transformer holds 239 Float8Tensor weights and zero GGUFParameter, and the row said GGUF · BF16 · cuda for it too. It now says z-image · FP8 · cuda.

A backend without the field falls back to the dtype, so an older wheel keeps the line it has always shown.

before   Image · z-image · GGUF · BF16 · cuda
after    Image · z-image · GGUF · Q8_0 · cuda

Verification

Both rows driven through the real UI against a real load, picker chip and panel captured together:

  • before, on main: Image · z-image · GGUF · BF16 · cuda beside a chip reading GGUF · Q8_0;
  • after: Image · z-image · GGUF · Q8_0 · cuda, and /images/status carries "gguf_quant": "Q8_0".

Tests: 5 added to studio/backend/tests/test_diffusion_backend.py, 2 to studio/frontend/tests/loaded-models-sources.test.ts, 1 to loaded-models-backcompat.test.ts.

Mutation tested on a committed copy, 9 mutants, each caught by the named test, suite green after restoring:

mutation caught by
gguf_quant always null test_status_names_the_gguf_quant_that_actually_ran
name the GGUF even when the dense path replaced it test_status_drops_the_gguf_quant_when_the_dense_path_replaced_the_gguf
answer for a non-GGUF load kind too test_resident_gguf_quant_only_answers_for_a_gguf_it_can_name
invent a label from the filename stem test_resident_gguf_quant_only_answers_for_a_gguf_it_can_name
drop the key from the unloaded payload test_status_carries_no_gguf_quant_when_nothing_is_loaded
leave the field undeclared on the response model test_diffusion_status_response_declares_the_gguf_quant
row reads the compute dtype only (the reported bug) "a GGUF image row names the quant that was picked"
row still calls a replaced GGUF pick GGUF "a GGUF pick the dense fast path replaced"
no dtype fallback for a backend without the field "a backend with no gguf_quant field still reports the compute dtype"

studio/backend/tests: 19130 -> 19135 passing, FAILED/ERROR line set byte-identical to the merge base (85 lines, all pre-existing environment failures). studio/frontend: 1086 -> 1089 passing, failing set identical (37, all pre-existing). npm run typecheck and npm run build clean.

Picking a GGUF at Q8_0 showed "BF16" in the loaded models row. Nothing on
/images/status named the quant: dtype is the pipeline COMPUTE dtype and reads
bf16 for every CUDA load, so the row had nothing sharper to print. The chat
runtime has published gguf_variant all along.

The status payload gains gguf_quant, the quant of the GGUF that is actually
backing the transformer. It is null whenever the GGUF is not what ran: a
pipeline or single_file load, and a GGUF pick the dense fast path replaced with
a torchao build, which transformer_quant already describes.

The row then reads the build in the order it is decided: the dense scheme when
one engaged, else the GGUF quant, else the pipeline dtype. Video already did
this for the first and last of those. It also stops calling a row GGUF when the
fast path replaced the GGUF, since that names a file the pipeline never opened.
A backend without the field falls back to the dtype, so an older wheel keeps
the line it has always shown.

@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: 15fe8e4ea3

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

Comment on lines +223 to +224
precisionLabel(status.gguf_quant) ??
precisionLabel(status.dtype),

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 Populate the quant for native diffusion loads

When a GGUF image load is routed to the native sd.cpp engine (the normal CPU path, enabled MPS, or forced native), SdCppDiffusionBackend.status() in studio/backend/core/inference/sd_cpp_backend.py still supplies only dtype: "gguf" and supplies neither gguf_quant nor model_kind. Consequently this fallback renders only family · GGUF · device, so a selected Q4_K_M or Q8_0 remains unnamed despite the new status contract. Populate both the quant derived from the native state's gguf_filename and the GGUF model kind, or otherwise account for the native status here.

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.

Correct, and fixed in 3c40093. The native path was the hole: SdCppDiffusionBackend.status() sends dtype "gguf" and no model_kind, so gating the row on model_kind === "gguf" would have dropped both the GGUF chip and the quant for every sd.cpp load.

Resolved by merging rather than by adding a second field. main's #8238 landed the same label fix under gguf_variant, and it already populates it in the native status (sd_cpp_backend.py: extract_quant_token(state.gguf_filename)) and in video.py. So this branch drops gguf_quant and _resident_gguf_quant entirely and keeps its one genuine addition on top of that field: the row keeps the isGguf test, which reads dtype === "gguf" and gguf_variant as well as model_kind, and only suppresses the GGUF chip and prefers transformer_quant when the dense fast path replaced the picked file.

Covered by loaded-models-sources.test.ts: 'a native GGUF image row names its selected quant without model_kind' (no model_kind, dtype gguf -> z-image GGUF Q8_0 cpu) and 'a GGUF pick the dense fast path replaced names that build instead'.

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.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 3c400936ff

ℹ️ 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 merged commit f21b04c into main Aug 9, 2026
40 of 44 checks passed
@danielhanchen
danielhanchen deleted the q8label branch August 9, 2026 12:54
danielhanchen added a commit that referenced this pull request Aug 9, 2026
Picking a GGUF at Q8_0 showed "BF16" in the loaded models row. Nothing on
/images/status named the quant: dtype is the pipeline COMPUTE dtype and reads
bf16 for every CUDA load, so the row had nothing sharper to print. The chat
runtime has published gguf_variant all along.

The status payload gains gguf_quant, the quant of the GGUF that is actually
backing the transformer. It is null whenever the GGUF is not what ran: a
pipeline or single_file load, and a GGUF pick the dense fast path replaced with
a torchao build, which transformer_quant already describes.

The row then reads the build in the order it is decided: the dense scheme when
one engaged, else the GGUF quant, else the pipeline dtype. Video already did
this for the first and last of those. It also stops calling a row GGUF when the
fast path replaced the GGUF, since that names a file the pipeline never opened.
A backend without the field falls back to the dtype, so an older wheel keeps
the line it has always shown.
@danielhanchen

Copy link
Copy Markdown
Member Author

Post-merge evidence, since this one is easy to mis-state. Two isolated Studio installs, merge base 8e558606a vs merged head 3c400936f, same load on both: unsloth/Z-Image-Turbo-GGUF Q4_K_M with transformer_quant=int8, so the dense fast path replaces the GGUF with a torchao int8 build.

Image · z-image · GGUF · Q4_K_M · cuda becomes Image · z-image · INT8 · cuda. Same weights, same load, only the label: status on both sides reports model_kind=gguf, gguf_variant=Q4_K_M, transformer_quant=int8, dtype=bfloat16.

Worth writing down for anyone reading this back: a PLAIN GGUF load looks identical on both sides. gguf_variant was already feeding the row before this PR, so GGUF · Q4_K_M was already correct there. What changed is only the case where a dense quant engaged, where the row was naming a file the pipeline never opened and reporting its quant instead of the build that actually ran.

The int8 rather than fp8 is not incidental either: the published Z-Image fp8 artifact predates the activation scale floor, so the loader refuses it and the load fails before reaching this state.

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.

1 participant