JuliaDiff / AbstractDifferentiation.jl

An abstract interface for automatic differentiation.
https://juliadiff.org/AbstractDifferentiation.jl/
MIT License
137 stars 18 forks source link

New Zygote context in every call to `AD.pullback_function` #77

Closed devmotion closed 1 year ago

devmotion commented 1 year ago

Alternative to #76 that I had in mind when writing https://github.com/JuliaDiff/AbstractDifferentiation.jl/pull/76#pullrequestreview-1323649955.

In contrast to #76, with this PR ZygoteBackend would still be a ReverseRuleConfigBackend, and hence the behaviour of ZygoteBackend and ReverseRuleConfigBackend(Zygote.ZygoteRuleConfig()) would not differ.

Fixes #69. Closes #70. Closes #76.

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 75.00% and project coverage change: -0.12 :warning:

Comparison is base (19ce815) 84.36% compared to head (848ee38) 84.25%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #77 +/- ## ========================================== - Coverage 84.36% 84.25% -0.12% ========================================== Files 8 8 Lines 467 470 +3 ========================================== + Hits 394 396 +2 - Misses 73 74 +1 ``` | [Impacted Files](https://codecov.io/gh/JuliaDiff/AbstractDifferentiation.jl/pull/77?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaDiff) | Coverage Δ | | |---|---|---| | [src/backends.jl](https://codecov.io/gh/JuliaDiff/AbstractDifferentiation.jl/pull/77?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaDiff#diff-c3JjL2JhY2tlbmRzLmps) | `83.33% <0.00%> (-16.67%)` | :arrow_down: | | [ext/AbstractDifferentiationChainRulesCoreExt.jl](https://codecov.io/gh/JuliaDiff/AbstractDifferentiation.jl/pull/77?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaDiff#diff-ZXh0L0Fic3RyYWN0RGlmZmVyZW50aWF0aW9uQ2hhaW5SdWxlc0NvcmVFeHQuamw=) | `100.00% <100.00%> (ø)` | | | [ext/AbstractDifferentiationZygoteExt.jl](https://codecov.io/gh/JuliaDiff/AbstractDifferentiation.jl/pull/77?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaDiff#diff-ZXh0L0Fic3RyYWN0RGlmZmVyZW50aWF0aW9uWnlnb3RlRXh0Lmps) | `100.00% <100.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaDiff). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaDiff)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

devmotion commented 1 year ago

I made the fix more modular in https://github.com/JuliaDiff/AbstractDifferentiation.jl/pull/77/commits/848ee3847c364bd95f4a0d6a57c7f6787cb3d43f, to avoid code duplication and make it easy to apply similar fixes for other AD backends if needed.

ToucheSir commented 1 year ago

Well, that eliminates my only substantive point in https://github.com/JuliaDiff/AbstractDifferentiation.jl/pull/76#issuecomment-1453695860. As the adage goes, the fastest way to get something done is to do it wrong and get someone to correct it for you :laughing:

devmotion commented 1 year ago

That is, you approve this PR? 🙂

devmotion commented 1 year ago

I trust your Zygote expertise 🙂