Skip to content

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
city96:mainfrom
pottokao-dotcom:qwen3vl-mmproj
Open

pottokao-dotcom wants to merge 1 commit into
city96:mainfrom
pottokao-dotcom:qwen3vl-mmproj

Conversation

@pottokao-dotcom

@pottokao-dotcom pottokao-dotcom commented Sep 23, 2026 •

Copy link
Copy Markdown

Using a Qwen3-VL GGUF as the Qwen-Image-2.1 text encoder (CLIPLoaderGGUF, type qwen_image → TextEncodeQwenImage21) fails in the sampler with:

RuntimeError: Given normalized_shape=[4096], expected input with shape [*, 4096], but got input of size [1, 512, 12288]

Cause

gguf_clip_loader only loads the mmproj vision tower for qwen2vl. For qwen3vl the vision tower is missing, so ComfyUI doesn't detect the state dict as Qwen3-VL (it looks for model.visual.deepstack_merger_list.*) and builds the wrong text encoder, which returns 12288-wide (FFN) hidden states.

Fix

  • Load the mmproj for qwen3vl too.
  • Rename the tensors gguf_mmproj_loader returns 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}, merger ln_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):

  • The loaded state dict has the same 750 keys and shapes as Comfy-Org's bf16 safetensors text encoder; the 351 vision tensors match it numerically (rel. error ≤ 1.1e-7).
  • Qwen-Image-2.1 text-to-image and reference-image editing both run, and match the bf16 encoder's output for the same seed up to Q4 noise.

🤖 Generated with Claude Code

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>
@pottokao-dotcom pottokao-dotcom changed the title Load mmproj vision tower for qwen3vl text encoders Load mmproj vision tower for qwen3vl text encoders (fixes Qwen-Image-2.1 12288 error) Sep 23, 2026
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