fix(qwen): remap legacy single-file VL encoder keys under transformers 5.x - #9333
Merged
lstein merged 2 commits intoJul 5, 2026
Merged
Conversation
…s 5.x Qwen2_5_VLForConditionalGeneration._checkpoint_conversion_mapping is empty in transformers 5.x, so the `if key_mapping:` guard skipped remapping and ComfyUI single-file checkpoints (`visual.*`, `model.*`) failed to load: their keys were reported as unexpected while `model.visual.*` params stayed as meta tensors. Fall back to the legacy mapping when transformers no longer provides one. The negative lookahead keeps new-layout checkpoints untouched.
Pfannkuchensack
requested review from
JPPhoto,
blessedcoolant,
dunkeroni and
lstein
as code owners
July 5, 2026 16:31
Collaborator
|
Supersedes #9334 |
Closed
5 tasks
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
Qwen2_5_VLForConditionalGeneration._checkpoint_conversion_mappingis empty in transformers 5.x, so theif key_mapping:guard skipped remapping and ComfyUI single-file checkpoints (visual.*,model.*) failed to load: their keys were reported as unexpected whilemodel.visual.*params stayed as meta tensors. Fall back to the legacy mapping when transformers no longer provides one. The negative lookahead keeps new-layout checkpoints untouched.Related Issues / Discussions
N/A
QA Instructions
qwen_2.5_vl_7b_fp8_scaled.safetensorsfrom the starter models) that uses the legacy key layout (visual.*,model.layers.*).qwen_image_text_encoderinvocation.RuntimeError: Failed to load all parameters from checkpoint. Meta tensors remain: ['model.visual.patch_embed.proj.weight', ...]plus a728 unexpected keyswarning.Verified against the real checkpoint header (1446 keys): 730 →
model.language_model.*, 714 →model.visual.*, 1 →lm_head.weight, 1 →scaled_fp8(fp8 metadata, stripped before remap). No weight keys left unmapped.Merge Plan
Standard merge — no DB/schema changes, no migrations.
Checklist
What's Newcopy (if doing a release after this PR)