pytorch / pytorch/executorch

[RFC][Short] More on ExportRecipes

Open
#12,660 0 comments 0 reactions 1 assignee View on GitHub

@abhinaykukkadapu is already working on this.

Since Jul 21, 2025.

rfc triaged
Dominant language
Python
Stars
5k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
581

Description

Discussed in https://github.com/pytorch/executorch/discussions/12553

Originally posted by abhinaykukkadapu July 16, 2025
This discussion outlines few proposals regarding the ExportRecipes (currently experimental). These requirements have emerged from various discussions, and I want to consolidate them here for further discussion and prioritization:

1. API Naming

There is potential confusion between torch.export.export() and executorch.export(), especially since the latter encompasses additional functionalities such as quantization, lowering, and serialization. A previously proposed solution is to rename executorch.export(..) -> executorch.compile(..). This change could enhance clarity, but it may also be unnecessary. I would like to gather your thoughts on whether a renaming is warranted.

2. Support for Additional Backend Recipes

Support additional backend recipes

  • XNNPack (supported)
  • CoreML
  • QNN
3. QAT Quantization support

Currently, our recipes support Post-Training Quantization (PTQ). Should we extend this support to include Quantization-Aware Training (QAT)? Additionally, which backends currently support QAT, or we should at least transparently error out if QAT based recipe is passed?

4. Differentiating Calibration Inputs vs Example Inputs

The proposal is to add a new parameter, calibration_inputs, to the API alongside example_inputs. This parameter would explicitly indicate to users that the data provided in calibration_inputs is used for quantization purposes, while example_inputs are solely for export.

5. Support for ExportedProgram

At present, the API requires an nn.Module and assumes that the export stage is always run within the scope of the recipe. The proposal is to decouple this to accept either an ExportedProgram or an nn.Module. This change would help use cases such as HuggingFace Optimum, where the ExportRecipe can be utilized for post export stages such as graph quantization, lowering. This would provide greater flexibility for models to use torch.export.export(...) in a manner that suits their needs but use recipes for just quantization and lowering.

6. Support to_edge -> to_backend -> to_executorch along with to_edge_transform_and_lower

Currently, the executorch/export supports only the to_edge_transform_and_lower API. Is there a need to support to_edge() -> to_backend() -> to_executorch()?

7. Modularization of ExportRecipe

Split current ExportRecipe into piece-meal recipes such asExportRecipe, QuantizationRecipe, LoweringRecipe and have a root recipe for example: CompileRecipe which takes all the above. This might require re-writing most of the current ExportRecipe component, so not sure if this is needed, we may just get away with doing just (5) - Supporting ExportedProgram which skips torch.export.export() and SourceTransform stages which might be just sufficient.

8. Composable stages

Add support for composable stages to support dynamically running various lowering paths, user should have the power to choose the sequence of steps, we will validate if the provided sequence is valid. For example, user can choose between:

  • TORCH_EXPORT -> TO_EDGE_TRANSFORM_LOWER -> TO_EXECUTORCH
  • TORCH_EXPORT -> TO_EDGE -> TO_BACKEND -> TO_EXECUTORCH

CC: @cbilgin, @mergennachin, @kimishpatel, @metascroy, @JacobSzwejbka, @guangy10, @digantdesai, @mcr229, @jackzhxng, @JakeStevens

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.