-
Notifications
You must be signed in to change notification settings - Fork 25.7k
[MPS] Allow nan mean reduction in nll_loss
#135434
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/135434
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit 2eac2f0 with merge base 042f2f7 ( FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
Would appreciate it if someone could add the |
|
Please seek CI approval before scheduling CIFlow labels |
|
@pytorchbot label "ciflow/mps" |
554b3e7 to
8accd08
Compare
|
Interesting. Not sure why, but I'll disable these again for now. |
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.
Hmm, is this a regression from #94226 which attempted to solve the same problem a while back and even added regression tests for it..
| mpsGraphReducedTensor = divisionNoNaN(mpsGraph, mpsGraphReducedTensor, mpsGraphBatchSizeTensor); | ||
| mpsGraphReducedTensor = [mpsGraph divisionWithPrimaryTensor:mpsGraphReducedTensor | ||
| secondaryTensor:mpsGraphBatchSizeTensor | ||
| name:@"divisionTensor"]; |
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.
So, why this is safe/needed? Are you saying that NaN in reduced tensors should propagate thru?
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.
This is partially what this PR is fixing. It is needed in the case where weight elems are zero. Without it
Line 11599 in 39a6179
| self.assertEqual(F.nll_loss(input, target, weight, reduction="mean").item(), float("nan")) |
test/test_nn.py
Outdated
| from torch.testing._internal.common_device_type import dtypesIfMPS, instantiate_device_type_tests, dtypes, \ | ||
| dtypesIfCUDA, precisionOverride, skipCUDAIfCudnnVersionLessThan, onlyCUDA, onlyCPU, \ | ||
| skipCUDAIfRocm, skipCUDAIf, skipCUDAIfNotRocm, \ | ||
| skipCUDAIfRocm, skipCUDAIf, skipCUDAIfNotRocm, skipMPSVersionIfLessThan, \ |
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.
|
@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 |
This PR allows results from `nn_loss` to be `nan`, which is the same behavior as with CUDA and CPU pytorch#64572 (comment). Fixes pytorch#134431 Ref pytorch#64572 pytorch#119108 Pull Request resolved: pytorch#135434 Approved by: https://github.com/malfet
This PR allows results from
nn_lossto benan, which is the same behavior as with CUDA and CPU #64572 (comment).Fixes #134431
Ref #64572 #119108