fix: detect QWEN_IMAGE version from bare GGUF tensor names#1487
Open
honey1000001001 wants to merge 1 commit into
Open
fix: detect QWEN_IMAGE version from bare GGUF tensor names#1487honey1000001001 wants to merge 1 commit into
honey1000001001 wants to merge 1 commit into
Conversation
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)
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
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.weightimg_in.biasproj_out.weightInstead of:
model.diffusion_model.transformer_blocks.0.img_mod.1.weightThis causes
get_sd_version()to fail withget sd version from file failed, even though the binary has full Qwen-Image support (the--llmflag,QwenImageModelclass, etc. are all present).Reference: lemonade-sdk/lemonade#1874 — users hitting this when trying to run
Qwen-Image-2512-GGUFthroughsd-cpp.Fix
Two changes:
1.
src/model.cpp- Version detectionIn
get_sd_version(), matchtransformer_blocks.0.img_mod.1.weightwith or without themodel.diffusion_model.prefix.2.
src/name_conversion.cpp- Tensor name conversionAfter
replace_with_prefix_map(), addmodel.diffusion_model.prefix to bare Qwen-Image tensor names that don't already have a recognized prefix. This ensuresQwenImageModel(which uses prefixmodel.diffusion_model) can find the tensors.Testing
Verified locally that
sd-server.execan now detect Qwen-Image GGUF version and starts loading the model (text encoder + VAE load successfully, main GGUF passes version detection).