Skip to content

Conversation

@metascroy
Copy link
Contributor

The current design of using EDGE_DO_NOT_DECOMP to prevent decomposition has long standing issues, and often fails lowering when certain ops are requested for preservation. This shows up most notably in the CoreML backend, where most ops are requested for preservation.

As a band-aid, we introduced _remove_invalid_ops_for_not_decompose to cover certain kinds of ops. But when an op is encountered that we do not have an exception for, lowering still fails.

We also recently found another bug that shows up for SDPA related to contiguous views (https://fb.workplace.com/groups/pytorch.edge.users/permalink/1796069037930048/) that we still do not fully understand the root cause of.

EDGE_DO_NOT_DECOMP is actually only used to support the "check_op_support" argument in the partitioner; ops_to_not_decompose only modifies the default composition table.

In CoreML's case, "check_op_support" is not used, and the issues with EDGE_DO_NOT_DECOMP's design causes lots of lowering issues that are hard to keep up with. This PR enables a new path that bypasses EDGE_DO_NOT_DECOMP's when possible (_can_skip_using_EDGE_DO_NOT_DECOMP).

Long term, we need to address the buggy design of EDGE_DO_NOT_DECOMP. There are some ideas here: https://fb.workplace.com/groups/pytorch.edge2.team/permalink/1241898747065975/

@pytorch-bot
Copy link

pytorch-bot bot commented Jul 16, 2025

🔗 Helpful Links

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

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

❌ 1 New Failure, 1 Unrelated Failure

As of commit 7c5bfc2 with merge base 9e05d89 (image):

NEW FAILURE - The following job has failed:

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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 Jul 16, 2025
@metascroy metascroy requested review from mcr229 and removed request for JacobSzwejbka and larryliu0820 July 16, 2025 21:48
@github-actions
Copy link

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.

@JacobSzwejbka
Copy link
Contributor

@larryliu0820 @lucylq maybe relevant for the non delegated paths we have been talking about

@metascroy metascroy requested a review from larryliu0820 July 17, 2025 17:01
Copy link
Contributor

@mcr229 mcr229 left a comment

Choose a reason for hiding this comment

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

yea this makes sense. sorry it has been so buggy. I've been meaning to look into it but haven't had the bw.

I've been trying to rethink this a little bit. Right now i think the cases check_op_support isn't use that often altogether(there used to be some cases, but i think they were slowly resolved out). I wonder if we should drop it altogether, but then i worry about cases where an aten op is actually sometimes supported, and for best delegation the backend should try and delegate its decomposition.

@metascroy
Copy link
Contributor Author

check_op_support

Yeah I don't know a good solution for check_op_support. I think @larryliu0820's idea of moving to_backend before to_edge was to let backends control this at a finer granularity.

@metascroy metascroy merged commit 5e03d33 into main Jul 17, 2025
363 of 370 checks passed
@metascroy metascroy deleted the fix-coreml-to-edge-transform-and-lower branch July 17, 2025 18:14
@metascroy metascroy restored the fix-coreml-to-edge-transform-and-lower branch July 17, 2025 20:56
metascroy added a commit that referenced this pull request Jul 17, 2025
…NOT_DECOMP namespace" (#12608)

Reverts #12564

This conflicts with the PR that landed shortly before it:
#12306
metascroy added a commit that referenced this pull request Jul 22, 2025
Re-land of: #12564 

Previous attempt had conflict with
#12306 that caused CI
failure.

------

The current design of using EDGE_DO_NOT_DECOMP to prevent decomposition
has long standing issues, and often fails lowering when certain ops are
requested for preservation. This shows up most notably in the CoreML
backend, where most ops are requested for preservation.

As a band-aid, we introduced _remove_invalid_ops_for_not_decompose to
cover certain kinds of ops. But when an op is encountered that we do not
have an exception for, lowering still fails.

We also recently found another bug that shows up for SDPA related to
contiguous views
(https://fb.workplace.com/groups/pytorch.edge.users/permalink/1796069037930048/)
that we still do not fully understand the root cause of.

EDGE_DO_NOT_DECOMP is actually only used to support the
"check_op_support" argument in the partitioner; ops_to_not_decompose
only modifies the default composition table.

In CoreML's case, "check_op_support" is not used, and the issues with
EDGE_DO_NOT_DECOMP's design causes lots of lowering issues that are hard
to keep up with. This PR enables a new path that bypasses
EDGE_DO_NOT_DECOMP's when possible (_can_skip_using_EDGE_DO_NOT_DECOMP).

Long term, we need to address the buggy design of EDGE_DO_NOT_DECOMP.
There are some ideas here:
https://fb.workplace.com/groups/pytorch.edge2.team/permalink/1241898747065975/

cc @kimishpatel @YifanShenSZ @cymbalrush
Conarnar pushed a commit to Conarnar/executorch that referenced this pull request Jul 25, 2025
Re-land of: pytorch#12564 

Previous attempt had conflict with
pytorch#12306 that caused CI
failure.

------

The current design of using EDGE_DO_NOT_DECOMP to prevent decomposition
has long standing issues, and often fails lowering when certain ops are
requested for preservation. This shows up most notably in the CoreML
backend, where most ops are requested for preservation.

As a band-aid, we introduced _remove_invalid_ops_for_not_decompose to
cover certain kinds of ops. But when an op is encountered that we do not
have an exception for, lowering still fails.

We also recently found another bug that shows up for SDPA related to
contiguous views
(https://fb.workplace.com/groups/pytorch.edge.users/permalink/1796069037930048/)
that we still do not fully understand the root cause of.

EDGE_DO_NOT_DECOMP is actually only used to support the
"check_op_support" argument in the partitioner; ops_to_not_decompose
only modifies the default composition table.

In CoreML's case, "check_op_support" is not used, and the issues with
EDGE_DO_NOT_DECOMP's design causes lots of lowering issues that are hard
to keep up with. This PR enables a new path that bypasses
EDGE_DO_NOT_DECOMP's when possible (_can_skip_using_EDGE_DO_NOT_DECOMP).

Long term, we need to address the buggy design of EDGE_DO_NOT_DECOMP.
There are some ideas here:
https://fb.workplace.com/groups/pytorch.edge2.team/permalink/1241898747065975/

cc @kimishpatel @YifanShenSZ @cymbalrush
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants