-
Notifications
You must be signed in to change notification settings - Fork 25.4k
Return unsafe_view instead of view from matmul when folding occurs #134568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/134568
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit d155a11 with merge base 41e6534 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
@jgong5 @EikanWang Hi, can you help on review the PR? |
@zou3519 Hi I have linter patch ready. In the error messages I've also seen note about adding test owner. From what I've seen in similar test it's just '# Owner(s): ["module: unknown"]. I'm also wondering whether it's the right place for this kind of test or you might already have a more fitted suite somewhere else. Could you give any hints on that? |
class TestCustomFunction(TestCase): | ||
def test_autograd_function_with_matmul_folding_at_output(self): | ||
""" | ||
When tensor folding occurs during matmul operation returned tensor is a view. | ||
This can cause issues when matmul is used inside a custom function | ||
and such view is then returned as output. Then it cannot be modified inplace | ||
and causes errors. | ||
It can be especially problematic when after such function inplace allreduce | ||
is performed. This test recreates this behaviour. | ||
Issue is resolved when unsafe_view is returned from matmul instead. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to test/dynamo/test_misc.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code change makes sense to me. Let's move the test to an existing file rather than put it in its own testcase.
@pytorchbot label "topic: not user facing" |
@pytorchbot rebase |
You don't have permissions to rebase this PR since you are a first time contributor. If you think this is a mistake, please contact PyTorch Dev Infra. |
@pytorchbot rebase |
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
When tensor folding occurs during matmul operation returned tensor is a view. This can cause issues when matmul is used inside a custom function and such view is then returned as output. Then it cannot be modified inplace and causes errors. It can be especially problematic when after such function inplace allreduce is performed. Issue is resolved when unsafe_view is returned from matmul instead. This solution aligns matmul decomposition with eager implementation in such a way that a non view tensor is returned.
- Removed return types from forward/backward functions in test_custom_function to be compatible with python 3.8 - Updated graph in test_proxy_tensor test_reflect_r_over_x os that _unsafe_view is added instead of view_4 after mm
Successfully rebased |
d174036
to
6e11997
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lint failing
done |
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
…ytorch#134568) When tensor folding occurs during matmul operation returned tensor is a view. This can cause issues when matmul is used inside a custom function and such view is then returned as output. Then it cannot be modified inplace and causes errors. It can be especially problematic when after such function inplace allreduce is performed. Issue is resolved when unsafe_view is returned from matmul instead. This solution aligns matmul decomposition with eager implementation in such a way that a non view tensor is returned. Test included in this PR reproduces the issue. Pull Request resolved: pytorch#134568 Approved by: https://github.com/zou3519
When tensor folding occurs during matmul operation returned tensor is a view. This can cause issues when matmul is used inside a custom function and such view is then returned as output. Then it cannot be modified inplace and causes errors. It can be especially problematic when after such function inplace allreduce is performed. Issue is resolved when unsafe_view is returned from matmul instead. This solution aligns matmul decomposition with eager implementation in such a way that a non view tensor is returned. Pull request openned to pytorch pytorch#134568 Change-Id: I77484ff6f22d3e290352348b1acbffa267eb063b
When tensor folding occurs during matmul operation returned tensor is a view. This can cause issues when matmul is used inside a custom function and such view is then returned as output. Then it cannot be modified inplace and causes errors. It can be especially problematic when after such function inplace allreduce is performed. Issue is resolved when unsafe_view is returned from matmul instead. This solution aligns matmul decomposition with eager implementation in such a way that a non view tensor is returned. Pull request openned to pytorch pytorch#134568 Change-Id: I77484ff6f22d3e290352348b1acbffa267eb063b
When tensor folding occurs during matmul operation returned tensor is a view. This can cause issues when matmul is used inside a custom function and such view is then returned as output. Then it cannot be modified inplace and causes errors. It can be especially problematic when after such function inplace allreduce is performed. Issue is resolved when unsafe_view is returned from matmul instead. This solution aligns matmul decomposition with eager implementation in such a way that a non view tensor is returned. Pull request openned to pytorch pytorch#134568 Change-Id: I77484ff6f22d3e290352348b1acbffa267eb063b
When tensor folding occurs during matmul operation returned tensor is a view. This can cause issues when matmul is used inside a custom function and such view is then returned as output. Then it cannot be modified inplace and causes errors. It can be especially problematic when after such function inplace allreduce is performed. Issue is resolved when unsafe_view is returned from matmul instead. This solution aligns matmul decomposition with eager implementation in such a way that a non view tensor is returned. Pull request openned to pytorch pytorch#134568 Change-Id: I77484ff6f22d3e290352348b1acbffa267eb063b
When tensor folding occurs during matmul operation returned tensor is a view. This can cause issues when matmul is used inside a custom function and such view is then returned as output. Then it cannot be modified inplace and causes errors.
It can be especially problematic when after such function inplace allreduce is performed.
Issue is resolved when unsafe_view is returned from matmul instead. This solution aligns matmul decomposition with eager implementation in such a way that a non view tensor is returned.
Test included in this PR reproduces the issue.
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @chauhang @amjames @rec