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
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 nogeneral.architecturefield, sogguf_sd_loaderfalls into the compatibility path and callsdetect_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.pyalready whitelistsqwen_imagein IMG_ARCH_LIST, so onlyconvert.pyis affected.\n\n## Fix\n\nAddModelQwenImagetotools/convert.pywith 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 modesd.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.