-
Notifications
You must be signed in to change notification settings - Fork 50
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
docs: clarify that sqrt
must be correctly rounded in accordance with IEEE 754
#882
Conversation
Given #826 (comment) says that the default for single-precision |
The default for single-precision divide in CUDA isn't to round with this precision either. |
I want to comment that
|
The default is to do correct rounding, as @hpkfft noted. However, it involves to not set array-api/src/array_api_stubs/_draft/elementwise_functions.py Lines 1478 to 1481 in 532db5b
Therefore, I do not think the "correctly rounded" requirement is achievable. Certainly it is not CuPy's default. Ref: https://docs.nvidia.com/cuda/floating-point/index.html#compiler-flags |
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.
(see above)
Denormal result support (as opposed to flush to zero ( |
Oh, I think the note you referenced is not in the spec itself? But, I would suggest that your observation ought to be considered a separate bug/PR and not block this PR. |
Hi @hpkfft @kgryte, sorry for my late reply. I reached out to our math team (at NVIDIA) asking for clarification, and I believe what @hpkfft stated above is generally correct. Denormals can be flushed while still keeping the rounding behavior correct, at least for |
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.
Looks great! Thank you.
Thanks for the review @hpkfft! As the changes implement the suggestions discussed above, I'll go ahead and merge. Thanks all! |
Thanks to you both 🙏 |
This PR:
sqrt
should follow IEEE 754 and always return correctly rounded result. This was implied (i.e., conforming implementations should be IEEE 754 compliant), but never made explicit.