Transforms: let a backend declare what counts as a permute - #22125
Open
rascani wants to merge 9 commits into
Open
Transforms: let a backend declare what counts as a permute#22125rascani wants to merge 9 commits into
rascani wants to merge 9 commits into
Conversation
Contributor
Author
|
Stack from ghstack (oldest at bottom): |
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22125
Note: Links to docs will display an error until the docs builds have been completed. ⏳ No Failures, 280 PendingAs of commit 33053b2 with merge base 35adf60 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Aug 25, 2026
rascani
added a commit
that referenced
this pull request
Aug 25, 2026
The propagation pass matched a single hardcoded target, aten.permute_copy, so a backend carrying its own layout dialect got a pass that silently did nothing: it never recognised the copies, so it never moved them. On the Cortex-M explicit-layout path that is the difference between 1 cortex_m::transpose and 106, with the driver in place either way. Take the set through the constructor. The pass still emits _PERMUTE_TARGET when it has to create a copy, so nothing changes for a caller that does not pass the argument, and the default is the single target it matched before. Found by wiring the shared driver into the Cortex-M pipeline and measuring rather than by reading: every other extension point was exercised by the Arm suite, and this one was not, because Arm has only one permute target. No behaviour change for Arm: the pass suite produces a failure set identical to merge base, name for name. Authored with Claude Code. ghstack-source-id: c7afd33 ghstack-comment-id: 5404820390 Pull-Request: #22125
rascani
marked this pull request as ready for review
August 25, 2026 04:17
rascani
added a commit
that referenced
this pull request
Aug 25, 2026
The propagation pass matched a single hardcoded target, aten.permute_copy, so a backend carrying its own layout dialect got a pass that silently did nothing: it never recognised the copies, so it never moved them. On the Cortex-M explicit-layout path that is the difference between 1 cortex_m::transpose and 106, with the driver in place either way. Take the set through the constructor. The pass still emits _PERMUTE_TARGET when it has to create a copy, so nothing changes for a caller that does not pass the argument, and the default is the single target it matched before. Found by wiring the shared driver into the Cortex-M pipeline and measuring rather than by reading: every other extension point was exercised by the Arm suite, and this one was not, because Arm has only one permute target. No behaviour change for Arm: the pass suite produces a failure set identical to merge base, name for name. Authored with Claude Code. ghstack-source-id: 3473d66 ghstack-comment-id: 5404820390 Pull-Request: #22125
rascani
added a commit
that referenced
this pull request
Aug 25, 2026
The propagation pass matched a single hardcoded target, aten.permute_copy, so a
backend carrying its own layout dialect got a pass that silently did nothing: it
never recognised the copies, so it never moved them.
Take the set through the constructor, and thread it into the three passes the
driver delegates its actual work to. Recognising a permute widens to the
declared set; creating one still emits _PERMUTE_TARGET, so a caller that passes
no argument sees the behaviour it had before.
Threading it all the way down is the part that matters. The driver walks the
graph itself but cancels nothing on its own -- fuse_vertical hands off to
CanonicalizeViewCopyPermutePass and fuse_horizontal to
FuseIdenticalInputTransformsPass, both of which hardcoded aten.permute_copy.
Parameterising only the driver leaves it walking correctly over copies that the
passes underneath cannot see. Measured on Cortex-M explicit-layout mv2, counting
cortex_m::transpose:
driver alone, driver-only parameterisation 106 (unoptimized baseline)
driver alone, threaded through 31
driver + region cancellation, threaded through 1
the Cortex-M fixed-point loop it would replace 1
So this is what makes the shared driver reach parity on a second backend, and
make_fusion_pass is the composition point that closes the remaining 31.
Found by wiring the driver into the Cortex-M pipeline and measuring rather than
by reading: every other extension point is exercised by the Arm suite, and this
one is not, because Arm has only one permute target.
No behaviour change for Arm: the pass suite produces a failure set identical to
merge base, name for name.
Authored with Claude Code.
ghstack-source-id: 18729f7
ghstack-comment-id: 5404820390
Pull-Request: #22125
AdrianLundell
approved these changes
Aug 27, 2026
rascani
requested review from
Gasoonjia,
JacobSzwejbka,
abhinaykukkadapu,
digantdesai,
kirklandsign,
larryliu0820,
mergennachin,
psiddh,
robert-kalmar and
shoumikhin
as code owners
August 27, 2026 17:16
rascani
added a commit
that referenced
this pull request
Aug 27, 2026
The propagation pass matched a single hardcoded target, aten.permute_copy, so a
backend carrying its own layout dialect got a pass that silently did nothing: it
never recognised the copies, so it never moved them.
Take the set through the constructor, and thread it into the three passes the
driver delegates its actual work to. Recognising a permute widens to the
declared set; creating one still emits _PERMUTE_TARGET, so a caller that passes
no argument sees the behaviour it had before.
Threading it all the way down is the part that matters. The driver walks the
graph itself but cancels nothing on its own -- fuse_vertical hands off to
CanonicalizeViewCopyPermutePass and fuse_horizontal to
FuseIdenticalInputTransformsPass, both of which hardcoded aten.permute_copy.
Parameterising only the driver leaves it walking correctly over copies that the
passes underneath cannot see. Measured on Cortex-M explicit-layout mv2, counting
cortex_m::transpose:
driver alone, driver-only parameterisation 106 (unoptimized baseline)
driver alone, threaded through 31
driver + region cancellation, threaded through 1
the Cortex-M fixed-point loop it would replace 1
So this is what makes the shared driver reach parity on a second backend, and
make_fusion_pass is the composition point that closes the remaining 31.
Found by wiring the driver into the Cortex-M pipeline and measuring rather than
by reading: every other extension point is exercised by the Arm suite, and this
one is not, because Arm has only one permute target.
No behaviour change for Arm: the pass suite produces a failure set identical to
merge base, name for name.
Authored with Claude Code.
ghstack-source-id: ef4b82f
ghstack-comment-id: 5404820390
Pull-Request: #22125
rascani
added a commit
that referenced
this pull request
Aug 27, 2026
The propagation pass matched a single hardcoded target, aten.permute_copy, so a
backend carrying its own layout dialect got a pass that silently did nothing: it
never recognised the copies, so it never moved them.
Take the set through the constructor, and thread it into the three passes the
driver delegates its actual work to. Recognising a permute widens to the
declared set; creating one still emits _PERMUTE_TARGET, so a caller that passes
no argument sees the behaviour it had before.
Threading it all the way down is the part that matters. The driver walks the
graph itself but cancels nothing on its own -- fuse_vertical hands off to
CanonicalizeViewCopyPermutePass and fuse_horizontal to
FuseIdenticalInputTransformsPass, both of which hardcoded aten.permute_copy.
Parameterising only the driver leaves it walking correctly over copies that the
passes underneath cannot see. Measured on Cortex-M explicit-layout mv2, counting
cortex_m::transpose:
driver alone, driver-only parameterisation 106 (unoptimized baseline)
driver alone, threaded through 31
driver + region cancellation, threaded through 1
the Cortex-M fixed-point loop it would replace 1
So this is what makes the shared driver reach parity on a second backend, and
make_fusion_pass is the composition point that closes the remaining 31.
Found by wiring the driver into the Cortex-M pipeline and measuring rather than
by reading: every other extension point is exercised by the Arm suite, and this
one is not, because Arm has only one permute target.
No behaviour change for Arm: the pass suite produces a failure set identical to
merge base, name for name.
Authored with Claude Code.
ghstack-source-id: ef4b82f
ghstack-comment-id: 5404820390
Pull-Request: #22125
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The propagation pass matched a single hardcoded target, aten.permute_copy, so a
backend carrying its own layout dialect got a pass that silently did nothing: it
never recognised the copies, so it never moved them.
Take the set through the constructor, and thread it into the three passes the
driver delegates its actual work to. Recognising a permute widens to the
declared set; creating one still emits _PERMUTE_TARGET, so a caller that passes
no argument sees the behaviour it had before.
Threading it all the way down is the part that matters. The driver walks the
graph itself but cancels nothing on its own -- fuse_vertical hands off to
CanonicalizeViewCopyPermutePass and fuse_horizontal to
FuseIdenticalInputTransformsPass, both of which hardcoded aten.permute_copy.
Parameterising only the driver leaves it walking correctly over copies that the
passes underneath cannot see. Measured on Cortex-M explicit-layout mv2, counting
cortex_m::transpose:
So this is what makes the shared driver reach parity on a second backend, and
make_fusion_pass is the composition point that closes the remaining 31.
Found by wiring the driver into the Cortex-M pipeline and measuring rather than
by reading: every other extension point is exercised by the Arm suite, and this
one is not, because Arm has only one permute target.
No behaviour change for Arm: the pass suite produces a failure set identical to
merge base, name for name.
Authored with Claude Code.