-
Notifications
You must be signed in to change notification settings - Fork 37
Don't convert all T<:Real to float(T)
#1088
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
Conversation
| end | ||
| end | ||
|
|
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.
No change to the code here, just removing the redundant VERSION check since our min bound is 1.10.
Benchmark Report for Commit 9f89ee7Computer InformationBenchmark Results |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1088 +/- ##
==========================================
+ Coverage 81.06% 81.31% +0.25%
==========================================
Files 40 40
Lines 3749 3751 +2
==========================================
+ Hits 3039 3050 +11
+ Misses 710 701 -9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@mhauru This is not quite the right fix (it still does not respect the logp precision in the accumulator), but it will fix CI. Not sure what you think. I'm rather on the fence about going forward with this. |
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.
The old thing was hacky, and this thing is hacky, but hacky in a way that makes more things work, so it seems like an improvement to me. Any particular reason to decide not to do this? I assume the conclusion still holds that the proper fix needs special casing on AD tracer types.
Co-authored-by: Markus Hauru <markus@mhauru.org>
|
Yeah the correct fix still needs overloading on specific types. The main reason why I'm hesitant is technical debt, plus the knowledge that once this fix is in, any motivation I have to fix it properly will vanish. |
|
DynamicPPL.jl documentation for PR #1088 is available at: |
|
(Also, the original issue might be fixed by adrhill/SparseConnectivityTracer.jl#279) |
|
Not sure if this adds much technical debt, I feel like this is about as hacky as what was in place. A tiny bit more complicated, yes. Happy either way, to merge this or wait for the upstream fix, as long as the latter doesn't take very long. |
I will tag an SCT |
|
That definitely counts as not very long. :) Thank you! |
|
The release is tagged and should be available soon: JuliaRegistries/General#141344 |
|
CI on main passes now! Thank you @adrhill 😊 |
Closes #1081
I traced the error all the way back to
unflatten, and the problem is partly related to #906, but it's perhaps even more subtle than that.unflattenDOES attempt to change the eltypes of the accumulators based on the parameters. In other words it does actually try its best to work for all Real types. (Not doing so would cause issues with ForwardDiff, and we don't see that. So clearly something was working.)DynamicPPL.jl/src/varinfo.jl
Lines 381 to 383 in 1b159a6
However, it does this specifically using
float_type_with_fallback. And for typesT <: Real, we currently have the definitionDynamicPPL.jl/src/utils.jl
Lines 777 to 784 in 1b159a6
Now then the reason why this Just Works with ForwardDiff is because
But for SCT we have that
This PR therefore makes the smallest possible change to get this to work for both dual types.
It also adds more methods to handle
These methods mean that the old behaviour of
float(T)for such types is preserved.A note on ForwardDiff
One might think that this PR causes AD to break when evaluating with
Vector{Int}parameters, because the old behaviour was thatForwardDiff.Dual{tag,Int}would be converted toForwardDiff.Dual{tag,Float64}, and the new behaviour in this PR leaves it untouched.As it turns out, ForwardDiff can't be used with
Vector{Int}parameters anyway, because the output gradient is stored in aVector{Int}and although DI correctly calculates gradients of [0.5, 0.5], it will error when trying to insert those gradients back into theVector{Int}.so that case can be safely ignored.