-
-
Notifications
You must be signed in to change notification settings - Fork 190
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
Remove v_vari #2422
Remove v_vari #2422
Conversation
…4.1 (tags/RELEASE_600/final)
I kinda agree on NaN checks. |
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.
Good if tests pass.
If you want to remove all the NaN logic, happy to scroll back through and check.
The only place that looked weird to me was how we handle maxes/mins with NaNs, but apparently that is undefined behavior (https://stackoverflow.com/questions/55153210/do-stdmin0-0-1-0-and-stdmax0-0-1-0-yield-undefined-behavior) so I guess it probably doesn't matter so much what we do.
return {new precomp_v_vari(NOT_A_NUMBER, a.vi_, NOT_A_NUMBER)}; | ||
if (unlikely(is_nan(a.val()))) { | ||
return make_callback_var(a.val(), | ||
[a](auto& vi) mutable { a.adj() = NOT_A_NUMBER; }); |
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.
Oh yeah definitely ditch this nan check
return; | ||
} | ||
if (is_inf(bvi_->val_)) { | ||
bvi_->adj_ += NOT_A_NUMBER; | ||
bvi_->adj_ = NOT_A_NUMBER; |
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.
[optional] It looks like the conversion on gamma_p never got finished.
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.
I just did a ctrl+f for += NOT_A_NUMBER
and that's why these changed. I'm going to do the vv ones in a future PR
…4.1 (tags/RELEASE_600/final)
…4.1 (tags/RELEASE_600/final)
…4.1 (tags/RELEASE_600/final)
…4.1 (tags/RELEASE_600/final)
stan/math/opencl/rev/logit.hpp
Outdated
A.adj() += elt_divide(res.adj(), A.val() * LOG_TEN); | ||
A.adj() += elt_multiply(res.adj(), | ||
elt_divide(1.0, A.val() - square(A.val()))); |
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.
@t4c1 fyi I think this was wrong before? I wrote it to match up to the rev version
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.
It seems so. How did the tests pass?
Anyway you can simplify this into:
A.adj() += elt_divide(res.adj(), A.val() - square(A.val()));
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.
I reverted this change and the tests failed for me locally. It looks like the right tests are running in CI. I don't know. This seems like a canary worth investigating, but if nobody can reproduce it then nobody can reproduce it :/.
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.
Oh also I switched to the simplified A.adj() += elt_divide(res.adj(), A.val() - square(A.val()));
Ayy @rok-cesnovar @serban-nicusor-toptal it looks like something is going on with the opencl device across a few PRs |
Yeah, see #2442 |
Cool thanks! |
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
Besides @t4c1 's comment above this is ready for review! |
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.
I made a couple changes and left comments. I'll leave to @t4c1 to approve and merge. I don't understand how the non-working logit got in. The tests seem to work for me now.
@@ -87,7 +87,7 @@ TEST(opencl_context, switch_devices_errors) { | |||
EXPECT_THROW(stan::math::opencl_context.select_device(0, 99999), | |||
std::system_error); | |||
} | |||
|
|||
/* |
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 test should probably be turned back on
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.
Oooh yes good catch
stan/math/opencl/rev/logit.hpp
Outdated
A.adj() += elt_divide(res.adj(), A.val() * LOG_TEN); | ||
A.adj() += elt_multiply(res.adj(), | ||
elt_divide(1.0, A.val() - square(A.val()))); |
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.
I reverted this change and the tests failed for me locally. It looks like the right tests are running in CI. I don't know. This seems like a canary worth investigating, but if nobody can reproduce it then nobody can reproduce it :/.
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
This looks good, just uncomment the test Ben mentioned. |
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.
Grand theft github points
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
Summary
Just a small PR that removes
v_vari
from therev
folder and replaces it withmake_callback_var()
Tests
Cleanup so no new tests
Side Effects
No side effects but I was wondering about the callbacks that perform NaN checks like
Have we decided to not do NaN checks on the reverse pass? It feels like we are very inconsistent on this. Personally I'm pro removing them because of the inconsistency.
Release notes
Checklist
Math issue #(issue number)
Copyright holder: Steve Bronder
The copyright holder is typically you or your assignee, such as a university or company. By submitting this pull request, the copyright holder is agreeing to the license the submitted work under the following licenses:
- Code: BSD 3-clause (https://opensource.org/licenses/BSD-3-Clause)
- Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
the basic tests are passing
./runTests.py test/unit
)make test-headers
)make test-math-dependencies
)make doxygen
)make cpplint
)the code is written in idiomatic C++ and changes are documented in the doxygen
the new changes are tested