Skip to content

[Unsloth Bug] Studio: Qwen-Image-2.1 GGUF generation fails - 1-D norm weights never dequantized in no-conversion load path (4096 vs 8192) #12445

Closed

Description

@WolCarlos

Environment

Where are you using Unsloth?

  • Unsloth desktop application
  • Unsloth web UI (unsloth studio)
  • Unsloth CLI
  • Python package or notebook
  • Colab or Kaggle

Operating system and version: Windows 11 Pro, build 26300 (10.0.26300)

GPU model(s) and accelerator backend: NVIDIA GeForce RTX 4080 SUPER (16 GB VRAM), CUDA

Versions:

  • Unsloth Studio (Desktop): 0.1.900-beta
  • Bundled backend venv: Python 3.13, torch, diffusers (shipped with Studio)

What happened?

Steps to reproduce:

  1. In Unsloth Studio, download abenzerps/Qwen-Image-2.1-Uncensored-GGUF (Q8_0; the issue also reproduces with Q6_K from the same repo).
  2. Let Studio fetch the companion repos (unsloth/Qwen-Image-2.1 text encoder + VAE, FP8 text encoder) — these download fine.
  3. Load the model — load succeeds (diffusion.loaded: repo=abenzerps/Qwen-Image-2.1-Uncensored-GGUF base=Qwen/Qwen-Image-2.1 device=cuda offload=group ...).
  4. Generate any image.

Expected behavior: Image generation runs.

Actual behavior: Every generation fails with:

RuntimeError: The size of tensor a (4096) must match the size of tensor b (8192) at non-singleton dimension 2

Traceback ends in:

diffusers\pipelines\qwenimage21\pipeline_qwenimage21.py (line ~772)
studio\backend\core\inference\diffusion_qwenimage21.py (line ~344)
diffusers\models\transformers\transformer_qwenimage21.py (lines ~185/197)
diffusers\quantizers\gguf\utils.py (line ~578, in __torch_function__)

Model and operation involved: abenzerps/Qwen-Image-2.1-Uncensored-GGUF (qwen-image-2.1-UC-Q8_0.gguf, SHA-256-verified complete download; also qwen-image-2.1-UC-Q6_K.gguf) — diffusion GGUF inference.

Root cause (investigated)

This is not a corrupt download and not quant-specific (Q8_0 and Q6_K fail identically), and it is unrelated to the repo uploader's earlier Q8_0 RMSNorm advisory.

This GGUF stores 65 one-dimensional norm weights (txt_in.text_norm + 64 attention norms) as BF16-packed GGUF tensors (e.g. 4096 bf16 elements = 8192 raw bytes — exactly the 4096-vs-8192 mismatch). diffusers only dequantizes inside GGUFLinear layers, so 1-D norms must be dequantized at load time.

Studio already has the correct fix, but it never runs for this file:

  • _qwen_image_21_checkpoint_to_diffusers() contains the 1-D dequant logic.
  • However, diffusers/Studio skip the checkpoint conversion path when the GGUF's tensor names already match diffusers naming — which is the case for this repo (verified: all 297 tensors match QwenImage21Transformer2DModel naming exactly, and the mapping function is never invoked).
  • Result: the 1-D norm weights reach the forward pass as raw packed byte tensors and crash on the first norm.

Suggested fix: run the 1-D norm dequant also in the no-conversion GGUF load path, e.g. alongside _install_gguf_dim_restore / _restore_gguf_trimmed_dims in studio/backend/core/inference/diffusion.py.

Verified local workaround

Appending this to _restore_gguf_trimmed_dims (which runs for every GGUF load, including the no-conversion path) fixes generation for both Q8_0 and Q6_K:

# Dequant 1-D norm weights for pre-converted Qwen-Image-2.1 GGUFs.
for name, have in list(state_dict.items()):
    quant_shape = getattr(have, "quant_shape", None)
    if quant_shape is not None and len(quant_shape) == 1:
        from diffusers.quantizers.gguf.utils import dequantize_gguf_tensor
        state_dict[name] = dequantize_gguf_tensor(have)

With this patch, a full QwenImage21Transformer2DModel forward pass on CUDA succeeds (Q6_K: peak VRAM 5.98 GiB; Q8_0: 7.55 GiB; output finite). Before the patch, txt_in.text_norm forward crashes with the exact error above.

Logs

From %USERPROFILE%\.unsloth\studio\logs\backend-backend-*.log:

"event": "diffusion.loaded: repo=abenzerps/Qwen-Image-2.1-Uncensored-GGUF base=Qwen/Qwen-Image-2.1 device=cuda offload=group resolved=[transformer_quant=off(auto) text_encoder_quant=fp8(auto) cpu_offload=True(auto)] estimates={'safe_device_budget_mib': 13013, 'model_dense_mib': 24966, 'text_encoder_dense_mib': 16721}"
"event": "diffusion.generate_failed: The size of tensor a (4096) must match the size of tensor b (8192) at non-singleton dimension 2"

Additional context

Possibly related secondary issue: during the first FP8 text-encoder pre-quantization, the backend hit Windows commit-limit exhaustion (diffusion.te_prequant: fp8:text_encoder:repo failed: Il file di paging è troppo piccolo per essere completato. (os error 1455)) on a machine with 32 GB RAM + 42 GB pagefile. It succeeded on a later run, but the pre-quantization step may need more conservative peak-memory handling on Windows.

Activity

  1. added
    feature request
    on Oct 1, 2026
  2. Souravrajvi0 commented on Oct 1, 2026

    @Souravrajvi0
    Contributor

    Thanks for the thorough write-up — the no-conversion load path skipping _qwen_image_21_checkpoint_to_diffusers matches what we see in code.

    Opened a fix that dequantizes 1-D GGUFParameter norms in the same meta-loader shim as _restore_gguf_trimmed_dims (so pre-converted Qwen-Image-2.1 GGUFs are covered), and reuses that helper from the mapping function: #12449

  3. self-assigned this
    on Oct 1, 2026
  4. Imagineer99 commented on Oct 1, 2026

    @Imagineer99
    Member

    Confirmed the same error with both Q8_0 and Q6_K on a Colab A100, dequantizing the 1-D norm weights at load time fixes it and both models generate images successfully. FP8 memory error looks like a separate issue.

  5. danielhanchen commented on Oct 8, 2026

    @danielhanchen
    Member

    Thanks for the detailed root cause, this is fixed in the latest Unsloth Desktop release, v0.1.904-beta.

    #12775 added a post-load step that dequantizes every packed GGUF parameter outside GGUFLinear after each GGUF from_single_file load, so it also covers pre-converted Qwen-Image-2.1 GGUFs that skip the checkpoint conversion path.

    I checked it with abenzerps/Qwen-Image-2.1-Uncensored-GGUF (qwen-image-2.1-UC-Q6_K.gguf):

    Build Packed 1-D norms left Transformer forward
    Before #12775 65 The size of tensor a (4096) must match the size of tensor b (8192)
    After #12775 (included in v0.1.904-beta) 0 OK, finite output

    Only the small norm weights are dequantized; the 229 quantized linear weights stay quantized.

    Please update Unsloth Desktop to v0.1.904-beta (the in-app updater, or download it from https://github.com/unslothai/unsloth/releases/latest). If generation still fails after the update, please post the new backend log here.

    The Windows paging-file error during FP8 text encoder pre-quantization is a separate problem, so a new issue for that one would be great.

  6. danielhanchen commented on Oct 8, 2026

    @danielhanchen
    Member

    Fixed! Pre-converted Qwen-Image-2.1 GGUFs skip the checkpoint conversion, so their BF16 norm weights stayed packed and the first norm failed with 4096 vs 8192. #12775 now dequantizes every packed GGUF weight outside the linear layers right after load, and it ships in v0.1.904-beta.

    To update: Unsloth Desktop will have an update banner. For Studio, use unsloth studio update For Docker, use exec <container> unsloth-studio-update Reopen if it still happens.

  7. WolCarlos commented on Oct 14, 2026

    @WolCarlos
    Author

    Confirmed fixed on the original reporter's machine 👍

    After updating to v0.1.904-beta, on the same setup from the issue (Windows 11 Pro 26300, RTX 4080 SUPER 16 GB, abenzerps/Qwen-Image-2.1-Uncensored-GGUF Q8_0):

    • The backend now pulls the hosted pre-quantized FP8 text encoder from unsloth/Qwen-Image-2.1-FP8 (~9 GB one-time download) instead of quantizing the dense encoder locally
    • diffusion.generated: engine=diffusers workflow=txt2img images=1 size=1024x576 steps=25 — HTTP 200, ~35 s, correct image out
    • No more 4096 vs 8192 tensor error

    Thanks for the quick fix — closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugfeature request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions