fix(lisa): select language layers in multimodal models - #10173
Open
taking-lying-flat wants to merge 3 commits into
Open
taking-lying-flat wants to merge 3 commits into
taking-lying-flat wants to merge 3 commits into
Conversation
Signed-off-by: taking-lying-flat <1615405@qq.com>
Signed-off-by: taking-lying-flat <1615405@qq.com>
Signed-off-by: taking-lying-flat <1615405@qq.com>
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.
PR type
PR information
LISA currently selects the first
nn.ModuleListin the entire model. In Qwen2.5-VL, this ismodel.visual.blocks, so LISA switches vision blocks while leaving every language layer trainable. If vision parameters were frozen before optimizer creation, the callback can also enable gradients on vision parameters that are absent from the optimizer.Resolve candidate layers using the existing model architecture metadata: prefer
module_listwhen specified, otherwise restrict the search tolanguage_modelprefixes. Exclude registered vision, alignment, and generation components, including those nested under a language-model prefix. Unwrap parallel/compiled models before resolving these paths.The change is limited to
swift/callbacks/lisa.py(+13/-1). Layer switching still begins after optimizer creation. This addresses layer-container selection; it does not change freezing policies inside the selected language layers.Scope: the fix uses registered architecture information. Models without that information retain the existing fallback; ambiguous multi-backbone architectures need separate validation.
Experiment results
Used an actual Transformers
Qwen2_5_VLForConditionalGenerationwith a tiny random configuration (4 vision blocks, 8 language layers),lisa_activated_layers=2, and an optimizer constructed beforeon_train_begin:The missing optimizer entries indicate inconsistent gradient/optimizer state, not that those vision parameters were necessarily updated.
20 tests passed locally:
Also checked the actual registered Transformers model structures on the meta device for Qwen2.5-VL, Qwen3-VL, Qwen3.5, Gemma3-Vision, Gemma4, Gemma4 Unified, Llama3.2-Vision, and Llama4. All eight resolve to their language decoder layer stack; these are structural checks, not training tests for those models.
Changed-file pre-commit and
git diff --checkpass. Targeted regression scripts were run locally; this PR contains only the production fix. Validation used Transformers 5.14.1 and did not include pretrained-model or distributed training runs. The checks do not establish support for every registered model or Transformers version.