Skip to content

Transforms: let a backend declare what counts as a permute - #22125

Open
rascani wants to merge 9 commits into
gh/rascani/28/headfrom
gh/rascani/29/head
Open

Transforms: let a backend declare what counts as a permute#22125
rascani wants to merge 9 commits into
gh/rascani/28/headfrom
gh/rascani/29/head

Conversation

@rascani

@rascani rascani commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

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-poisoned]
@rascani

rascani commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@pytorch-bot

pytorch-bot Bot commented Aug 25, 2026

Copy link
Copy Markdown

🔗 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 Pending

As of commit 33053b2 with merge base 35adf60 (image):
💚 Looks good so far! There are no failures yet. 💚

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

[ghstack-poisoned]
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
rascani marked this pull request as ready for review August 25, 2026 04:17
@rascani
rascani requested a review from AdrianLundell August 25, 2026 04:17
[ghstack-poisoned]
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
[ghstack-poisoned]
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
[ghstack-poisoned]
[ghstack-poisoned]
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
@linux-foundation-easycla

linux-foundation-easycla Bot commented Aug 27, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

@rascani
rascani changed the base branch from gh/rascani/28/head to gh/rascani/41/head August 27, 2026 17:17
@github-actions github-actions Bot added ciflow/trunk module: arm Issues related to arm backend labels Aug 27, 2026
[ghstack-poisoned]
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
rascani changed the base branch from gh/rascani/41/head to gh/rascani/28/head August 27, 2026 17:30
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. module: arm Issues related to arm backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants