Make multimethod generic in llm_config#18213
Make multimethod generic in llm_config#18213meta-codesync[bot] merged 3 commits intogh/lucylq/140/basefrom
Conversation
Differential Revision: [D96822523](https://our.internmc.facebook.com/intern/diff/D96822523/) [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/18213
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (2 Unrelated Failures)As of commit f42c141 with merge base 28b4813 ( BROKEN TRUNK - The following jobs failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Differential Revision: [D96822523](https://our.internmc.facebook.com/intern/diff/D96822523/) ghstack-source-id: 352958349 Pull Request resolved: #18213
This PR needs a
|
kimishpatel
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
Differential Revision: [D96822523](https://our.internmc.facebook.com/intern/diff/D96822523/) [ghstack-poisoned]
Pull Request resolved: #18213 MultimethodLoraConfig --> MultimethodConfig Introduce MethodConfig for per-method configs (currently just lora). Default to the base llm_config params for everything else. Program-wide configs (such as share_mutable_buffers) stay under MultimethodConfig. ghstack-source-id: 358171273 @exported-using-ghexport Differential Revision: [D96822523](https://our.internmc.facebook.com/intern/diff/D96822523/)
There was a problem hiding this comment.
Pull request overview
This PR generalizes the LLM export “multimethod” configuration by renaming the previous multimethod_lora configuration to a more generic multimethod and switching from a dict-based schema to a list of per-method config objects, then updating the example YAML and llama export path accordingly.
Changes:
- Replace
MultimethodLoraConfigwithMultimethodConfig+ newMethodConfig(list-based schema) inLlmConfig. - Update Qwen3 multimethod example YAML to the new schema.
- Update llama export/validation logic to consume
llm_config.multimethodand iterate through method configs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| extension/llm/export/config/llm_config.py | Introduces MethodConfig and replaces multimethod_lora with a generic multimethod list-based configuration. |
| examples/models/qwen3/config/qwen3_multimethod.yaml | Updates the Qwen3 multimethod example to use the new multimethod.methods list format. |
| examples/models/llama/export_llama_lib.py | Updates validation and multimethod export logic to use the new config shape and naming. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| """Configuration for exporting multiple methods to a single .pte file. | ||
|
|
||
| Maps method names to optional LoRA configurations. A None value means | ||
| the method uses base model weights. | ||
|
|
There was a problem hiding this comment.
The MultimethodConfig docstring still says it "Maps method names" even though methods is now a List[MethodConfig]. This is misleading for config authors; please update the docstring wording to reflect the list-based schema (and, if relevant, that each list element’s lora_config=None means base weights).
|
|
||
| # Get the exported program | ||
| exported_program = builder._export(builder.pre_autograd_graph_module) | ||
| method_to_program[method_name] = exported_program | ||
| method_to_program[method.method_name] = exported_program |
There was a problem hiding this comment.
With multimethod.methods now being a list, duplicate method_name entries are possible. The current code will silently overwrite earlier entries in method_to_program[...], but num_methods/logging still counts duplicates, which can lead to confusing or incorrect exports. Please validate that all method.method_name values are unique (and non-empty) before populating method_to_program, and raise a clear error if duplicates are found.
Differential Revision: [D96822523](https://our.internmc.facebook.com/intern/diff/D96822523/) [ghstack-poisoned]
Pull Request resolved: #18213 MultimethodLoraConfig --> MultimethodConfig Introduce MethodConfig for per-method configs (currently just lora). Default to the base llm_config params for everything else. Program-wide configs (such as share_mutable_buffers) stay under MultimethodConfig. ghstack-source-id: 358256777 @exported-using-ghexport Differential Revision: [D96822523](https://our.internmc.facebook.com/intern/diff/D96822523/)
df879a8
into
gh/lucylq/140/base
This PR was created by the merge bot to help merge the original PR into the main branch. ghstack PR number: #18213 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/140/base ghstack PR head: https://github.com/pytorch/executorch/tree/gh/lucylq/140/head Merge bot PR base: https://github.com/pytorch/executorch/tree/main Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/lucylq/140/orig Differential Revision: [D96822523](https://our.internmc.facebook.com/intern/diff/D96822523/) @diff-train-skip-merge Co-authored-by: Github Executorch <github_executorch@arm.com>
Stack from ghstack (oldest at bottom):
Differential Revision: D96822523