You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Have had a fewusers report this error when running my package MuseInference which I believe boils down to a bug with SimpleVarInfo+threads+ForwardDiff. The problem is the logp vector in ThreadSafeVarInfo is concretely typed for Float64 (or whatever precision) so ForwardDiff.Dual's can't go in it.
Here's a MWE (DynamicPPL v0.23.13, Turing v0.28.2) which you must run with --threads=2 (or more) to trigger the error, otherwise no error:
using Turing, ForwardDiff
import DynamicPPL as DynPPL
@modelfunctionfoo()
x ~Normal()
end
model =foo()
ForwardDiff.derivative(1.) do x
vi = DynPPL.SimpleVarInfo((;x), 0., DynPPL.NoTransformation())
DynPPL.logprior(model, vi)
end
(stack trace below)
One solution is relax the logp type (although it makes things unstable, but maybe it doesnt matter, not sure what you guys would want as a fix)
function DynPPL.ThreadSafeVarInfo(vi::DynPPL.SimpleVarInfo)
return DynPPL.ThreadSafeVarInfo(vi, Vector{Real}(zeros(typeof(DynPPL.getlogp(vi)), Threads.nthreads())))
end
If this is a bug would be great to get fixed. If this is instead a problem with how I'm using DynamicPPL internals please let me know.
Actually after digging some more I'm guessing I'm using the internals wrong and I should follow what the other constructors do which is to use float_type_with_fallback and infer_nested_eltype to get the right typed zero:
Have had a few users report this error when running my package MuseInference which I believe boils down to a bug with SimpleVarInfo+threads+ForwardDiff. The problem is the logp vector in ThreadSafeVarInfo is concretely typed for Float64 (or whatever precision) so ForwardDiff.Dual's can't go in it.
Here's a MWE (DynamicPPL v0.23.13, Turing v0.28.2) which you must run with
--threads=2
(or more) to trigger the error, otherwise no error:(stack trace below)
One solution is relax the logp type (although it makes things unstable, but maybe it doesnt matter, not sure what you guys would want as a fix)
If this is a bug would be great to get fixed. If this is instead a problem with how I'm using DynamicPPL internals please let me know.
The text was updated successfully, but these errors were encountered: