fix: load embed_tokens and norm for ColQwen2/ColQwen2_5 on transformers 5.x#414
Merged
QuentinJGMace merged 2 commits intoJun 10, 2026
Merged
Conversation
…s 5.x The text backbone is nested under language_model in transformers 5.x, but released Qwen2-VL checkpoints store embed_tokens/norm under model.*. The checkpoint conversion mapping only remapped model.layers, so embed_tokens and norm were silently dropped and randomly re-initialized. Add the missing rules so these pretrained tensors load correctly. The rules only match keys starting with model., so checkpoints already saved in the language_model.* layout are unaffected. Fixes illuin-tech#413
QuentinJGMace
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for finding this and the fix ! Could you also update the changelog ?
Otherwise it looks good to me.
Contributor
Author
|
Done — added the changelog entry. Thanks! |
QuentinJGMace
approved these changes
Jun 10, 2026
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
Fixes #413.
On
transformers5.x,Qwen2VLModel.__init__nests the text backbone underlanguage_model, so the expected keys arelanguage_model.embed_tokens,language_model.layers.*,language_model.norm. Released Qwen2-VL checkpoints store these asmodel.embed_tokens,model.layers.*,model.norm.ColQwen2._checkpoint_conversion_mappingonly remappedmodel.layers, soembed_tokensandnormwere silently dropped and randomly re-initialized when loading from a Qwen2-VL checkpoint.ColQwen2_5had the same incomplete mapping and was affected identically.Changes
Add the missing rules to both
modeling_colqwen2.pyandmodeling_colqwen2_5.py:This is backward-compatible: the rules only match keys starting with
model., so checkpoints already saved in thelanguage_model.*layout are unaffected.Result
Before,
language_model.embed_tokens.weightandlanguage_model.norm.weightwere reported MISSING while their source tensors were UNEXPECTED. After the fix only the expectedcustom_text_proj.{weight,bias}(the ColBERT projection head trained from scratch) remain MISSING.