From 6f51002a27accc5ffb455c26d000737c1821fc66 Mon Sep 17 00:00:00 2001 From: NikolayGusev-astra <198532749+NikolayGusev-astra@users.noreply.github.com> Date: Tue, 22 Sep 2026 00:49:43 +0500 Subject: [PATCH] Add Qwen-Image (2.1) architecture detection for sd.cpp GGUF exports 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. --- tools/convert.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/convert.py b/tools/convert.py index 5029c87..e376984 100644 --- a/tools/convert.py +++ b/tools/convert.py @@ -145,8 +145,16 @@ class ModelLumina2(ModelTemplate): ("cap_embedder.1.weight", "context_refiner.0.attention.qkv.weight") ] -arch_list = [ModelFlux, ModelSD3, ModelAura, ModelHiDream, CosmosPredict2, - ModelLTXV, ModelHyVid, ModelWan, ModelSDXL, ModelSD1, ModelLumina2] +class ModelQwenImage(ModelTemplate): + arch = "qwen_image" + keys_detect = [ + ("img_in.weight", "modulation.1.weight"), + ("img_in.weight", "img_mlp.gate_layer.weight"), + ] + +arch_list = [ModelFlux, ModelSD3, ModelAura, ModelHiDream, CosmosPredict2, + ModelLTXV, ModelHyVid, ModelWan, ModelSDXL, ModelSD1, ModelLumina2, + ModelQwenImage] def is_model_arch(model, state_dict): # check if model is correct