-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
jet of pow using comp with exp, mul, log #2652
Conversation
Co-authored-by: Jesse Bettencourt <jessebett@cs.toronto.edu> Co-authored-by: David Duvenaud <duvenaud@cs.toronto.edu>
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
jax/experimental/jet.py
Outdated
u_, r_ = primals_in | ||
u_terms, r_terms = series_in | ||
u = [u_] + u_terms | ||
r = [r_] + r_terms | ||
|
||
logu_, logu_terms = _log_taylor((u_, ), (u_terms, )) | ||
|
||
v_, v_terms = _bilinear_taylor_rule(lax.mul_p, (logu_, r_), (logu_terms, r_terms)) | ||
|
||
v_, v_terms = _exp_taylor((v_, ), (v_terms, )) | ||
|
||
return v_, v_terms |
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.
If you're going to define things this way, I'd just call back into jet
:
u_, r_ = primals_in | |
u_terms, r_terms = series_in | |
u = [u_] + u_terms | |
r = [r_] + r_terms | |
logu_, logu_terms = _log_taylor((u_, ), (u_terms, )) | |
v_, v_terms = _bilinear_taylor_rule(lax.mul_p, (logu_, r_), (logu_terms, r_terms)) | |
v_, v_terms = _exp_taylor((v_, ), (v_terms, )) | |
return v_, v_terms | |
return jet(lambda x, y: lax.exp(y * lax.log(x), primals_in, series_in) |
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.
Haha, I feel silly now. We started by trying to derive a giant monolithic formula for pow(x, y), but we already had all the ingredients!
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.
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.
@shoyer yeah! We're still unclear if there is a benefit from writing the expanded rules for primitives that can be composed of other primitives vs just calling jet on that composition like you have here.
I guess the more numerically stable but also more expensive alternate would be to recursively apply the JVP rule? |
@shoyer yeah you can see in the tests the function that looks like recursive calls to jvp: However this is significantly slower. Interesting to see if it's more numerically stable, though, because I'd expect the opposite. Not confident about intuition. |
I think 77b7d9b fixes this. I changed the I modified the tests in c75855b, to include the option to check jets on only finite values (by casting |
Looks good to me! @jacobjinkelly That's kind of you to mark me as a co-author, but I think a one line review suggestion barely qualifies :) @jessebett @duvenaud googlebot still needs your OK on this ( |
@googlebot I consent. |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
@jacobjinkelly could you kindly either remove my "co-author" status from the commit or use by google email instead ( |
Co-authored-by: Stephan Hoyer <shoyer@google.com>
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
@shoyer Ok rebased the relevant commit with your google email! |
@jessebett this still needs your consent |
@googlebot I consent. |
Thanks everyone! |
just to keep track this addresses #2431 |
This implementation is numerically unstable (the test begins to fail when the upper limit is about 35), but it's unclear if there's another way to implement jet of pow easily.
Co-authored-by: Jesse Bettencourt jessebett@cs.toronto.edu (@jessebett)
Co-authored-by: David Duvenaud duvenaud@cs.toronto.edu (@duvenaud)