Load mmproj vision tower for qwen3vl text encoders (fixes Qwen-Image-2.1 12288 error) - #485
Open
pottokao-dotcom wants to merge 1 commit into
Open
pottokao-dotcom wants to merge 1 commit into
pottokao-dotcom wants to merge 1 commit into
Conversation
Qwen3-VL GGUF text encoders (e.g. for Qwen-Image-2.1) were loaded without their vision tower, so ComfyUI did not detect Qwen3-VL and the model failed with a [1, 512, 12288] shape error. Load the mmproj for qwen3vl as for qwen2vl and rename its tensors to ComfyUI's Qwen3-VL layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Using a Qwen3-VL GGUF as the Qwen-Image-2.1 text encoder (
CLIPLoaderGGUF, typeqwen_image→TextEncodeQwenImage21) fails in the sampler with:Cause
gguf_clip_loaderonly loads themmprojvision tower forqwen2vl. Forqwen3vlthe vision tower is missing, so ComfyUI doesn't detect the state dict as Qwen3-VL (it looks formodel.visual.deepstack_merger_list.*) and builds the wrong text encoder, which returns 12288-wide (FFN) hidden states.Fix
qwen3vltoo.gguf_mmproj_loaderreturns to ComfyUI's Qwen3-VL layout (model.visual.*):attn_qkv→attn.qkv,up/down_proj→linear_fc1/fc2,v.deepstack.{8,16,24}→deepstack_merger_list.{0,1,2}, mergerln_q/mlp.0/mlp.2→norm/linear_fc1/linear_fc2,v.position_embd→pos_embed.qwen2vl is unchanged.
Tested
ComfyUI 0.36.0 with a Qwen3-VL-8B Q4_K_M GGUF + f16 mmproj (llama.cpp conversion):
🤖 Generated with Claude Code