Skip to content

fix: detect QWEN_IMAGE version from bare GGUF tensor names#1487

Open
honey1000001001 wants to merge 1 commit into
leejet:masterfrom
honey1000001001:fix/qwen-image-gguf-detection
Open

fix: detect QWEN_IMAGE version from bare GGUF tensor names#1487
honey1000001001 wants to merge 1 commit into
leejet:masterfrom
honey1000001001:fix/qwen-image-gguf-detection

Conversation

@honey1000001001
Copy link
Copy Markdown

@honey1000001001 honey1000001001 commented May 12, 2026

Problem

Some GGUF files (e.g. from unsloth) store diffusion model tensors without the model.diffusion_model. prefix. For example, tensor names look like:

  • transformer_blocks.0.img_mod.1.weight
  • img_in.bias
  • proj_out.weight

Instead of:

  • model.diffusion_model.transformer_blocks.0.img_mod.1.weight

This causes get_sd_version() to fail with get sd version from file failed, even though the binary has full Qwen-Image support (the --llm flag, QwenImageModel class, etc. are all present).

Reference: lemonade-sdk/lemonade#1874 — users hitting this when trying to run Qwen-Image-2512-GGUF through sd-cpp.

Fix

Two changes:

1. src/model.cpp - Version detection

In get_sd_version(), match transformer_blocks.0.img_mod.1.weight with or without the model.diffusion_model. prefix.

2. src/name_conversion.cpp - Tensor name conversion

After replace_with_prefix_map(), add model.diffusion_model. prefix to bare Qwen-Image tensor names that don't already have a recognized prefix. This ensures QwenImageModel (which uses prefix model.diffusion_model) can find the tensors.

Testing

Verified locally that sd-server.exe can now detect Qwen-Image GGUF version and starts loading the model (text encoder + VAE load successfully, main GGUF passes version detection).

Some GGUF files (e.g. from unsloth) store diffusion model tensors
without the 'model.diffusion_model.' prefix. This caused get_sd_version()
to fail with 'get sd version from file failed' even though the binary
has full Qwen-Image support.

Two fixes:
1. In get_sd_version(), also match 'transformer_blocks.0.img_mod.1.weight'
   without the 'model.diffusion_model.' prefix for QWEN_IMAGE detection.
2. In convert_tensor_name(), add 'model.diffusion_model.' prefix to bare
   Qwen-Image tensor names so downstream loaders (QwenImageModel) can
   find them with their canonical prefix.

Fixes lemonade-sdk/lemonade#TBD (Qwen-Image-2512-GGUF fails to load)
@wbruna
Copy link
Copy Markdown
Contributor

wbruna commented May 12, 2026

Are you loading it through the field model_path (flag --model) instead of diffusion_model_path (flag --diffusion-model)?

I'm probably not finding all relevant discussions right now, but this is related to at least : #403 #434 #435 #884 #887 #1064 #1425

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