Repository navigation
Extend permute removal through singleton and sink views (#22549) - #22549
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22549
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 43544a2 with merge base 7dc8641 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@mcremon-meta has exported this pull request. If you are a Meta employee, you can view the originating Diff in D116686835. |
This PR needs a
|
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
The conservative sink-view rules look well chosen: only a single non-unit dimension is relocatable without changing element order, rank must match the surrounding permutation, and single-user ownership avoids rewriting a shape consumed under two layout assumptions. Extending reductions requires remapping the reduced axis as well as removing permutes, so the new amax/amin cases are important. The numerical before/after graph execution checks make this substantially safer than node-count assertions alone.
Summary: Widen the regions `RemovePermutesAroundElementwiseOps` can collapse by handling two view patterns that previously terminated a region, and extend the permutable set to the `amax`/`amin` reductions. Singleton boundary views: when a view that only inserts unit dimensions sits between a region's incoming and outgoing layout transforms, compose the pair across it and rewrite the view's target shape, so the boundary is removed instead of ending the region. Reject the composition unless the view has a single user and the outgoing permutation restores the incoming axis labels to identity order. Broadcast sink views: replace the conservative consumer walk with an exact shape remap. A sink reshape carrying at most one non-unit dimension has layout-invariant element order, so remap its target shape into the layout preceding the region, letting its broadcast axes line up once the boundary transforms are dropped. Reject sinks whose output has more than one non-unit dimension or whose rank does not match the region permutation, along with shared boundary views whose replacements would be ambiguous. Reductions: `amax` and `amin` join `mean.dim` and `sum.dim_IntList` in the permutable op set, and the dim-remapping helper (renamed `update_reduction_dim`) now accepts a scalar `dim` in addition to a list. The transform is shared rather than backend-specific, so the widened region coverage applies to every backend that runs it. Differential Revision: D116686835
7d4e178 to
3d61031
Compare
Summary: Widen the regions `RemovePermutesAroundElementwiseOps` can collapse by handling two view patterns that previously terminated a region, and extend the permutable set to the `amax`/`amin` reductions. Singleton boundary views: when a view that only inserts unit dimensions sits between a region's incoming and outgoing layout transforms, compose the pair across it and rewrite the view's target shape, so the boundary is removed instead of ending the region. Reject the composition unless the view has a single user and the outgoing permutation restores the incoming axis labels to identity order. Broadcast sink views: replace the conservative consumer walk with an exact shape remap. A sink reshape carrying at most one non-unit dimension has layout-invariant element order, so remap its target shape into the layout preceding the region, letting its broadcast axes line up once the boundary transforms are dropped. Reject sinks whose output has more than one non-unit dimension or whose rank does not match the region permutation, along with shared boundary views whose replacements would be ambiguous. Reductions: `amax` and `amin` join `mean.dim` and `sum.dim_IntList` in the permutable op set, and the dim-remapping helper (renamed `update_reduction_dim`) now accepts a scalar `dim` in addition to a list. The transform is shared rather than backend-specific, so the widened region coverage applies to every backend that runs it. Differential Revision: D116686835
3d61031 to
ea6cf02
Compare
rascani
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
Summary: Widen the regions `RemovePermutesAroundElementwiseOps` can collapse by handling two view patterns that previously terminated a region, and extend the permutable set to the `amax`/`amin` reductions. Singleton boundary views: when a view that only inserts unit dimensions sits between a region's incoming and outgoing layout transforms, compose the pair across it and rewrite the view's target shape, so the boundary is removed instead of ending the region. Reject the composition unless the view has a single user and the outgoing permutation restores the incoming axis labels to identity order. Broadcast sink views: replace the conservative consumer walk with an exact shape remap. A sink reshape carrying at most one non-unit dimension has layout-invariant element order, so remap its target shape into the layout preceding the region, letting its broadcast axes line up once the boundary transforms are dropped. Reject sinks whose output has more than one non-unit dimension or whose rank does not match the region permutation, along with shared boundary views whose replacements would be ambiguous. Reductions: `amax` and `amin` join `mean.dim` and `sum.dim_IntList` in the permutable op set, and the dim-remapping helper (renamed `update_reduction_dim`) now accepts a scalar `dim` in addition to a list. The transform is shared rather than backend-specific, so the widened region coverage applies to every backend that runs it. Reviewed By: rascani Differential Revision: D116686835
ea6cf02 to
43544a2
Compare
|
cc @zingo @freddan80 just a test update on Arm side, so should be pretty safe |
Two things, one enabling the other. **`ciflow/trunk/*` on `pull.yml` is a mistake.** It arrived in #18172, which moved the ARM Cortex-M size test from `trunk.yml` to `pull.yml` and carried trunk's tag trigger across with the job. `ciflow/trunk` should run `trunk.yml`; `pull.yml` already runs on every pull request via `pull_request`, so those tag runs were duplicates — on #22549 the tag run had 120 jobs against the pull request run's 121. `trunk.yml` keeps the trigger. **With no tag push reaching this workflow, the concurrency key can go back to pytorch's.** #21622 added `github.ref_type == 'branch' && github.sha` to stop ciflow tag re-pushes flooding the fleet, but that term is truthy on `pull_request` too, where `github.sha` is the merge commit and changes with every push — so pushes stopped cancelling superseded runs. Before #21622: eight consecutive runs on one branch, seven cancelled. After: three overlapping full runs on `bump-torch-pin-2.14`, none cancelled. The key now matches pytorch's `pull.yml` exactly, `github.run_id` included so two manual dispatches don't cancel each other. Authored with Claude Code.
Summary:
Widen the regions
RemovePermutesAroundElementwiseOpscan collapse by handling two view patterns that previously terminated a region, and extend the permutable set to theamax/aminreductions.Singleton boundary views: when a view that only inserts unit dimensions sits between a region's incoming and outgoing layout transforms, compose the pair across it and rewrite the view's target shape, so the boundary is removed instead of ending the region. Reject the composition unless the view has a single user and the outgoing permutation restores the incoming axis labels to identity order.
Broadcast sink views: replace the conservative consumer walk with an exact shape remap. A sink reshape carrying at most one non-unit dimension has layout-invariant element order, so remap its target shape into the layout preceding the region, letting its broadcast axes line up once the boundary transforms are dropped. Reject sinks whose output has more than one non-unit dimension or whose rank does not match the region permutation, along with shared boundary views whose replacements would be ambiguous.
Reductions:
amaxandaminjoinmean.dimandsum.dim_IntListin the permutable op set, and the dim-remapping helper (renamedupdate_reduction_dim) now accepts a scalardimin addition to a list.The transform is shared rather than backend-specific, so the widened region coverage applies to every backend that runs it.
Reviewed By: rascani
Differential Revision: D116686835