pytorch / pytorch/executorch

Introduce export_llama to extension/llm as export_llm

Open
#11,527 4 comments 0 reactions 1 assignee View on GitHub

@jackzhxng is already working on this.

Since Jun 10, 2025.

  • #11746 by @jackzhxng — merged
  • #11809 by @jackzhxng — merged
  • #11811 by @jackzhxng — merged
  • #11833 by @jackzhxng — merged
  • #11836 by @jackzhxng — merged
module: llm triaged
Dominant language
Python
Stars
5k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
581

Description

🚀 The feature, motivation and pitch

To generalize export_llama better to transformers as export_llm, the following directories and files in examples/models/llama will be moved to extension/llm:

  • examples/models/llama/config
  • examples/models/llama/source_transformation
  • examples/models/llama/tests
  • attention.py -> Will go into a new attention directory
  • export_llama_hydra.py -> this will be renamed to export_llm.py and will be the main entrypoint to the new API
  • export_llama_lib.py -> this will be renamed to export_llm_lib.py
  • fairseq2.py
  • hf_download.py
  • llama_transformer.py -> this will be renamed to transformer.py
  • model.py -> this will have Llama2Model renamed to TransformerModel. Also not a big fan of the naming of this file, open to take this opportunity to rename to eager.py or something like that to its intent better, which is to instantiate the model.
    • We could remove Llama-specific components from the version in extension/llm such as Fairseq2 and have Llama2Model inherit from it
  • model_args.py
  • norm.py
  • rope.py
  • static_attention.py -> Will go into a new attention directory

Key notes:

  • export_llama.py stays put, export_llama will still exist to preserve BC, especially internally
    • export_llama_args.py then also stays put, supporting the legacy CLI
    • export_llama_hydra.py will be the new export_llm powered by Hydra, and it will be in extension/llm. Note that this means that the export_llm API will not support the legacy CLI
  • Lots of internal callsites for functions in export_llama_lib such as _prepare_for_llama_export and _export_llama. These will need to all be renamed and refactored.
Alternatives

No response

Additional context

No response

RFC (Optional)

No response

cc @larryliu0820 @mergennachin @cccclai @helunwencser

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.