-
Notifications
You must be signed in to change notification settings - Fork 837
Introduce LoraConfig #17229
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: gh/lucylq/132/base
Are you sure you want to change the base?
Introduce LoraConfig #17229
Conversation
Differential Revision: [D92304723](https://our.internmc.facebook.com/intern/diff/D92304723/) [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/17229
Note: Links to docs will display an error until the docs builds have been completed. ❌ 4 New Failures, 1 Cancelled JobAs of commit 7124c01 with merge base aa2f683 ( NEW FAILURES - The following jobs have failed:
CANCELLED JOB - The following job was cancelled. Please retry:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
Differential Revision: [D92304723](https://our.internmc.facebook.com/intern/diff/D92304723/) [ghstack-poisoned]
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.
Pull request overview
This PR introduces a LoraConfig dataclass to encapsulate LoRA (Low-Rank Adaptation) adapter configuration, replacing the previous separate adapter_checkpoint and adapter_config fields in BaseConfig. This refactoring improves code organization and provides a cleaner API for LoRA configuration.
Changes:
- Added
LoraConfigdataclass with validation and automatic config parsing from JSON - Refactored
BaseConfigto useLoraConfiginstead of separate adapter fields - Updated
from_argsmethod to createLoraConfiginstances from CLI arguments - Simplified adapter loading logic in
Llama2Modelby using the newLoraConfigobject
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| extension/llm/export/config/llm_config.py | Introduces LoraConfig dataclass with validation, updates BaseConfig to use it, and modifies from_args to create LoraConfig from CLI arguments |
| examples/models/llama/model.py | Refactors adapter loading to use LoraConfig object, simplifying the logic by removing redundant validation and JSON parsing |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Differential Revision: [D92304723](https://our.internmc.facebook.com/intern/diff/D92304723/) [ghstack-poisoned]
Differential Revision: [D92304723](https://our.internmc.facebook.com/intern/diff/D92304723/) [ghstack-poisoned]
Pull Request resolved: #17229 Introduce LoraConfig to hold lora parameters such as: - checkpoint - rank - target_modules (e.g. q_proj, k_proj, v_proj, up_proj, down_proj, gate_proj, o_proj) - lora_alpha LoraConfig validation done post-init. LoraConfig can be created with config.json file. Update cases of export_llama_lib to use LoraConfig instead of adapter_checkpoint and adapter_config. NOTE: we may need to extend this to support more customizable features like lora config per layer etc. cc @hakanb ghstack-source-id: 340400147 @exported-using-ghexport Differential Revision: [D92304723](https://our.internmc.facebook.com/intern/diff/D92304723/)
Differential Revision: [D92304723](https://our.internmc.facebook.com/intern/diff/D92304723/) [ghstack-poisoned]
Pull Request resolved: #17229 Introduce LoraConfig to hold lora parameters such as: - checkpoint - rank - target_modules (e.g. q_proj, k_proj, v_proj, up_proj, down_proj, gate_proj, o_proj) - lora_alpha LoraConfig validation done post-init. LoraConfig can be created with config.json file. Update cases of export_llama_lib to use LoraConfig instead of adapter_checkpoint and adapter_config. NOTE: we may need to extend this to support more customizable features like lora config per layer etc. cc @hakanb ghstack-source-id: 340423626 @exported-using-ghexport Differential Revision: [D92304723](https://our.internmc.facebook.com/intern/diff/D92304723/)
Differential Revision: [D92304723](https://our.internmc.facebook.com/intern/diff/D92304723/) [ghstack-poisoned]
Pull Request resolved: #17229 Introduce LoraConfig to hold lora parameters such as: - checkpoint - rank - target_modules (e.g. q_proj, k_proj, v_proj, up_proj, down_proj, gate_proj, o_proj) - lora_alpha LoraConfig validation done post-init. LoraConfig can be created with config.json file. Update cases of export_llama_lib to use LoraConfig instead of adapter_checkpoint and adapter_config. NOTE: we may need to extend this to support more customizable features like lora config per layer etc. cc @hakanb ghstack-source-id: 340434171 @exported-using-ghexport Differential Revision: [D92304723](https://our.internmc.facebook.com/intern/diff/D92304723/)
Differential Revision: [D92304723](https://our.internmc.facebook.com/intern/diff/D92304723/) [ghstack-poisoned]
Pull Request resolved: #17229 Introduce LoraConfig to hold lora parameters such as: - checkpoint - rank - target_modules (e.g. q_proj, k_proj, v_proj, up_proj, down_proj, gate_proj, o_proj) - lora_alpha LoraConfig validation done post-init. LoraConfig can be created with config.json file. Update cases of export_llama_lib to use LoraConfig instead of adapter_checkpoint and adapter_config. NOTE: we may need to extend this to support more customizable features like lora config per layer etc. cc @hakanb ghstack-source-id: 340443733 @exported-using-ghexport Differential Revision: [D92304723](https://our.internmc.facebook.com/intern/diff/D92304723/)
Differential Revision: [D92304723](https://our.internmc.facebook.com/intern/diff/D92304723/) [ghstack-poisoned]
Pull Request resolved: #17229 Introduce LoraConfig to hold lora parameters such as: - checkpoint - rank - target_modules (e.g. q_proj, k_proj, v_proj, up_proj, down_proj, gate_proj, o_proj) - lora_alpha LoraConfig validation done post-init. LoraConfig can be created with config.json file. Update cases of export_llama_lib to use LoraConfig instead of adapter_checkpoint and adapter_config. NOTE: we may need to extend this to support more customizable features like lora config per layer etc. cc @hakanb ghstack-source-id: 340443733 @exported-using-ghexport Differential Revision: [D92304723](https://our.internmc.facebook.com/intern/diff/D92304723/)
kimishpatel
left a comment
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.
Review automatically exported from Phabricator review in Meta.
Differential Revision: [D92304723](https://our.internmc.facebook.com/intern/diff/D92304723/) [ghstack-poisoned]
Pull Request resolved: #17229 Introduce LoraConfig to hold lora parameters such as: - checkpoint - rank - target_modules (e.g. q_proj, k_proj, v_proj, up_proj, down_proj, gate_proj, o_proj) - lora_alpha LoraConfig validation done post-init. LoraConfig can be created with config.json file. Update cases of export_llama_lib to use LoraConfig instead of adapter_checkpoint and adapter_config. NOTE: we may need to extend this to support more customizable features like lora config per layer etc. cc @hakanb ghstack-source-id: 340525244 @exported-using-ghexport Differential Revision: [D92304723](https://our.internmc.facebook.com/intern/diff/D92304723/)
Differential Revision: [D92304723](https://our.internmc.facebook.com/intern/diff/D92304723/) [ghstack-poisoned]
Pull Request resolved: #17229 Introduce LoraConfig to hold lora parameters such as: - checkpoint - rank - target_modules (e.g. q_proj, k_proj, v_proj, up_proj, down_proj, gate_proj, o_proj) - lora_alpha LoraConfig validation done post-init. LoraConfig can be created with config.json file. Update cases of export_llama_lib to use LoraConfig instead of adapter_checkpoint and adapter_config. NOTE: we may need to extend this to support more customizable features like lora config per layer etc. cc @hakanb ghstack-source-id: 340525244 @exported-using-ghexport Differential Revision: [D92304723](https://our.internmc.facebook.com/intern/diff/D92304723/)
Stack from ghstack (oldest at bottom):
Differential Revision: D92304723