-
Notifications
You must be signed in to change notification settings - Fork 30
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 adjoint for fill
and fix tests
#203
Conversation
* Fix deprecations * Improve CI (AD): cancel builds and no coverage * Improve CI (Others): cancel builds and no coverage
It seems there are two problems remaining with Zygote that are both caused by the ChainRules integration:
In both cases it seems somehow ChainRules types ( DistributionsAD.jl/src/chainrules.jl Line 10 in af2ea73
0 seems to fix the first issue but this seems rather like a workaround than a proper fix. And the second problem occurs more generally.
@mcabbott @DhairyaLGandhi I lost track of the recent changes, open PRs and possible fixes in Zygote for the ChainRules integration - is there anything on the Zygote side that could fix the problems? I assume you might be familiar with these issues. I'll also check if removing the workarounds in #198 helps (if they are not needed anymore, that's the first thing I have to check of course). |
As far as I know this one is a new class of bug. Having an array of
Whereas this one looks like a Tangent is leaking to where it expects a NamedTuple:
Some such leaks are plugged in FluxML/Zygote.jl#1104 . That's the only open PR which fiddles with these things, I believe. Linked case is Zygote v0.6.29, julia version 1.3.1. Am I reading correctly that these errors do not occur on Julia 1.6? |
No, the tests were just cancelled before these tests were run with Julia 1.6 on Github. I can reproduce the test errors locally with Julia 1.6. |
OK. Maybe FluxML/Zygote.jl@35ee9bd will run these tests on top of that PR. Not sure I understand how group/AD selects what's used in tests; ideally it would run just the Zygote ones. In https://github.com/FluxML/Zygote.jl/runs/3976090808?check_suite_focus=true so far I see Tracker, ForwardDiff, ReverseDiff so perhaps it's doing them all. |
I already changed this in this PR, you can run the Zygote tests only with |
The complete test was killed after 6 hours. I see many |
No, it didn't. |
@mcabbott I was able to fix these issues locally by simplifying the Zygote tests a bit (in contrast to the tracked/dual number type ADs we only have to check the full set of arguments once) and using However, I had to add the type piracy in DistributionsAD.jl/test/ad/utils.jl Lines 14 to 26 in 12b9d34
filldist tests failed (hopefully the last commit doesn't break other tests 😄). More concretely, the problem was that https://github.com/JuliaDiff/ChainRulesTestUtils.jl/blob/dd0e246d1516451ec963db55a7a51910819082b3/src/testers.jl#L228 failed otherwise since cotangents that were specified as NoTangent and for which FiniteDifferences returned a NoTangent were computed as nested Tangent of NoTangent s and tuples of NoTangent s by Zygote. Unfortunately, I don't have a MWE but only a quite complicated test here.
|
Well spotted. Yes I think that ought to be safe. I've added FluxML/Zygote.jl@45f5c27 which I hope captures this effect everywhere. We'll see if CI likes it... |
I confirmed locally that the remaining Zygote test errors (namely, as mentioned above,
) are indeed fixed by FluxML/Zygote.jl#1104. FluxML/Zygote.jl#1104 also allows us to remove the workarounds for @mcabbott Thus this PR is blocked by FluxML/Zygote.jl#1104 but tests should pass once a new Zygote version with the changes in this PR is released. |
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.
Looks good to me - many thanks @devmotion !
This PR removes the Zygote adjoint for
fill
(see #202 for a discussion for why it is bad and causes problems in other packages).Additionally, it
Beta
andGamma
with ForwardDiff, Tracker, and ReverseDiff caused byxlogy
by choosing less special parameter values (the proper upstream fix was Add rules for LogExpFunctions JuliaDiff/DiffRules.jl#69 but it has not been propagated to the AD packages yet)_project
intogetproperty
's gradient, and then improvez2d
etc. to restore stability FluxML/Zygote.jl#1104 was merged; an integration test with DistributionsAD was added to Zygote which hopefully helps to avoid that Zygote breaks DistributionsAD accidentally in the future)Original comment:
An alternative to #202 with some additional unrelated fixes that make Zygote tests pass locally. Hopefully this fixes also the Tracker and ReverseDiff issues (didn't run them locally to save time).
Edit: Unfortunately, it seems the Tracker and ReverseDiff issues are not fixed by this PR.
Edit 2: Maybe the problem is that RD, Tracker, and FD don't know the derivative of
xlogy
andxlog1py
. I'll check locally if adding some DiffRules helps.Edit 3: Indeed, the issues with Tracker, ReverseDiff, and ForwardDiff are fixed by defining diff rules for
xlogy
andxlog1py
. I made a PR to DiffRules (JuliaDiff/DiffRules.jl#69) but unfortunately additionally it requires fixes for Tracker, ReverseDiff and ForwardDiff itself. In the mean time I guess the easiest is to choose different parameter values such that we don't end up with the special case forxlogy
wherex
is zero.