Skip to content

Pin the Dynamic 2.0 4-bit text encoder for Qwen-Image-2.1's native route - #11542

Merged
danielhanchen merged 2 commits into
mainfrom
studio-q21-te-q4kxl
Sep 22, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
studio-q21-te-q4kxl

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

What this changes

Qwen-Image-2.1's no-GPU sd.cpp route conditions on a GGUF of Qwen3-VL-8B, pinned by exact filename in the family. It pointed at the uniform Q4_K_M. unsloth/Qwen3-VL-8B-Instruct-GGUF also publishes UD-Q4_K_XL, the Dynamic 2.0 rung, whose per-tensor precision is derived by measurement rather than applied uniformly across the tensors.

 sd_cpp_text_encoders = (
     (
         "unsloth/Qwen3-VL-8B-Instruct-GGUF",
-        "Qwen3-VL-8B-Instruct-Q4_K_M.gguf",
+        "Qwen3-VL-8B-Instruct-UD-Q4_K_XL.gguf",
         "llm",
     ),
 ),

It costs almost nothing in the resource this route exists to protect: 5.1 GB against 5.0, where the bf16 encoder is 16.4 GB.

Verified on real hardware

Rendered on this host with a build that carries the qwen_image_2_1 marker, since the five older builds on the box do not implement the architecture at all and would have proved nothing. One prompt at 1024, 20 steps, euler, cfg 6.0, --diffusion-fa, seed 42. The DiT and the VAE are bf16 and fixed across both arms, so the encoder is the only thing that moves.

text encoder file size wall result
Qwen3-VL-8B-Instruct-Q4_K_M (before) 5.03 GB 39.0 s coherent
Qwen3-VL-8B-Instruct-UD-Q4_K_XL (after) 5.15 GB 36.5 s coherent

Between the two, at the same seed: LPIPS 0.02894, SSIM 0.95908.

That is a different sample rather than a reproduction of the old one, which is what swapping the conditioning encoder does and is worth stating plainly. Both renders are clean, with no artifacts and no failure to follow the prompt. This pair is one prompt on one seed, so it establishes that the Dynamic rung loads and renders correctly through the native route; it is not a quality ranking between the two quantisations, and I have not claimed one.

Test

test_qwen_image_2_1_takes_the_dynamic_4bit_text_encoder pins the exact repo id and filename. A wrong filename here is not a config-time error anyone sees: the fetch 404s mid-load, after the denoiser has already been staged, so the failure surfaces late and reads like a network problem. Pinning it by name means a rename upstream, or a quiet drop back to the uniform quant, breaks a test rather than a user's load.

tests/test_diffusion_compat_preflight.py is 80 passed.

The no-GPU sd.cpp route fetched the uniform Qwen3-VL-8B Q4_K_M for conditioning.
unsloth/Qwen3-VL-8B-Instruct-GGUF also publishes UD-Q4_K_XL, the Dynamic 2.0
rung, whose per-tensor precision is chosen by measurement rather than applied
uniformly, and it costs almost nothing here: 5.1 GB against 5.0, so the CPU RAM
win the native route exists for is unchanged (bf16 is 16.4 GB).

Verified end to end on this host against a build that carries the
qwen_image_2_1 marker, one prompt at 1024 with 20 steps, euler, cfg 6.0 and a
shared seed, DiT and VAE bf16 and fixed across both arms so only the encoder
moves: both render coherently, LPIPS 0.02894 and SSIM 0.95908 between them, 36.5
s against 39.0 s. It is a different sample, not a reproduction of the old one,
which is what swapping the conditioning encoder does.

The test pins the exact filename. A wrong name is not a config-time error: the
fetch 404s mid-load, after the denoiser has already been staged.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 22, 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-09-22T14:52:59.213236Z d87fbbf PR opened
ℹ️ 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.

@danielhanchen
danielhanchen merged commit 71912e8 into main Sep 22, 2026
2 of 38 checks passed
@danielhanchen
danielhanchen deleted the studio-q21-te-q4kxl branch September 22, 2026 14:50

@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: d87fbbfb49

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

(
"unsloth/Qwen3-VL-8B-Instruct-GGUF",
"Qwen3-VL-8B-Instruct-Q4_K_M.gguf",
"Qwen3-VL-8B-Instruct-UD-Q4_K_XL.gguf",

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 encoder contract test

The Studio backend CI still collects test_qwen_image_21_gguf_reaches_sd_cpp_with_its_own_vae_and_a_qwen3vl_encoder from studio/backend/tests/test_diffusion_more_families.py, whose line 695 requires Qwen3-VL-8B-Instruct-Q4_K_M.gguf. Since sd_cpp_text_encoders_for() returns this newly changed tuple, that existing test now deterministically fails even though the new test passes; update the original assertion alongside this filename change.

Useful? React with 👍 / 👎.

shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Sep 22, 2026
…i#11573)

(Python 3.13, a-k) fails the same four tests on every PR. Bisected on main
with the GPU hidden, as on the runner; each is a test that stopped describing
the product, not a product regression:

- test_download_plan_counts_a_cached_lower_auto_prequant, since unslothai#11394. The
  plan now skips a pre-quant name this install cannot open, and torchao 0.18,
  which the shard installs unpinned, has no int8 pickle constructors. The
  test offers only Qwen-Image-INT8.pt. It now pins the readability answer and
  also asserts the converse: an unreadable artifact is not budgeted.
- test_every_third_party_bf16_pipeline_the_catalog_offers_is_mirrored, since
  unslothai#11405 offered Qwen/Qwen-Image-2.1. unsloth/Qwen-Image-2.1 is not on the Hub,
  so a mirror row would 404 every fetch it redirects. Named as a pending mirror
  that fails once the row lands or the catalog drops it.
- test_the_recorded_base_must_be_the_canonical_id_not_just_the_same_tail, added
  by unslothai#11405. build_prequant_checkpoint.main imports diffusers before reading an
  argument and the shard has no diffusers. An empty stand-in when it is absent;
  the refusal lands before any diffusers attribute is read.
- test_qwen_image_21_gguf_reaches_sd_cpp_with_its_own_vae_and_a_qwen3vl_encoder,
  since unslothai#11542 moved the encoder to UD-Q4_K_XL on purpose and pins that name in
  its own test. This one now reads the declared name and keeps its own claim,
  that the file is a 4-bit GGUF.
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…ute (unslothai#11542)

The no-GPU sd.cpp route fetched the uniform Qwen3-VL-8B Q4_K_M for conditioning.
unsloth/Qwen3-VL-8B-Instruct-GGUF also publishes UD-Q4_K_XL, the Dynamic 2.0
rung, whose per-tensor precision is chosen by measurement rather than applied
uniformly, and it costs almost nothing here: 5.1 GB against 5.0, so the CPU RAM
win the native route exists for is unchanged (bf16 is 16.4 GB).

Verified end to end on this host against a build that carries the
qwen_image_2_1 marker, one prompt at 1024 with 20 steps, euler, cfg 6.0 and a
shared seed, DiT and VAE bf16 and fixed across both arms so only the encoder
moves: both render coherently, LPIPS 0.02894 and SSIM 0.95908 between them, 36.5
s against 39.0 s. It is a different sample, not a reproduction of the old one,
which is what swapping the conditioning encoder does.

The test pins the exact filename. A wrong name is not a config-time error: the
fetch 404s mid-load, after the denoiser has already been staged.
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…i#11573)

(Python 3.13, a-k) fails the same four tests on every PR. Bisected on main
with the GPU hidden, as on the runner; each is a test that stopped describing
the product, not a product regression:

- test_download_plan_counts_a_cached_lower_auto_prequant, since unslothai#11394. The
  plan now skips a pre-quant name this install cannot open, and torchao 0.18,
  which the shard installs unpinned, has no int8 pickle constructors. The
  test offers only Qwen-Image-INT8.pt. It now pins the readability answer and
  also asserts the converse: an unreadable artifact is not budgeted.
- test_every_third_party_bf16_pipeline_the_catalog_offers_is_mirrored, since
  unslothai#11405 offered Qwen/Qwen-Image-2.1. unsloth/Qwen-Image-2.1 is not on the Hub,
  so a mirror row would 404 every fetch it redirects. Named as a pending mirror
  that fails once the row lands or the catalog drops it.
- test_the_recorded_base_must_be_the_canonical_id_not_just_the_same_tail, added
  by unslothai#11405. build_prequant_checkpoint.main imports diffusers before reading an
  argument and the shard has no diffusers. An empty stand-in when it is absent;
  the refusal lands before any diffusers attribute is read.
- test_qwen_image_21_gguf_reaches_sd_cpp_with_its_own_vae_and_a_qwen3vl_encoder,
  since unslothai#11542 moved the encoder to UD-Q4_K_XL on purpose and pins that name in
  its own test. This one now reads the declared name and keeps its own claim,
  that the file is a 4-bit 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.

1 participant