-
Notifications
You must be signed in to change notification settings - Fork 29
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
Fixes for SimpleVarInfo with Ref
#527
Conversation
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.
lp = getlogp(vi_typed) | ||
return map((vi_untyped, vi_typed, svi_typed, svi_untyped)) do vi | ||
return map(( |
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.
It's slightly strange that we performed a functionality test for setlogp!!
inside this utility function.
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.
Hmm, maybe. But it's really not something we rely on. This is just to make the varinfos as consistent with each other as possible, i.e. they should have the same values and the same logp.
Alternatively, we can always just use zero
instead, but then that would also require setlogp!!
😕
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #527 +/- ##
==========================================
+ Coverage 80.40% 80.64% +0.23%
==========================================
Files 24 24
Lines 2776 2779 +3
==========================================
+ Hits 2232 2241 +9
+ Misses 544 538 -6
☔ View full report in Codecov by Sentry. |
Pull Request Test Coverage Report for Build 6048032021
💛 - Coveralls |
VarInfo
usesRef
for its logp-field, partially because it makes us compatible with Zygote.jl; Zygote.jl does support differentiating through mutations ofRef
, though it's slow: FluxML/Zygote.jl#999By default,
SimpleVarInfo
does not mutate itslogp
field, and so it uses a simpleReal
instead of aRefValue{<:Real}
. This then works fine with Zygote because no mutation occurs, until we start using threads, in which case we're working with aVector{<:Real}
instead ofVector{<:RefValue{<:Real}}
, as is done by default withVarInfo
.This can cause some issues when Julia is started with threads, e.g. https://discourse.julialang.org/t/error-running-museinference-jl-example/103360/4.
This PR adds more testing for
SimpleVarInfo
withRef
+ a fix allowing proper usage with threads.