-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[bugfix] qwen25-VL support lora #14638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @SYChen123, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Qwen2.5-VL model by integrating LORA (Low-Rank Adaptation) capabilities. The primary goal is to facilitate more efficient and resource-friendly fine-tuning of this large vision-language model. The changes involve adding a mechanism to correctly identify and target the appropriate model layers for LORA application, ensuring compatibility and proper functionality. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds LoRA support for the Qwen2.5-VL model by implementing the should_apply_lora method. This correctly restricts LoRA application to the text model's layers, preventing it from being applied to the vision encoder. The overall approach is sound. I have one suggestion to improve the precision of the regular expression used for matching module names.
| _lora_pattern = re.compile( | ||
| r"^model\.layers\.(\d+)\.(?:self_attn|mlp)\.(?:qkv_proj|o_proj|down_proj|gate_up_proj)$" | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current regular expression is slightly too broad. It allows for combinations of modules that do not exist in the model architecture, such as self_attn.down_proj. While this won't cause issues with the current model structure because named_modules() will only yield valid module names, making the regex more specific will improve its correctness and maintainability, especially for future model changes.
A more precise regex would explicitly group the allowed projections under their respective parent modules (self_attn or mlp).
| _lora_pattern = re.compile( | |
| r"^model\.layers\.(\d+)\.(?:self_attn|mlp)\.(?:qkv_proj|o_proj|down_proj|gate_up_proj)$" | |
| ) | |
| _lora_pattern = re.compile( | |
| r"^model\.layers\.(\d+)\.(?:(?:self_attn\.(?:qkv_proj|o_proj))|(?:mlp\.(?:gate_up_proj|down_proj)))$" | |
| ) |
Motivation
LORA supports on Qwen25-VL
Modifications
add "should_apply_lora" function, same as other models.
Accuracy Tests
Benchmarking and Profiling
Checklist