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, 6 Unrelated FailuresAs of commit 53a5176 with merge base aa2f683 ( NEW FAILURES - The following jobs have failed:
FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
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.
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.
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/)
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/)
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: 340930093 @exported-using-ghexport Differential Revision: [D92304723](https://our.internmc.facebook.com/intern/diff/D92304723/)
3ac1f31
into
gh/lucylq/132/base
This PR was created by the merge bot to help merge the original PR into the main branch. ghstack PR number: #17229 by @lucylq ^ Please use this as the source of truth for the PR details, comments, and reviews ghstack PR base: https://github.com/pytorch/executorch/tree/gh/lucylq/132/base ghstack PR head: https://github.com/pytorch/executorch/tree/gh/lucylq/132/head Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/lucylq/131/orig Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/lucylq/132/orig Differential Revision: [D92304723](https://our.internmc.facebook.com/intern/diff/D92304723/) @diff-train-skip-merge Co-authored-by: Github Executorch <github_executorch@arm.com>
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: 340930093 @exported-using-ghexport Differential Revision: [D92304723](https://our.internmc.facebook.com/intern/diff/D92304723/)
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: 340930093 @exported-using-ghexport Differential Revision: [D92304723](https://our.internmc.facebook.com/intern/diff/D92304723/) Co-authored-by: Github Executorch <github_executorch@arm.com>
Pull Request resolved: pytorch#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: 340930093 @exported-using-ghexport Differential Revision: [D92304723](https://our.internmc.facebook.com/intern/diff/D92304723/) Co-authored-by: Github Executorch <github_executorch@arm.com>
Stack from ghstack (oldest at bottom):
Differential Revision: D92304723