Improve efficiency of _python_dispatch.return_and_correct_aliasing#161240
Closed
swolchok wants to merge 4 commits intogh/swolchok/791/basefrom
Closed
Improve efficiency of _python_dispatch.return_and_correct_aliasing#161240swolchok wants to merge 4 commits intogh/swolchok/791/basefrom
swolchok wants to merge 4 commits intogh/swolchok/791/basefrom
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/161240
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 75fa587 with merge base a85711d ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Aug 22, 2025
…aliasing" get_write_alias() call count reduction explained briefly in code comment. We don't need to check write_aliases against None in the final outs_to_return calculation because we just did that check. [ghstack-poisoned]
This was referenced Aug 22, 2025
…aliasing" get_write_alias() call count reduction explained briefly in code comment. We don't need to check write_aliases against None in the final outs_to_return calculation because we just did that check. [ghstack-poisoned]
This was referenced Aug 22, 2025
wconstab
reviewed
Aug 22, 2025
| if not all(x is not None for x in schema_info_outs_write_aliases): | ||
| raise RuntimeError("Unsupported schema: " + str(func._schema)) | ||
|
|
||
| if len(func._schema.returns) == 1: |
Contributor
There was a problem hiding this comment.
why do you change this line? it may indeed be the same length as schema_info_outs_write_aliases but this doesn't seem clearly perf motivated and i'm not actually sure they are the same
Contributor
There was a problem hiding this comment.
this seems ok upon closer look
Contributor
Author
There was a problem hiding this comment.
func._schema.returns is a pybind; accessing it will cost more than the alternative
wconstab
approved these changes
Aug 22, 2025
This was referenced Aug 23, 2025
Collaborator
|
Starting merge as part of PR stack under #161285 |
pytorchmergebot
pushed a commit
that referenced
this pull request
Aug 25, 2025
…ly_alias_match (#161284) Containers are truthy iff they're non-empty. Pull Request resolved: #161284 Approved by: https://github.com/Skylion007, https://github.com/wconstab ghstack dependencies: #161231, #161234, #161235, #161240
markc-614
pushed a commit
to markc-614/pytorch
that referenced
this pull request
Sep 17, 2025
…ytorch#161240) get_write_alias() call count reduction explained briefly in code comment. We don't need to check write_aliases against None in the final outs_to_return calculation because we just did that check. Pull Request resolved: pytorch#161240 Approved by: https://github.com/wconstab ghstack dependencies: pytorch#161231, pytorch#161234, pytorch#161235
markc-614
pushed a commit
to markc-614/pytorch
that referenced
this pull request
Sep 17, 2025
…ly_alias_match (pytorch#161284) Containers are truthy iff they're non-empty. Pull Request resolved: pytorch#161284 Approved by: https://github.com/Skylion007, https://github.com/wconstab ghstack dependencies: pytorch#161231, pytorch#161234, pytorch#161235, pytorch#161240
markc-614
pushed a commit
to markc-614/pytorch
that referenced
this pull request
Sep 17, 2025
…#161285) Drives down the overhead of return_and_correct_storage_aliasing slightly. Hopefully you'll agree it doesn't compromise readability. Pull Request resolved: pytorch#161285 Approved by: https://github.com/wconstab ghstack dependencies: pytorch#161231, pytorch#161234, pytorch#161235, pytorch#161240, pytorch#161284
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.
Stack from ghstack (oldest at bottom):
is, not ==, to check exact type matches in _python_dispatch #161304__hash__and__eq__#161234get_write_alias() call count reduction explained briefly in code comment.
We don't need to check write_aliases against None in the final outs_to_return calculation because we just did that check.