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
Fix incorrect CUDA torch.nn.Embedding
result when max_norm is not None and indices are not sorted
#45248
Fix incorrect CUDA torch.nn.Embedding
result when max_norm is not None and indices are not sorted
#45248
Conversation
💊 CI failures summary and remediationsAs of commit c4edc84 (more details on the Dr. CI page): Commit c4edc84 was recently pushed. Waiting for builds... This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group. This comment has been revised 41 times. |
💊 CI failures summary and remediationsAs of commit 18dbfb8ee4 (more details on the Dr. CI page): ✅ None of the CI failures appear to be your fault 💚
🚧 8 ongoing upstream failures:These were probably caused by upstream breakages that are not fixed yet:
This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group. |
913fff7
to
403fbfd
Compare
7be0437
to
e469c3d
Compare
I think this is ready. The CI failures didn't seem to be my fault, but I'm rerunning them. |
Codecov Report
@@ Coverage Diff @@
## master #45248 +/- ##
==========================================
- Coverage 68.28% 68.27% -0.01%
==========================================
Files 410 410
Lines 53306 53306
==========================================
- Hits 36398 36397 -1
- Misses 16908 16909 +1
Continue to review full report at Codecov.
|
So I'm curious about your thinking here, @kurtamohler,
|
@kurtamohler as the comment here says, thrust::unique does not work on unsorted unputs https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/native/cuda/Embedding.cu#L350-L356, so you should sort inputs before calling thrust on them. It may be extra work (if there are no repeating indices), but otherwise there's no way to guarantee that incorrect results won't be produced. |
e469c3d
to
e1f6b16
Compare
torch.nn.Embedding
torch.nn.Embedding
when max_norm is not None
torch.nn.Embedding
when max_norm is not Nonetorch.nn.Embedding
result when max_norm is not None
torch.nn.Embedding
result when max_norm is not Nonetorch.nn.Embedding
result when max_norm is not None and indices are not sorted
Thanks @ngimel! I've made that change and wrote a test based on the repro from the issue description. |
e1f6b16
to
c4edc84
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.
@ngimel has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Sorting indices before calling
thrust::unique
fixes the issue.Fixes #44792