Skip to content

Don't persist Zygote backend cache#76

Closed
ToucheSir wants to merge 1 commit intoJuliaDiff:masterfrom
ToucheSir:zygote-nocache
Closed

Don't persist Zygote backend cache#76
ToucheSir wants to merge 1 commit intoJuliaDiff:masterfrom
ToucheSir:zygote-nocache

Conversation

@ToucheSir
Copy link

Fixes #69 and closes #70.

@codecov
Copy link

codecov bot commented Mar 3, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.31 🎉

Comparison is base (19ce815) 84.36% compared to head (ced0448) 84.68%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #76      +/-   ##
==========================================
+ Coverage   84.36%   84.68%   +0.31%     
==========================================
  Files           8        8              
  Lines         467      470       +3     
==========================================
+ Hits          394      398       +4     
+ Misses         73       72       -1     
Impacted Files Coverage Δ
ext/AbstractDifferentiationZygoteExt.jl 100.00% <100.00%> (ø)
src/backends.jl 100.00% <100.00%> (ø)
src/AbstractDifferentiation.jl 79.88% <0.00%> (+0.22%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

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

Copy link
Member

@devmotion devmotion left a comment

Choose a reason for hiding this comment

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

Could we overload AD.pullback_function(::ReverseRuleConfig{<:Zygote.ZygoteRuleConfig}, f, xs...) instead of making ZygoteRuleConfig a separate backend? I think it is very unfortunatem and unintuitive if ReverseRuleBackend(ZygoteRuleConfig()) is broken and behaves differently from ZygoteBackend.

Edit: I opened #77 to show what I had in mind.


AD.ZygoteBackend() = AD.ReverseRuleConfigBackend(Zygote.ZygoteRuleConfig())
AD.@primitive function pullback_function(ba::AD.ZygoteBackend, f, xs...)
@inline # @primitive doesn't support this before function keyword
Copy link
Member

Choose a reason for hiding this comment

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

This syntax is not supported on Julia 1.6.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@inline # @primitive doesn't support this before function keyword

Copy link
Author

Choose a reason for hiding this comment

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

That's odd, I thought I force-pushed a new commit which removed it. Either way, #77 is the way to go.

To be able to use this backend, you have to load Zygote.
"""
function ZygoteBackend end
struct ZygoteBackend <: AbstractReverseMode end
Copy link
Member

Choose a reason for hiding this comment

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

This also requires changing the docstring and the README which both state that it is just a special ReverseRuleConfigBackend.

@ToucheSir
Copy link
Author

I thought about that, but somehow got it in my mind that it would require an ugly @invoke to the more general ReverseRuleConfigBackend method. The code duplication in #77 is unfortunate but pretty harmless, so closing this in favour of that.

@ToucheSir ToucheSir closed this Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zygote context cache incorrectly(?) persists between AD calls

2 participants