-
-
Notifications
You must be signed in to change notification settings - Fork 71
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 duplicate callbacks in ForwardDiff and ReverseDiff adjoints #1087
Remove duplicate callbacks in ForwardDiff and ReverseDiff adjoints #1087
Conversation
Needs tests, make the problem from the issue into a test case. |
Also handle ReverseDiffAdjoint() and TrackerAdjoint as mentioned in the issue. |
It errors out when using ReverseDiffAdjoint or TrackerAdjoint, since the callback tries to mutate the parameter array. |
Make some |
Turns out TrackerAdjoint had the same problem. |
test/prob_kwargs.jl
Outdated
|
||
@testset "Callback duplication check" begin | ||
for adjoint_type in [ | ||
ForwardDiffSensitivity(), ReverseDiffAdjoint(), TrackerAdjoint()] |
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.
and loop through some adjoint methods too, all sensealgs is best
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.
Except ZygoteAdjoint
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.
ZygoteAdjoint()
and GaussAdjoint()
error out, besides those I've included all the rest that support callbacks
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.
For the ones that error, label them as @test_broken.
Gauss adjoint with callbacks is currently on the critical Todo.
Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
Fixes #1081
In some of the Adjoint methods, if a problem that was constructed with a callback is passed to it, the callback was being called twice. This because the
kwargs
argument already contains the callback that was passed to the problem constructor. So when the problem is solved, it uses the callback in the problem itself, and the callback passed to thesolve
, effectively doing the same callback operation twice.This PR just makes it so that only the callback in the
kwargs
is used.