Repository navigation
Remove permutes around expand_copy; reject symbolic scalar inputs (#24742) - #24742
Merged
Merged
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/24742
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit c783436 with merge base 6605290 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Contributor
|
@pssrawat has exported this pull request. If you are a Meta employee, you can view the originating Diff in D130138174. |
pssrawat
requested review from
mcremon-meta and
rascani
and removed request for
mcremon-meta
November 6, 2026 18:11
pssrawat
added a commit
to pssrawat/executorch
that referenced
this pull request
Nov 6, 2026
…torch#24742) Summary: `RemovePermutesAroundElementwiseOps` stopped at `aten.expand_copy.default`, so a layout region containing a broadcast was cut in two and kept a permute pair on each side. A squeeze-and-excitation gate, a per-channel scale broadcast over the time axis and multiplied back in, puts an expand in the middle of exactly such a region. `expand_copy` is now in the default permutable set, and `update_expand_copy` un-permutes its size argument the same way the other `update_*` methods remap their dims. Before reordering, it replaces each `-1` with the concrete output size, keeping `-1` only where that dim is symbolic: in a rank-growing expand, reordering could otherwise move a `-1` onto a dim the expand adds, where `-1` is invalid. With that, rank-growing expands of constants are remapped correctly and need no filter; non-constant lower-rank inputs are still rejected by the region's rank check. The pass also crashed with `AttributeError: 'SymInt' object has no attribute 'numel'` when a region op took a symbolic argument, such as `slice_copy` with an end of `y.shape[0]`, `constant_pad_nd` with a symbolic pad amount, or `expand_copy` with a symbolic size. The upstream walk reaches the `sym_size` node and calls `.numel()` on its `SymInt` value. Such inputs now reject the region. They cannot be skipped like numel-1 tensors: a `sym_size` can read a dim of a region tensor, which removing the permutes would change. Authored with an AI coding assistant (Claude). Differential Revision: D130138174
pssrawat
force-pushed
the
export-D130138174
branch
from
November 6, 2026 19:02
053efe6 to
6c37d15
Compare
pssrawat
added a commit
to pssrawat/executorch
that referenced
this pull request
Nov 6, 2026
…torch#24742) Summary: `RemovePermutesAroundElementwiseOps` stopped at `aten.expand_copy.default`, so a layout region containing a broadcast was cut in two and kept a permute pair on each side. A squeeze-and-excitation gate, a per-channel scale broadcast over the time axis and multiplied back in, puts an expand in the middle of exactly such a region. `expand_copy` is now in the default permutable set, and `update_expand_copy` un-permutes its size argument the same way the other `update_*` methods remap their dims. Before reordering, it replaces each `-1` with the concrete output size, keeping `-1` only where that dim is symbolic: in a rank-growing expand, reordering could otherwise move a `-1` onto a dim the expand adds, where `-1` is invalid. With that, rank-growing expands of constants are remapped correctly and need no filter; non-constant lower-rank inputs are still rejected by the region's rank check. The pass also crashed with `AttributeError: 'SymInt' object has no attribute 'numel'` when a region op took a symbolic argument, such as `slice_copy` with an end of `y.shape[0]`, `constant_pad_nd` with a symbolic pad amount, or `expand_copy` with a symbolic size. The upstream walk reaches the `sym_size` node and calls `.numel()` on its `SymInt` value. Such inputs now reject the region. They cannot be skipped like numel-1 tensors: a `sym_size` can read a dim of a region tensor, which removing the permutes would change. Authored with an AI coding assistant (Claude). Differential Revision: D130138174
pssrawat
force-pushed
the
export-D130138174
branch
from
November 6, 2026 19:33
6c37d15 to
1428baa
Compare
mcremon-meta
approved these changes
Nov 9, 2026
…torch#24742) Summary: `RemovePermutesAroundElementwiseOps` stopped at `aten.expand_copy.default`, so a layout region containing a broadcast was cut in two and kept a permute pair on each side. A squeeze-and-excitation gate, a per-channel scale broadcast over the time axis and multiplied back in, puts an expand in the middle of exactly such a region. `expand_copy` is now in the default permutable set, and `update_expand_copy` un-permutes its size argument the same way the other `update_*` methods remap their dims. Before reordering, it replaces each `-1` with the concrete output size, keeping `-1` only where that dim is symbolic: in a rank-growing expand, reordering could otherwise move a `-1` onto a dim the expand adds, where `-1` is invalid. With that, rank-growing expands of constants are remapped correctly and need no filter; non-constant lower-rank inputs are still rejected by the region's rank check. The pass also crashed with `AttributeError: 'SymInt' object has no attribute 'numel'` when a region op took a symbolic argument, such as `slice_copy` with an end of `y.shape[0]`, `constant_pad_nd` with a symbolic pad amount, or `expand_copy` with a symbolic size. The upstream walk reaches the `sym_size` node and calls `.numel()` on its `SymInt` value. Such inputs now reject the region. They cannot be skipped like numel-1 tensors: a `sym_size` can read a dim of a region tensor, which removing the permutes would change. Authored with an AI coding assistant (Claude). Reviewed By: mcremon-meta Differential Revision: D130138174
pssrawat
force-pushed
the
export-D130138174
branch
from
November 9, 2026 21:45
1428baa to
c783436
Compare
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.
Summary:
RemovePermutesAroundElementwiseOpsstopped ataten.expand_copy.default, so a layout region containing a broadcast was cut in two and kept a permute pair on each side. A squeeze-and-excitation gate, a per-channel scale broadcast over the time axis and multiplied back in, puts an expand in the middle of exactly such a region.expand_copyis now in the default permutable set, andupdate_expand_copyun-permutes its size argument the same way the otherupdate_*methods remap their dims. Before reordering, it replaces each-1with the concrete output size, keeping-1only where that dim is symbolic: in a rank-growing expand, reordering could otherwise move a-1onto a dim the expand adds, where-1is invalid. With that, rank-growing expands of constants are remapped correctly and need no filter; non-constant lower-rank inputs are still rejected by the region's rank check.The pass also crashed with
AttributeError: 'SymInt' object has no attribute 'numel'when a region op took a symbolic argument, such asslice_copywith an end ofy.shape[0],constant_pad_ndwith a symbolic pad amount, orexpand_copywith a symbolic size. The upstream walk reaches thesym_sizenode and calls.numel()on itsSymIntvalue. Such inputs now reject the region. They cannot be skipped like numel-1 tensors: asym_sizecan read a dim of a region tensor, which removing the permutes would change.Authored with an AI coding assistant (Claude).
Reviewed By: mcremon-meta
Differential Revision: D130138174