-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Add target module validation for init adapters #9429
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?
Add target module validation for init adapters #9429
Conversation
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.
Summary of Changes
Hello @Beichen-Ma, 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 introduces crucial validation checks for LoRA adapter target modules during initialization. Previously, incorrect --lora-target-modules specifications could lead to runtime ValueError exceptions during inference. The changes now proactively verify that all required modules for loaded LoRA adapters are included in the user-provided list, providing clear and actionable error messages to prevent such issues and improve system stability.
Highlights
- LoRA Target Module Validation: Implemented new validation logic in lora_manager.py to ensure that the target_modules specified by the user via --lora-target-modules correctly encompass all modules required by the loaded LoRA adapters.
- Enhanced Error Messaging: Introduced detailed ValueError messages that clearly indicate which specific modules are missing from the user's --lora-target-modules list, along with suggestions for correction, including the option to use 'all' to enable all supported modules.
- Preventing Runtime Failures: This validation prevents ValueError exceptions that previously occurred during inference when LoRA adapters attempted to access target modules not included in the user's configuration, thereby increasing the robustness of the system.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
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 issue 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
-
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. ↩
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 validation for LoRA target modules during initialization, which is a great improvement for user experience. The new error messages are clear and helpful.
My review includes a suggestion to refactor a small part of the new code to improve maintainability by removing some duplication. Overall, the change is solid.
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.
Thank you for the contribution :)
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.
LGTM
@Beichen-Ma Please fix lint |
Motivation
Currently, we assume that users specify --lora-target-modules is correct target module names. However, if this assumption is violated—specifically when:
•
--lora-path
is provided, and•
--lora-target-modules
does not include all the actual adapter’s target_modules,then it would raise ValueError during inference, such as:
ValueError: Cannot find target module name for base_model.model.model.layers.0.mlp.down_proj.lora_A.weight in {'embed_tokens'}
Modifications
We add checks that, during initialization, each LoRA adapter's required modules are included in the user-specified
--lora-target-modules
list, and provides clear error messages if not.Accuracy Tests
Tested with specifying limited
lora_target_modules
and expected ValueError raised, e.g.ValueError: LoRA adapter 'ce371f2bff874589bf7bda027ccf6300' contains target modules ['down_proj', 'gate_up_proj', 'o_proj', 'qkv_proj'] that are not included in the specified --lora-target-modules ['embed_tokens']. Please update --lora-target-modules to include all required modules: ['down_proj', 'embed_tokens', 'gate_up_proj', 'o_proj', 'qkv_proj'], or use 'all' to enable all supported modules.
Benchmarking and Profiling
Checklist