Skip to content

Conversation

@SYChen123
Copy link
Contributor

Motivation

LORA supports on Qwen25-VL

Modifications

add "should_apply_lora" function, same as other models.

Accuracy Tests

Benchmarking and Profiling

Checklist

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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

  • LORA Support for Qwen2.5-VL: This pull request introduces support for Low-Rank Adaptation (LORA) specifically for the Qwen2.5-VL model, enabling more efficient fine-tuning.
  • Module Identification for LORA: A new should_apply_lora function has been added to programmatically identify which specific modules within the Qwen2.5-VL model are eligible for LORA application, consistent with how other models handle LORA.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines +538 to +540
_lora_pattern = re.compile(
r"^model\.layers\.(\d+)\.(?:self_attn|mlp)\.(?:qkv_proj|o_proj|down_proj|gate_up_proj)$"
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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).

Suggested change
_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)))$"
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant