Skip to content

Reland "Arm backend: Add transpose propagation pass" (#20748) - #20748

Merged
meta-codesync[bot] merged 1 commit into
mainfrom
revert-20742-revert-20625-change-1265162
Jul 13, 2026
Merged

Reland "Arm backend: Add transpose propagation pass" (#20748)#20748
meta-codesync[bot] merged 1 commit into
mainfrom
revert-20742-revert-20625-change-1265162

Conversation

@rascani

@rascani rascani commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary:
Reverts #20742 and relands #20625.

Differential Revision: D110793024

Pulled By: rascani

@pytorch-bot

pytorch-bot Bot commented Jul 6, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20748

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

✅ You can merge normally! (1 Unrelated Failure)

As of commit 4aec2e4 with merge base a588b26 (image):

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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

@pytorch-bot pytorch-bot Bot added the ci-no-td label Jul 6, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 6, 2026
@github-actions github-actions Bot added ciflow/trunk module: arm Issues related to arm backend labels Jul 6, 2026
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@meta-codesync

meta-codesync Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

@rascani has imported this pull request. If you are a Meta employee, you can view this in D110793024.

@meta-codesync meta-codesync Bot changed the title Reland "Arm backend: Add transpose propagation pass" Reland "Arm backend: Add transpose propagation pass" (#20748) Jul 9, 2026
meta-codesync Bot pushed a commit that referenced this pull request Jul 9, 2026
Summary:
Reverts #20742 and relands #20625.


Differential Revision: D110793024

Pulled By: rascani
@meta-codesync
meta-codesync Bot force-pushed the revert-20742-revert-20625-change-1265162 branch from a0680ed to 8ac44af Compare July 9, 2026 18:35
@meta-codesync

meta-codesync Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

@rascani has exported this pull request. If you are a Meta employee, you can view the originating Diff in D110793024.

meta-codesync Bot pushed a commit that referenced this pull request Jul 9, 2026
Summary:
Reverts #20742 and relands #20625.


Differential Revision: D110793024

Pulled By: rascani
@meta-codesync
meta-codesync Bot force-pushed the revert-20742-revert-20625-change-1265162 branch from 8ac44af to 6557ec2 Compare July 9, 2026 19:04
meta-codesync Bot pushed a commit that referenced this pull request Jul 9, 2026
Summary:
Reverts #20742 and relands #20625.


Differential Revision: D110793024

Pulled By: rascani
@meta-codesync
meta-codesync Bot force-pushed the revert-20742-revert-20625-change-1265162 branch from 6557ec2 to 65c1f05 Compare July 9, 2026 19:50
Summary:
Reverts #20742 and relands #20625.


Differential Revision: D110793024

Pulled By: rascani
@meta-codesync
meta-codesync Bot force-pushed the revert-20742-revert-20625-change-1265162 branch from 65c1f05 to 4aec2e4 Compare July 9, 2026 20:47
@rascani
rascani marked this pull request as ready for review July 9, 2026 21:10
@rascani
rascani requested a review from digantdesai as a code owner July 9, 2026 21:10
@rascani
rascani requested a review from AdrianLundell July 9, 2026 21:10
Comment on lines +342 to +370
def _would_strand_layout_op_on_wider_elements(
self, next_node: torch.fx.Node
) -> bool:
"""Whether crossing next_node leaves the layout op on wider elements.

Crossing next_node upward moves the layout op onto next_node's input. When
next_node narrows the dtype (its input has wider elements than its output,
e.g. an int32 to int8 rescale), the layout op then has more bytes to move, so
block the crossing and keep it on the narrow side. The sole exception is a
placeholder input consumed only by next_node: moving the layout op onto such
a graph input folds it into the input's dim_order at no runtime cost. A
placeholder with other consumers cannot be relaid out for free, so the
crossing is still blocked. Valid for upward propagation only, where
next_node's single input is where the layout op would land.

"""
input_nodes = next_node.all_input_nodes
if len(input_nodes) != 1:
return False
node_val = next_node.meta.get("val")
producer = input_nodes[0]
producer_val = producer.meta.get("val")
if not isinstance(node_val, torch.Tensor) or not isinstance(
producer_val, torch.Tensor
):
return False
if producer_val.element_size() <= node_val.element_size():
return False
return producer.op != "placeholder" or len(producer.users) != 1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AdrianLundell - This is the main significant change from the original (plus its usage at line 412). We had some cases where this pass would insert a transpose between an Add -> Rescale, which wound up blocking a fusion and the resulting graph hit a regor pass bug. I'll fix that bug separately, but figured it would still be good to block the propagation here to minimize the data movement.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks!

next_nodes = list(self._get_next_nodes(frontier))

if len(next_nodes) == 0:
assert frontier.op in (

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed a nascent bug here. It was previously assert node.op, which doesn't match the comment or the intention. I don't think it caused any problems, but wanted to call it out.

@digantdesai digantdesai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

@meta-codesync
meta-codesync Bot merged commit 18e2ff8 into main Jul 13, 2026
502 of 504 checks passed
@meta-codesync
meta-codesync Bot deleted the revert-20742-revert-20625-change-1265162 branch July 13, 2026 20:08
meta-codesync Bot pushed a commit that referenced this pull request Jul 17, 2026
Differential Revision: D112005256

Pull Request resolved: #20947
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-no-td ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported module: arm Issues related to arm backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants