fix: detect vision patch size for unsplit (HF-format) Qwen3-VL#1811
Merged
Conversation
fszontagh
force-pushed
the
fix/qwen3vl-hf-patch-embed
branch
from
July 23, 2026 05:57
ad52e9d to
de9646f
Compare
fszontagh
force-pushed
the
fix/qwen3vl-hf-patch-embed
branch
from
July 23, 2026 06:41
de9646f to
9334ec8
Compare
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.
Summary
HF/ComfyUI-format Qwen3-VL text encoders keep the vision patch embed unsplit as
visual.patch_embed.proj.weight. The existing detection only matches the splitvisual.patch_embed.proj.0.weight, sovision.patch_sizesilently stays at the Qwen2.5-VL default of 14 instead of 16. Any model that builds the Qwen3-VL vision tower (e.g. Mage-Flow) then fails to load such an encoder withpatch_embed.proj.weight got [16, 16, ...], expected [14, 14, ...].This reads the patch size from the unsplit weight's kernel extent (
ne[0]), and additionally deriveshidden_sizefromvisual.patch_embed.proj.bias(the split namevisual.patch_embed.biasdoes not match the unsplit.proj.bias). GGUF-sourced and split-format encoders are unaffected.The
model.language_model.*naming difference is already handled byscripts/convert_qwen3_vl.py; this only fixes the remaining patch-size detection, which that script does not touch.Related Issue / Discussion
Related to #1708 - users hit this loading the Comfy-Org bf16 Qwen3-VL; the convert script fixes naming but the unsplit patch size still mis-detects.
Additional Information
Verified with the bf16 Qwen3-VL-4B from
Comfy-Org/Krea-2, run throughscripts/convert_qwen3_vl.py, then loaded as--llmfor Mage-Flow: before this change it fails withpatch_embed.proj.weight ... expected [14, 14, ...]; after, it loads and generates correctly. GGUF encoders continue to work unchanged.Checklist