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
To fix inconsistency of digamma with SciPy #56689
Conversation
💊 CI failures summary and remediationsAs of commit 30164ee (more details on the Dr. CI page):
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 to the (internal) Dr. CI Users group. |
707caea
to
df5889c
Compare
6023a2e
to
7c39797
Compare
The ROCm build failure is real:
Maybe |
3a33b20
to
aac1592
Compare
hi @jeffdaily, we are trying to use the 'modf' function, to compute the digamma function more accurately. We have tried both ::modf and std::modf in the cuda implementation : aten/src/ATen/native/cuda/Math.cuh in this PR but unfortunatly ROCm seem doesn't support neither of these cases. Is there an alternative here we can use ? |
The device functions I'm finding are the ones that follow the C++11 naming convention, rather than overloading
Might that be the reason for the |
ed0dedf
to
d76ad65
Compare
6f1fef5
to
f39ed5d
Compare
aten/src/ATen/native/Math.h
Outdated
// in order to multiply by pi. Tangent function has period pi (irrational number), | ||
// which is slighly different than numerically estimated pi provided here. When x | ||
// is big enough multiplying it with estimated pi would lead to much bigger difference. | ||
// This difference can lead to bir errors in extreme values. |
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.
"fractiontional" -> "fractional"
"bir errors" -> "big errors"
But this comment can also be simplified a little:
Extracts the fractional part of x as r, since tan(pi * r) is more numerically accurate than tan(pi * x). While these operations are mathematically equivalent since both x and r are in radians and tan() has a periodicity of pi, in practice the computation of pi * x is a source of error (when |x| > 1).
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 indeed very nice choice of explanation what happens in the following code. Thanks for the suggestion.
test/test_unary_ufuncs.py
Outdated
@@ -568,7 +568,7 @@ def test_digamma(self, device, dtype): | |||
# TODO: Add value `-1931.99999994`, to the tensor below when |
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.
Since this is the issue this PR is fixing, this note should be removed, too
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 function and test update look correct now, there are just a couple tweaks needed for the comments
a941944
to
fb4ca34
Compare
fb4ca34
to
30164ee
Compare
@iramazanli has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Codecov Report
@@ Coverage Diff @@
## master #56689 +/- ##
==========================================
- Coverage 77.20% 77.20% -0.01%
==========================================
Files 1948 1948
Lines 193573 193575 +2
==========================================
- Hits 149455 149452 -3
- Misses 44118 44123 +5 |
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.
Cool; nice to have this fixed!
@iramazanli merged this pull request in 6e826ca. |
Summary: Fixes {pytorch#49015} Pull Request resolved: pytorch#56689 Reviewed By: mruberry Differential Revision: D28014563 Pulled By: iramazanli fbshipit-source-id: 4d311e6a32737e44ebfabfc1a4b9414b0de7b46e
Fixes {#49015}