Skip to content

Conversation

@Erik-Lundell
Copy link
Collaborator

@Erik-Lundell Erik-Lundell commented Oct 10, 2025

Add PostToBackend stage to Recipes
After a discussion in #14588, it was decided to
create an additional recipe stage to run passes after partitioning.
This is meant for backends that convert ops directly instead of
partitioning.

Add RequireExportProgram mixin for passes
It is a common pattern that passes require an exported program,
which means that the pass needs to be constructed right before
it is ran, with the correct exported program. Today there is no
unified way this is done, which makes it tricky for general pass handling
to figure out whether to pass an exported program to the constructor or not.
This commit solves this by introducing a RequireExportProgram mixin,
and makes a best effort to migirate passes to this system.

Note that there are passes which require other arguments that
still will break general pass handling.

cc @freddan80 @per @zingo @oscarandersson8218 @digantdesai

@pytorch-bot
Copy link

pytorch-bot bot commented Oct 10, 2025

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 22 New Failures

As of commit 090baad with merge base 5cf193a (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@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 Oct 10, 2025
@Erik-Lundell Erik-Lundell added partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm ciflow/trunk release notes: none Do not include this in the release notes and removed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Oct 10, 2025
@Erik-Lundell Erik-Lundell changed the title Post to backend stage Add Post to backend stage to recipes Oct 10, 2025
@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 Oct 10, 2025
It is a common pattern that passes require an exported program,
which means that the pass needs to be constructed right before
it is ran, with the correct exported program. Today there is no
unified way this is done, which makes it tricky for general pass handling
to figure out whether to pass an exported program to the constructor or not.
This commit solves this by introducing a RequireExportProgram mixin,
and makes a best effort to migirate passes to this system.

Note that there are passes which require other arguments that
still will break general pass handling.

Signed-off-by: Erik Lundell <[email protected]>
Change-Id: Ifaef3069fb04d6ab3df68b1d303aae7dc42585f2
After a discussion in pytorch#14588, it was decided to
create an additional recipe stage to run passes after partitioning.
This is meant for backends that convert ops directly instead of
partitioning.

Signed-off-by: Erik Lundell <[email protected]>
Change-Id: Iddf74accb739d4dff16fa46c6fad88ffccfe2f3b
@zingo
Copy link
Collaborator

zingo commented Oct 30, 2025

Hi @abhinaykukkadapu and @digantdesai I think you commented on the original issue leading up to this change, is it OK to merge this?



class RequireExportedProgram:
"""Mixin to require a pass to take an exported program, which is accessed by the exported_program property.
Copy link
Contributor

@abhinaykukkadapu abhinaykukkadapu Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Erik-Lundell @zingo Sorry for the late response and thanks for following up on this change, i've done some "standardization" when passes needs an ExportedProgram. QNN backend has exact issue where some passes wants ExportedProgram, i think we can follow similar pattern here too, here is the code ptr: https://github.com/pytorch/executorch/blob/main/backends/qualcomm/recipes/qnn_recipe_provider.py#L142

Basic idea is that the recipe will get a callable similar to aten_transform_passes and the callable can have a sequence of passes instantiated with or without EP. Let me know if you have any questions.

After you are done, i will probably take a stab at creating a single stage for all the pass related steps and then that stage shall be plugged in at various stages pre/post et stages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm release notes: none Do not include this in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants