Skip to content

Conversation

@GregoryComer
Copy link
Member

@GregoryComer GregoryComer commented Nov 13, 2025

Summary

Add a direct memcpy fast path for the portable _clone_dim_order op, as it can be a performance bottleneck. I'd like to more aggressively optimize these out of the graph, but this fast path should reduce the perf impact significantly.

Test plan

Existing correctness tests for the _clone_dim_order implementation should cover it.

For performance, I did a quick test with a default dim order (1, 128, 256, 256) element tensor on an x86 server. This is mainly intended as a quick smoke test and not a proper benchmark. I included numbers for both optimized and debug builds. Optimized matters more, but super long debug runs can be painful for development.

[Optimized Build]
Before: 27.9 ms
After: 6.4 ms

[Debug Build]
Before: 5947.01 ms
After: 7.2 ms

@pytorch-bot
Copy link

pytorch-bot bot commented Nov 13, 2025

🔗 Helpful Links

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

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

❌ 1 New Failure

As of commit 421c6dc with merge base e774b77 (image):

NEW FAILURE - The following job has failed:

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

@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 Nov 13, 2025
@github-actions
Copy link

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.

@GregoryComer GregoryComer force-pushed the clone-dim-order-fast-path branch from 3f1cb30 to 929d52b Compare November 13, 2025 19:53
@meta-codesync
Copy link
Contributor

meta-codesync bot commented Nov 13, 2025

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

@GregoryComer GregoryComer force-pushed the clone-dim-order-fast-path branch from 929d52b to 421c6dc Compare November 13, 2025 20:09
@GregoryComer GregoryComer marked this pull request as ready for review November 13, 2025 21:35
@GregoryComer
Copy link
Member Author

Note that the moshi failure is pre-existing.

Copy link
Contributor

@Gasoonjia Gasoonjia left a comment

Choose a reason for hiding this comment

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

LGTM!

@GregoryComer GregoryComer merged commit 0704ae3 into pytorch:main Nov 14, 2025
231 of 234 checks passed
jirioc pushed a commit to nxp-upstream/executorch that referenced this pull request Dec 19, 2025
### Summary
Add a direct memcpy fast path for the portable _clone_dim_order op, as
it can be a performance bottleneck. I'd like to more aggressively
optimize these out of the graph, but this fast path should reduce the
perf impact significantly.

### Test plan
Existing correctness tests for the _clone_dim_order implementation
should cover it.

For performance, I did a quick test with a default dim order (1, 128,
256, 256) element tensor on an x86 server. This is mainly intended as a
quick smoke test and not a proper benchmark. I included numbers for both
optimized and debug builds. Optimized matters more, but super long debug
runs can be painful for development.

[Optimized Build]
Before: 27.9 ms
After: 6.4 ms

[Debug Build]
Before: 5947.01 ms
After: 7.2 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants