fix: load Qwen2.5-VL vision tower weights under FSDP2 - Do not merge#2431
Closed
yuekaizhang wants to merge 1 commit into
Closed
fix: load Qwen2.5-VL vision tower weights under FSDP2 - Do not merge#2431yuekaizhang wants to merge 1 commit into
yuekaizhang wants to merge 1 commit into
Conversation
…a-init transformers >=5.5 nests the Qwen2.5-VL vision tower under `model.visual.*`, but HF checkpoints store it flat (`visual.*`). get_combined_key_mapping only picked up the transformers WeightRenaming for the language model (`model.*` -> `model.language_model.*`) and had no rule for `visual.*`, so the entire vision tower silently failed to load (set_model_state_dict strict=False) and was left randomly initialized. Each process then got a different random vision encoder, producing a nondeterministic, degraded multimodal forward (e.g. NeMo-RL sft_avlm Qwen2.5-VL val loss jumped from ~4.0 to 5-10 and varied run-to-run). Add a non-destructive `^visual\.` -> `model.visual.` rule for the Qwen VL family (qwen2_5_vl, qwen2_vl), augmenting rather than overriding the transformers language-model renaming. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Yuekai Zhang <zhangyuekai@foxmail.com>
Contributor
|
/ok to test 20c2f3d |
Contributor
|
The problem should have been addressed already by transformers 5.6: https://github.com/huggingface/transformers/blob/e933550ec03334b47d2f6f3c92125290c4cd5295/src/transformers/conversion_mapping.py#L134 (PR huggingface/transformers#45358). We ran into this problem with NeMo RL (NVIDIA-NeMo/RL#2224) because NeMo RL pins at an earlier Automodel commit which uses transformers 5.5. Applying a temporary patch in NeMo RL could be a workaround. |
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.
The PR fixed a bug:
transformers >=5.5 nests the Qwen2.5-VL vision tower under
model.visual.*, but HF checkpoints store it flat (visual.*). get_combined_key_mapping only picked up the transformers WeightRenaming for the language model (model.*->model.language_model.*) and had no rule forvisual.*, so the entire vision tower silently failed to load (set_model_state_dict strict=False) and was left randomly initialized.Add a non-destructive
^visual\.->model.visual.rule for the Qwen VL family (qwen2_5_vl, qwen2_vl), augmenting rather than overriding the transformers language-model renaming.