Skip to content

Support multimethod in export_llama_lib#17231

Merged
meta-codesync[bot] merged 11 commits intogh/lucylq/134/basefrom
gh/lucylq/134/head
Feb 13, 2026
Merged

Support multimethod in export_llama_lib#17231
meta-codesync[bot] merged 11 commits intogh/lucylq/134/basefrom
gh/lucylq/134/head

Conversation

@lucylq
Copy link
Copy Markdown
Contributor

@lucylq lucylq commented Feb 5, 2026

TODO: add CI test.

Differential Revision: [D92315602](https://our.internmc.facebook.com/intern/diff/D92315602/)

[ghstack-poisoned]
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Feb 5, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/17231

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure, 4 Unrelated Failures

As of commit 4aa2372 with merge base aa2f683 (image):

NEW FAILURE - The following job has 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.

lucylq pushed a commit that referenced this pull request Feb 5, 2026
TODO: add CI test.

Differential Revision: [D92315602](https://our.internmc.facebook.com/intern/diff/D92315602/)

ghstack-source-id: 338339885
Pull Request resolved: #17231
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 5, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 5, 2026

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@lucylq lucylq changed the title Support multimethod in export_llama_lib [wip] Support multimethod in export_llama_lib Feb 5, 2026
TODO: add CI test.

Differential Revision: [D92315602](https://our.internmc.facebook.com/intern/diff/D92315602/)

[ghstack-poisoned]
lucylq pushed a commit that referenced this pull request Feb 5, 2026
Pull Request resolved: #17231

TODO: add CI test.

Note: multimethod export is currently limited to:
- xnnpack or portable lib
- only lora (does not support arbitrary nn.Modules in each method)
- if quant is enabled, lora models must share quant schemes at source transformation time
- no pt2e quant, as each model could have slightly different results after calibration

ghstack-source-id: 338339885
@exported-using-ghexport

Differential Revision: [D92315602](https://our.internmc.facebook.com/intern/diff/D92315602/)
@lucylq lucylq requested a review from Copilot February 5, 2026 19:01
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 pull request adds multimethod export support to the Llama export library, enabling the export of multiple methods (base model and LoRA variants) into a single .pte file. This is part of a stack of PRs (#17228-#17231) that collectively add multimethod and LoRA support to the ExecuTorch runtime.

Changes:

  • Added _export_llama_multimethod() function to handle exporting multiple methods to a single .pte file
  • Added helper functions _get_xnnpack_partitioners() and _get_output_filename() to support multimethod export
  • Added validation logic to ensure multimethod export only works with XNNPACK backend or portable ops
  • Added configuration file for Qwen3 multimethod export with LoRA
  • Added comprehensive test script for validating multimethod export functionality
  • Updated build dependencies to include required tokenizer and weight conversion modules

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
examples/models/llama/export_llama_lib.py Core implementation of multimethod export logic, including validation, helper functions, and the main export function
examples/models/qwen3/config/qwen3_multimethod.yaml Configuration file demonstrating multimethod export with LoRA and base methods using environment variable interpolation
examples/models/llama/BUCK Added convert_weights.py to export library sources for proper dependency resolution
examples/models/llama/runner/targets.bzl Added regex_lookahead tokenizer dependency for enhanced tokenizer support
.ci/scripts/test_lora_multimethod.sh Comprehensive test script validating both LoRA and base method execution with expected output verification

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread examples/models/llama/export_llama_lib.py Outdated
Comment thread examples/models/llama/export_llama_lib.py Outdated
Comment thread examples/models/llama/export_llama_lib.py
Comment thread .ci/scripts/test_lora_multimethod.sh
TODO: add CI test.

Differential Revision: [D92315602](https://our.internmc.facebook.com/intern/diff/D92315602/)

[ghstack-poisoned]
lucylq pushed a commit that referenced this pull request Feb 10, 2026
Pull Request resolved: #17231

Note: multimethod export is currently limited to:
- xnnpack or portable lib
- only lora (does not support arbitrary nn.Modules in each method)
- if quant is enabled, lora models must share quant schemes at source transformation time
- no pt2e quant, as each model could have slightly different results after calibration

ghstack-source-id: 339710072
@exported-using-ghexport

Differential Revision: [D92315602](https://our.internmc.facebook.com/intern/diff/D92315602/)
@lucylq lucylq changed the title [wip] Support multimethod in export_llama_lib Support multimethod in export_llama_lib Feb 10, 2026
Copy link
Copy Markdown
Contributor

@kimishpatel kimishpatel left a 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.

TODO: add CI test.

Differential Revision: [D92315602](https://our.internmc.facebook.com/intern/diff/D92315602/)

[ghstack-poisoned]
lucylq pushed a commit that referenced this pull request Feb 13, 2026
Pull Request resolved: #17231

Note: multimethod export is currently limited to:
- xnnpack or portable lib
- only lora (does not support arbitrary nn.Modules in each method)
- if quant is enabled, lora models must share quant schemes at source transformation time
- no pt2e quant, as each model could have slightly different results after calibration

Changes:
1. Add MultimethodLoraConfig to yaml
2. Deepcopy yaml config. Move each lora_config into base.lora_config.
3. Create and export the model
4. Repeat 2,3 for each method.
5. Pass a dict of method_name: ep to `to_edge_transform_and_lower`


ghstack-source-id: 340935057
@exported-using-ghexport

Differential Revision: [D92315602](https://our.internmc.facebook.com/intern/diff/D92315602/)
TODO: add CI test.

Differential Revision: [D92315602](https://our.internmc.facebook.com/intern/diff/D92315602/)

[ghstack-poisoned]
lucylq pushed a commit that referenced this pull request Feb 13, 2026
Pull Request resolved: #17231

Note: multimethod export is currently limited to:
- xnnpack or portable lib
- only lora (does not support arbitrary nn.Modules in each method)
- if quant is enabled, lora models must share quant schemes at source transformation time
- no pt2e quant, as each model could have slightly different results after calibration

Changes:
1. Add MultimethodLoraConfig to yaml
2. Deepcopy yaml config. Move each lora_config into base.lora_config.
3. Create and export the model
4. Repeat 2,3 for each method.
5. Pass a dict of method_name: ep to `to_edge_transform_and_lower`


ghstack-source-id: 341144063
@exported-using-ghexport

Differential Revision: [D92315602](https://our.internmc.facebook.com/intern/diff/D92315602/)
TODO: add CI test.

Differential Revision: [D92315602](https://our.internmc.facebook.com/intern/diff/D92315602/)

[ghstack-poisoned]
lucylq pushed a commit that referenced this pull request Feb 13, 2026
Pull Request resolved: #17231

Note: multimethod export is currently limited to:
- xnnpack or portable lib
- only lora (does not support arbitrary nn.Modules in each method)
- if quant is enabled, lora models must share quant schemes at source transformation time
- no pt2e quant, as each model could have slightly different results after calibration

Changes:
1. Add MultimethodLoraConfig to yaml
2. Deepcopy yaml config. Move each lora_config into base.lora_config.
3. Create and export the model
4. Repeat 2,3 for each method.
5. Pass a dict of method_name: ep to `to_edge_transform_and_lower`


ghstack-source-id: 341145198
@exported-using-ghexport

Differential Revision: [D92315602](https://our.internmc.facebook.com/intern/diff/D92315602/)
TODO: add CI test.

Differential Revision: [D92315602](https://our.internmc.facebook.com/intern/diff/D92315602/)

[ghstack-poisoned]
lucylq pushed a commit that referenced this pull request Feb 13, 2026
Pull Request resolved: #17231

Note: multimethod export is currently limited to:
- xnnpack or portable lib
- only lora (does not support arbitrary nn.Modules in each method)
- if quant is enabled, lora models must share quant schemes at source transformation time
- no pt2e quant, as each model could have slightly different results after calibration

Changes:
1. Add MultimethodLoraConfig to yaml
2. Deepcopy yaml config. Move each lora_config into base.lora_config.
3. Create and export the model
4. Repeat 2,3 for each method.
5. Pass a dict of method_name: ep to `to_edge_transform_and_lower`


ghstack-source-id: 341145198
@exported-using-ghexport

Differential Revision: [D92315602](https://our.internmc.facebook.com/intern/diff/D92315602/)
TODO: add CI test.

Differential Revision: [D92315602](https://our.internmc.facebook.com/intern/diff/D92315602/)

[ghstack-poisoned]
lucylq pushed a commit that referenced this pull request Feb 13, 2026
Pull Request resolved: #17231

Note: multimethod export is currently limited to:
- xnnpack or portable lib
- only lora (does not support arbitrary nn.Modules in each method)
- if quant is enabled, lora models must share quant schemes at source transformation time
- no pt2e quant, as each model could have slightly different results after calibration

Changes:
1. Add MultimethodLoraConfig to yaml
2. Deepcopy yaml config. Move each lora_config into base.lora_config.
3. Create and export the model
4. Repeat 2,3 for each method.
5. Pass a dict of method_name: ep to `to_edge_transform_and_lower`


ghstack-source-id: 341145198
@exported-using-ghexport

Differential Revision: [D92315602](https://our.internmc.facebook.com/intern/diff/D92315602/)
TODO: add CI test.

Differential Revision: [D92315602](https://our.internmc.facebook.com/intern/diff/D92315602/)

[ghstack-poisoned]
lucylq pushed a commit that referenced this pull request Feb 13, 2026
Pull Request resolved: #17231

Note: multimethod export is currently limited to:
- xnnpack or portable lib
- only lora (does not support arbitrary nn.Modules in each method)
- if quant is enabled, lora models must share quant schemes at source transformation time
- no pt2e quant, as each model could have slightly different results after calibration

Changes:
1. Add MultimethodLoraConfig to yaml
2. Deepcopy yaml config. Move each lora_config into base.lora_config.
3. Create and export the model
4. Repeat 2,3 for each method.
5. Pass a dict of method_name: ep to `to_edge_transform_and_lower`


ghstack-source-id: 341145198
@exported-using-ghexport

Differential Revision: [D92315602](https://our.internmc.facebook.com/intern/diff/D92315602/)
TODO: add CI test.

Differential Revision: [D92315602](https://our.internmc.facebook.com/intern/diff/D92315602/)

[ghstack-poisoned]
lucylq pushed a commit that referenced this pull request Feb 13, 2026
Pull Request resolved: #17231

Note: multimethod export is currently limited to:
- xnnpack or portable lib
- only lora (does not support arbitrary nn.Modules in each method)
- if quant is enabled, lora models must share quant schemes at source transformation time
- no pt2e quant, as each model could have slightly different results after calibration

Changes:
1. Add MultimethodLoraConfig to yaml
2. Deepcopy yaml config. Move each lora_config into base.lora_config.
3. Create and export the model
4. Repeat 2,3 for each method.
5. Pass a dict of method_name: ep to `to_edge_transform_and_lower`


ghstack-source-id: 341235800
@exported-using-ghexport

Differential Revision: [D92315602](https://our.internmc.facebook.com/intern/diff/D92315602/)
TODO: add CI test.

Differential Revision: [D92315602](https://our.internmc.facebook.com/intern/diff/D92315602/)

[ghstack-poisoned]
lucylq pushed a commit that referenced this pull request Feb 13, 2026
Pull Request resolved: #17231

Note: multimethod export is currently limited to:
- xnnpack or portable lib
- only lora (does not support arbitrary nn.Modules in each method)
- if quant is enabled, lora models must share quant schemes at source transformation time
- no pt2e quant, as each model could have slightly different results after calibration

Changes:
1. Add MultimethodLoraConfig to yaml
2. Deepcopy yaml config. Move each lora_config into base.lora_config.
3. Create and export the model
4. Repeat 2,3 for each method.
5. Pass a dict of method_name: ep to `to_edge_transform_and_lower`


ghstack-source-id: 341235800
@exported-using-ghexport

Differential Revision: [D92315602](https://our.internmc.facebook.com/intern/diff/D92315602/)
@meta-codesync meta-codesync Bot merged commit 943e869 into gh/lucylq/134/base Feb 13, 2026
334 of 341 checks passed
@meta-codesync meta-codesync Bot deleted the gh/lucylq/134/head branch February 13, 2026 23:59
lucylq added a commit that referenced this pull request Feb 15, 2026
This PR was created by the merge bot to help merge the original PR into
the main branch.
ghstack PR number: #17231 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/134/base
ghstack PR head:
https://github.com/pytorch/executorch/tree/gh/lucylq/134/head
Merge bot PR base:
https://github.com/pytorch/executorch/tree/gh/lucylq/133/orig
Merge bot PR head:
https://github.com/pytorch/executorch/tree/gh/lucylq/134/orig
Differential Revision:
[D92315602](https://our.internmc.facebook.com/intern/diff/D92315602/)
@diff-train-skip-merge

---------

Co-authored-by: Github Executorch <github_executorch@arm.com>
Co-authored-by: lucylq <lfq@meta.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants