Repository navigation
Fix tie_word_embeddings not lifted from text_config for some VLM configs (BC regression) - #45857
Conversation
…configs (BC regression)
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
@qgallouedec @zucchini-nlp I reproduced two gaps in the current implementation with a minimal
legacy dict input: pre-initialized Qwen2VLTextConfig input:
I also reproduced the real-world impact with Would you be okay with me opening a superseding PR that preserves |
|
run-slow: glm4v, glm4v_moe, qwen2_5_vl, qwen2_vl |
|
This comment contains models: ["models/glm4v", "models/glm4v_moe", "models/qwen2_5_vl", "models/qwen2_vl"] |
|
Any status here @qgallouedec @ArthurZucker? |
…xt configs are covered too
|
Updated in 5f9d739: the check now runs after |
zucchini-nlp
left a comment
There was a problem hiding this comment.
Thanks! I'll trigger slow CI and lets merge if it's all green
|
@bot /repo |
|
Repo. Consistency bot fixed some files and pushed the changes. |
|
[For maintainers] Suggested jobs to run (before merge) run-slow: glm4v, glm4v_moe, glm_ocr, paddleocr_vl, qwen2_5_vl, qwen2_vl |
|
run-slow: glm4v, glm4v_moe, glm_ocr, paddleocr_vl, qwen2_5_vl, qwen2_vl |
|
This comment contains models: ["models/glm4v", "models/glm4v_moe", "models/glm_ocr", "models/paddleocr_vl", "models/qwen2_5_vl", "models/qwen2_vl"] |
CI recapDashboard: View test results in Grafana |
…configs (BC regression) (huggingface#45857) * Fix `tie_word_embeddings` not lifted from `text_config` for some VLM configs (BC regression) * Lift tie_word_embeddings after text_config init so pre-initialized text configs are covered too * Apply repo consistency fixes --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
For
Qwen2_5_VLConfig,Qwen2VLConfig,Glm4vConfig, andGlm4vMoeConfig, pre-v5 saves placedtie_word_embeddingsinsidetext_config(and dropped it from the root) because the inner text class declared the field. v5 moved the field to the outer config (#42420) but__post_init__doesn't lift the value fromtext_config. The outer attribute therefore falls through to its dataclass default (False),get_expanded_tied_weights_keysreturns{}, no tying happens,lm_head.weightis reported MISSING and randomly initialized — the model loads silently broken.Regression introduced in #41541, which removed the forwarding line
kwargs["tie_word_embeddings"] = self.text_config.tie_word_embeddingsoriginally added in #42420 with aFIXME: tying has to be used from the text configcomment. The vestigialtie_word_embeddings: bool = Falsefield was later removed from the inner text classes in #44976.This patch mirrors the existing fix in
LlavaConfig.__post_init__: whentext_configarrives as a dict (the deserialization path), forwardtie_word_embeddingsto the outer when the root is the default and the dict has a truthy value.Reproducer
Before this PR (loud LOAD REPORT, broken model):
After this PR:
(no LOAD REPORT printed)
The Hub artifact above was saved by transformers 4.57.5; under 4.x its
__post_init__still propagatedtie_word_embeddingsfrom text → root, so the bug is v5-only and only triggers on configs saved by 4.x (the vast majority of pre-existing Hub repos for these architectures).Affected configs
Empirically determined by saving each composite VLM config under transformers 4.56.2 with
tie_word_embeddings=Trueand inspecting the resultingconfig.json:qwen2_5_vl<absent>Trueqwen2_vl<absent>Trueglm4v<absent>Trueglm4v_moe<absent>Truegot_ocr2<absent>TrueTruealreadyllava{,_next,_next_video,_onevision}True<absent>idefics3,smolvlm,llama4,pix2struct,fuyuTrueFiles touched:
qwen2_5_vl,qwen2_vl,glm4v(configuration + modular),glm4v_moe.