-
Notifications
You must be signed in to change notification settings - Fork 685
[ExecuTorch][Export][1/N] Export API pipeline re-architecture, making it composable #13055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… it composable Pull Request resolved: #12936 RFC: #12660 This diff introduces composable architecture for the export pipeline. Changes: 1. Introduces notion of `PipelineArtifact` which encompasses stage artifacts and run context necessary to execute a stage and the pipeline. 1. Move all stages to new file to better architect the component 1. Export api will now accept `pipeline_stages` and honors the sequence if provided otherwise fallback to default sequence: `source_transform -> quantize -> torch.export -> to_edge_transform_and_lower -> to_executorch` 1. Validate if pipeline provided is valid, error out if not. 1. Add unittests to test pipeline sequence and stages With this one can execute a partial pipeline, for example, one can just do `TORCH_EXPORT -> TO_EDGE_TRANSFORM_AND_LOWER -> TO_EXECUTORCH` Current limitation: 1. `TORCH_EXPORT` stage is mandatory to avoid someone passing incorrect input such as `ExportedProgram` instead of nn.module, this enforcement will anchor the pipeline to have expected stages to run. - This limitation will be removed if we choose to add the support to take `ExportedProgram` as input. ## Default usage ``` recipe = ExportRecipe.get_recipe( XNNPackRecipeType.INT8_DYNAMIC_ACT_INT4_WEIGHT_PER_CHANNEL, group_size=32) export(eager_model, example_inputs, dynamic_shapes, recipe) ``` All default steps are run, `SOURCE_TRANSFORM -> QUANTIZE -> TORCH_EXPORT -> TO_EDGE_TRANSFORM_AND_LOWER -> TO_EXECUTORCH` ## Custom pipeline through recipe ``` recipe = ExportRecipe.get_recipe( XNNPackRecipeType.INT8_DYNAMIC_ACT_INT4_WEIGHT_PER_CHANNEL, group_size=32) # override stages (just for demonstration, usually recipe carries the stages that it wants to run) recipe.pipeline_stages = [ StageType.SOURCE_TRANSFORM, StageType.TORCH_EXPORT, StageType.TO_EDGE_TRANSFORM_AND_LOWER, StageType.TO_EXECUTORCH, ] export(eager_model, example_inputs, dynamic_shapes, recipe) ``` Only steps passed in are run. Note: 1. this diff is large because I moved stages to separate file and added bunch of unittests but core functionality that is added can be reviewed in `export.py` file. CC: @digantdesai 2. Export component was supposed to mimic stages design in tester and now it is. Fixes: #12928 ghstack-source-id: 300019404 @exported-using-ghexport Differential Revision: [D79120574](https://our.internmc.facebook.com/intern/diff/D79120574/)
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/13055
Note: Links to docs will display an error until the docs builds have been completed. ⏳ No Failures, 51 PendingAs of commit 1c71155 with merge base 43d90e5 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
This PR was created by the merge bot to help merge the original PR into the main branch. ghstack PR number: #12937 by @abhinaykukkadapu ^ 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/abhinaykukkadapu/2/base ghstack PR head: https://github.com/pytorch/executorch/tree/gh/abhinaykukkadapu/2/head Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/abhinaykukkadapu/1/orig Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/abhinaykukkadapu/2/orig @diff-train-skip-merge Co-authored-by: Abhinay Kukkadapu <abhinayk@meta.com>
Co-authored-by: Abhinay Kukkadapu <abhinayk@meta.com>
… it composable (pytorch#13055) Co-authored-by: Abhinay Kukkadapu <abhinayk@meta.com> Co-authored-by: Gasoonjia <gasoonjia@meta.com>
This PR was created by the merge bot to help merge the original PR into the main branch.
ghstack PR number: #12936 by @abhinaykukkadapu
^ 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/abhinaykukkadapu/1/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/abhinaykukkadapu/1/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/main
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/abhinaykukkadapu/1/orig
@diff-train-skip-merge