Skip to content

Transforms: stop fork splitting from stranding a permute - #22124

Open
rascani wants to merge 2 commits into
gh/rascani/27/headfrom
gh/rascani/28/head
Open

Transforms: stop fork splitting from stranding a permute#22124
rascani wants to merge 2 commits into
gh/rascani/27/headfrom
gh/rascani/28/head

Conversation

@rascani

@rascani rascani commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Splitting a permute over a fork is meant to be free: each branch takes its own
copy on the way down, and the copies merge again on the way up. That holds when
every branch behaves the same way -- branches that rejoin have their copies
fused at the meeting node, branches that stay separate have theirs hoisted back
to the shared producer.

It does not hold for a fork where some branches rejoin and others do not. The
rejoining side ends with a copy below the meeting node, the diverging side with
one at the source, and neither mechanism can bring those together: upward
propagation has no fork split of its own, so it cannot hoist a copy above a
rejoin. Five ops are enough to see it, with no views and no quantization:

p = x.permute(0, 2, 3, 1)
return torch.abs(p) + torch.neg(p), torch.sigmoid(p)

before: 1   after Down: 2   after Up: 2

Decline the split in exactly that shape. Uniform forks are unaffected, which is
what keeps the existing behaviour: all-rejoin still splits and fuses at the
meeting node, all-diverge still splits and merges at the producer. A sweep of 75
fan-out shapes now regresses none, and the wins on real graphs are unchanged --
MultiheadAttention 10 to 9, TransformerEncoderLayer 14 to 11.

Also stop is_swappable raising on a non-keepdim reduction. The shared pass
answers the question it was asked and declines; Arm overrides it to keep raising,
since its pipeline normalizes reductions earlier and a violation there means the
ordering is wrong rather than that the graph is unusual.

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]
@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/22124

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

❌ 8 New Failures, 1 Unrelated Failure

As of commit be06ff4 with merge base e831b3e (image):

NEW FAILURES - The following jobs have failed:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

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

[ghstack-poisoned]
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.

1 participant