Skip to content

Add Qwen-Image 2.1 architecture detection (sd.cpp GGUF exports fail with 'Unknown model architecture!') - #483

Open
NikolayGusev-astra wants to merge 1 commit into
city96:mainfrom
NikolayGusev-astra:add-qwen-image-2.1-arch
Open

NikolayGusev-astra wants to merge 1 commit into
city96:mainfrom
NikolayGusev-astra:add-qwen-image-2.1-arch

Conversation

@NikolayGusev-astra

Copy link
Copy Markdown

Problem\n\nGGUF exports of Qwen/Qwen-Image-2.1 (release 2026-09-20, e.g. KasugaiSakura/Qwen-Image-2.1-Uncensored-GGUF or realrebelai Q2-Q8) fail to load via UnetLoaderGGUF:\n\n\nValueError: This model is not currently supported - (Unknown model architecture!)\n\n\n## Root cause\n\nsd.cpp exports carry no general.architecture field, so gguf_sd_loader falls into the compatibility path and calls detect_arch() (tools/convert.py). The fingerprint list knows 11 architectures but not Qwen-Image 2.1.\n\nQwen-Image-2.1 is a 32-layer single-stream DiT - its state dict keys differ from Qwen-Image 1.0:\n- img_in.weight + modulation.1.weight (shared)\n- img_mlp.gate_layer.weight - 2.1-only key that distinguishes it from 1.0\n\nloader.py already whitelists qwen_image in IMG_ARCH_LIST, so only convert.py is affected.\n\n## Fix\n\nAdd ModelQwenImage to tools/convert.py with verified keys:\n\npython\nclass ModelQwenImage(ModelTemplate):\n arch = "qwen_image"\n keys_detect = [\n ("img_in.weight", "modulation.1.weight"),\n ("img_in.weight", "img_mlp.gate_layer.weight"),\n ]\n\n\n## Verification\n\n- Q6_K GGUF (5.88 GB, sd.cpp commit 1330cebae) previously rejected → now loads in compatibility mode sd.cpp [arch:qwen_image] and samples end-to-end in ComfyUI 0.35+ / b0f4b7b+ with the official TextEncodeQwenImage21 conditioning path (25 steps, euler/simple, cfg 1.0).\n- No other model paths touched: earlier detectors keep their priority; the new class only fires when previous fingerprints miss.\n\nCache note (reload behavior): after updating cookies, users need restart ComfyUI, and I'd ideally see the same keys in convert verified by the CI in other models家里 too.

Qwen/Qwen-Image-2.1 (single-stream DiT, 32 transformer_blocks) exported
via stable-diffusion.cpp produces GGUFs with no general.architecture
field. The sd.cpp compatibility path in gguf_sd_loader calls detect_arch,
which had no fingerprint for this model and failed with 'Unknown model
architecture!'.

detect keys (verified against Q6_K export):
- img_in.weight
- modulation.1.weight (float module at index 1)
- img_mlp.gate_layer.weight (2.1-only key, distinguishing it from
  Qwen-Image 1.0)

img_arch_list already contains qwen_image, so only convert.py is
affected. Verified locally: same file previously rejected now loads via
UnetLoaderGGUF and samples.
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