fix(glm4v): version-aware hidden_size/vocab_size for Glm4vConfig#1214
Open
1fanwang wants to merge 1 commit intolinkedin:mainfrom
Open
fix(glm4v): version-aware hidden_size/vocab_size for Glm4vConfig#12141fanwang wants to merge 1 commit intolinkedin:mainfrom
1fanwang wants to merge 1 commit intolinkedin:mainfrom
Conversation
cd91744 to
3d2266b
Compare
…kedin#1152) Reading config.hidden_size and config.vocab_size directly fails on transformers v5+, where Glm4vConfig is a composite (text_config + vision_config) and the top-level fields are removed. Mirror the helper pattern introduced by linkedin#1062 for Qwen2-VL/Qwen2.5-VL. Closes linkedin#1152.
3d2266b to
d7915ae
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.
Reading
config.hidden_sizeandconfig.vocab_sizedirectly inglm4v.pyandglm4v_moe.pyfails on transformers v5+, whereGlm4vConfigandGlm4vMoeConfigare composite (text_config+vision_config) and the top-level fields are no longer present. Reported in #1152:Same shape PR #1062 already fixed for Qwen2-VL / Qwen2.5-VL — mirror that helper (
_get_hidden_size,_get_vocab_size) gated ontransformers >= 5.0.0, applied to bothglm4v.pyandglm4v_moe.py. Pre-v5 still works because the helpers fall back to the top-level attribute. Helper signatures are typed (config: PretrainedConfig -> int) and the version flag is annotatedbool.Reproducer (transformers 5.7.0)
Same shape reproduces for
Glm4vMoeConfig. Identical to the trace in #1152.After the helper change, both
_get_hidden_size(cfg)and_get_vocab_size(cfg)route throughtext_configon v5+ and fall back to the top-level attribute pre-v5:Tests
End-to-end coverage already in place in
test/convergence/bf16/test_mini_models.pyandtest/convergence/fp32/test_mini_models.py— bothmini_glm4vandmini_glm4v_moeconfigs construct via thetext_configsub-dict (lines 1245–1308 / 1311–1368), so CI exercises the fixed path on v5+ runners. No new test file added — matches the precedent set by PR #1062 (qwen2_vl fix), which also relied on the existing convergence tests rather than introducing a helper-level test layer.Closes #1152.