Skip to content

Add refs/decomps for dot/vdot #108194

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

Closed
wants to merge 6 commits into from
Closed

Conversation

lezcano
Copy link
Collaborator

@lezcano lezcano commented Aug 29, 2023

Follow-up on #108127 (comment)

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Aug 29, 2023

🔗 Helpful Links

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

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

✅ No Failures

As of commit 3632437 with merge base b7624fc (image):
💚 Looks good so far! There are no failures yet. 💚

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

yield ErrorInput(SampleInput(make_input(1, 1), args=(make_input(3),)),
error_regex='1D tensors expected')
yield ErrorInput(SampleInput(make_input(9), args=(make_input(3),)),
error_regex='inconsistent tensor size')
if device != "cpu":
ErrorInput(SampleInput(make_input(3), args=(make_input(3, device="cpu"),)),
error_regex='Expected all tensors to be on the same device')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are we changing the tests here? Shouldn't you fix the refs to match the test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We don't check the device in almost any op, so I figured that it's a bit unnecessary. I can roll back.

As to the other, checking for that error disallows using the elementwise wrapper, which is, if anything, a good thing. One of the initial designs of primtorch was that we should add more support for ops if it's easy to do so.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Adding more functionality to the ref seems fine, but removing testing from eager definitely seems bad,

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What do you suggest then? Should I just xfail these tests?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you override the error_inputs_func of the ref info to pass in an is_ref=True option?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fair enough. Done.

"_refs.dot",
torch_opinfo_name="dot",
# .conj() returns a view on complex tensors??
validate_view_consistency=False,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why aren't we getting the view behavior right here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

At a guess, return torch.dot(self, other.conj()).conj() probably needs to come outside of elementwise_type_promotion_wrapper.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not quite. I checked under this branch:

    elif other.is_conj():
        return torch.dot(self, other.conj()).conj()

which is the one that triggers the issue, and torch.dot(self, other.conj()) is not a view, but torch.dot(self, other.conj()).conj() is a view.
On the other hand, if I put the same code in ATen, it says that torch.dot(self, other.conj()).conj() is conj but not a view... I'm submitting a different fix.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nvm, the other fix doesn't work. I'm not quite sure what's going on there.
I'm voting for leaving as is right now as we don't even support complex numbers at the moment in inductor.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay the eager result having is_conj() but not _is_view() is weird but not really our fault here, so I guess thats fine. This comment should be updated to reflect that though; .conj() is expected to return a view so the comment doesn't make much sense.

Follow-up on #108127 (comment)

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 ipiszy ngimel yf225 chenyang78 kadeng muchulee8 aakhundov

[ghstack-poisoned]
lezcano added a commit that referenced this pull request Aug 30, 2023
Follow-up on #108127 (comment)

ghstack-source-id: 399c51e
Pull Request resolved: #108194
Follow-up on #108127 (comment)

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 ipiszy ngimel yf225 chenyang78 kadeng muchulee8 aakhundov

[ghstack-poisoned]
lezcano added a commit that referenced this pull request Aug 30, 2023
Follow-up on #108127 (comment)

ghstack-source-id: 81642a5
Pull Request resolved: #108194
Follow-up on #108127 (comment)

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 ipiszy ngimel yf225 chenyang78 kadeng muchulee8 aakhundov

[ghstack-poisoned]
Follow-up on #108127 (comment)

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 ipiszy ngimel yf225 chenyang78 kadeng muchulee8 aakhundov

[ghstack-poisoned]
lezcano added a commit that referenced this pull request Aug 30, 2023
Follow-up on #108127 (comment)

ghstack-source-id: 849d47b
Pull Request resolved: #108194
@lezcano
Copy link
Collaborator Author

lezcano commented Aug 30, 2023

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Aug 30, 2023
@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: 1 jobs have failed, first few of them are: trunk / macos-12-py3-arm64-mps / test (default, 1, 1)

Details for Dev Infra team Raised by workflow job

Follow-up on #108127 (comment)

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 ipiszy ngimel yf225 chenyang78 kadeng muchulee8 aakhundov

[ghstack-poisoned]
lezcano added a commit that referenced this pull request Aug 31, 2023
Follow-up on #108127 (comment)

ghstack-source-id: 992cf08
Pull Request resolved: #108194
@lezcano lezcano requested a review from kulinseth as a code owner August 31, 2023 12:12
Comment on lines -499 to -504
TORCH_CHECK(
self.device() == other.device(),
"expected all tensors to be on the same device. Found: ",
self.device(),
", ",
other.device());
Copy link
Collaborator Author

@lezcano lezcano Aug 31, 2023

Choose a reason for hiding this comment

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

@peterbell10 removing this as it's unreachable. We currently check this in the dispatcher and throw

Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument tensor in method wrapper_CUDA__dot

@lezcano
Copy link
Collaborator Author

lezcano commented Aug 31, 2023

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

@facebook-github-bot facebook-github-bot deleted the gh/Lezcano/233/head branch October 1, 2023 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants