Skip to content
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

Update of #36 and #35 #93

Merged
merged 20 commits into from
Sep 20, 2023
Merged

Update of #36 and #35 #93

merged 20 commits into from
Sep 20, 2023

Conversation

devmotion
Copy link
Member

@devmotion devmotion commented Jul 25, 2023

This PR is an update of #36, without merge conflicts and with updated primitives of Tracker and CRC.

A concrete example of why #36 and this PR are useful is #57: This issue is fixed if the primal is taken directly from rrule instead of manually re-computing the primal.

Fixes #57.

cc @sethaxen

Edit: I also updated and merged #35 in this PR to fix #93 (comment).

Fixes #34.

Copy link
Member

@oxinabox oxinabox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this is much better

AD.@primitive function value_and_pullback_function(ba::AD.ReverseRuleConfigBackend, f, xs...)
value, back = ChainRulesCore.rrule_via_ad(AD.ruleconfig(ba), f, xs...)
function value_and_pullback(vs)
pb_value = if vs === nothing
Copy link
Member Author

@devmotion devmotion Jul 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to handle nothing due to the way jacobian is implemented for @primitive function value_and_pullback_function (this PR) and @primitive function pullback_function (on the master branch):

value, _ = value_and_pbf(nothing)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the master branch, the default fallback for value_and_pullback_function handles nothing inputs, hence the design choice becomes apparent only in this PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why the jacobian is implemented in this way. In principle, calling pullback repeatedly should be sufficient and the value should not be needed.

Copy link
Member Author

@devmotion devmotion Aug 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be solved easily with #35 I assume since then the value could be obtained before constructing the co-tangents.

@codecov
Copy link

codecov bot commented Jul 31, 2023

Codecov Report

Patch coverage: 86.95% and project coverage change: -1.01% ⚠️

Comparison is base (00181f8) 85.12% compared to head (fe86f18) 84.12%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #93      +/-   ##
==========================================
- Coverage   85.12%   84.12%   -1.01%     
==========================================
  Files           8        8              
  Lines         464      466       +2     
==========================================
- Hits          395      392       -3     
- Misses         69       74       +5     
Files Changed Coverage Δ
src/AbstractDifferentiation.jl 78.46% <72.72%> (-2.05%) ⬇️
ext/AbstractDifferentiationChainRulesCoreExt.jl 100.00% <100.00%> (ø)
ext/AbstractDifferentiationFiniteDifferencesExt.jl 100.00% <100.00%> (ø)
ext/AbstractDifferentiationTrackerExt.jl 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@devmotion
Copy link
Member Author

I solved #93 (comment) by merging and updating #35. With this change, nothing is not "abused" as co-tangent anymore in AbstractDifferentiation, the code could be simplified quite a bit, and implementations of value_and_pullback_function do not have to handle nothing anymore.

@devmotion devmotion changed the title Update of #36 Update of #36 and #35 Aug 2, 2023
@gdalle
Copy link
Member

gdalle commented Aug 5, 2023

@devmotion would it make sense to integrate #100 into the current PR?
There I tried to handle the tuple and the single-input cases correctly (to resolve #99), but I'm not confident enough with the package to decide whether I did it right. Also it needs testing but the AbstractDifferentiation.jl test base is still scary to me ^^

@devmotion
Copy link
Member Author

I guess it could but I'm hesitant right now because #100 still seems to be quite preliminary and #100 is supposed to be a bugfix that could be released in a non-breaking release whereas this PR is clearly breaking.

@gdalle
Copy link
Member

gdalle commented Aug 6, 2023

Then would you mind maybe reviewing it since it's rather short, and advising me on how to add tests? Since you've already worked on that part of the code, your opinion would be very valuable!

@devmotion
Copy link
Member Author

Bump 🙂

#95 could be included in a breaking release as well. And of course, I'd be fine with merging some of the other non-breaking PRs first if they are reviewed and approved 🙂

src/AbstractDifferentiation.jl Outdated Show resolved Hide resolved
src/AbstractDifferentiation.jl Show resolved Hide resolved
@gdalle
Copy link
Member

gdalle commented Sep 19, 2023

@oxinabox ok for merging this breaking PR?

@oxinabox
Copy link
Member

Please do

@gdalle gdalle merged commit 3c18e86 into master Sep 20, 2023
5 of 6 checks passed
@devmotion
Copy link
Member Author

I thought part of ColPrac is that developers merge their own PRs after approval? 🤔😛

@devmotion devmotion deleted the dw/value_and_pb_function branch September 20, 2023 07:01
@gdalle
Copy link
Member

gdalle commented Sep 20, 2023

I was planning to read it this morning! And actually your PRs had been waiting for so long I thought you didn't have merge rights, and I didn't even check 😅 sorry about that

@gdalle
Copy link
Member

gdalle commented Sep 20, 2023

Speaking of, does the repo have the right branch protections to help enforce ColPrac?

@devmotion
Copy link
Member Author

Well, they weren't approved (and I also wanted to wait for Mohammeds approval specifically). I merged and released #97 as soon as it was approved yesterday 🙂

@gdalle
Copy link
Member

gdalle commented Sep 20, 2023

I apologize for the confusion. I'm now up to speed on ColPrac ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants