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
I found a very weird interaction between DynamicPPL / MLDatasets / Enzyme:
Original DynamicPPL / MLDatasets code
using ADTypes: AutoEnzyme
using DynamicPPL:@modelusing DynamicPPL.TestUtils.AD: run_ad
import Enzyme: set_runtime_activity, Reverse
using Distributions: InverseGamma, MvNormal, product_distribution
using LinearAlgebra: Diagonal
@modelfunctiondemo_assume_multivariate_observe(x = [1.5, 2.0])
s ~product_distribution([InverseGamma(2, 3), InverseGamma(2, 3)])
x ~MvNormal([0.0, 0.0], Diagonal(s))
end# This import is what causes problems --- otherwise Enzyme happily differentiates the model aboveusing MLDatasets
model =demo_assume_multivariate_observe()
adtype =AutoEnzyme(; mode=set_runtime_activity(Reverse, true))
run_ad(model, adtype; test=false, benchmark=false)
MWE (Base only)
import Enzyme: Enzyme, Reverse, Const, set_runtime_activity
Enzyme.Compiler.VERBOSE_ERRORS[] =true# This block of three structs corresponds to the `using MLDatasets`struct PStruct end
Base.getproperty(::Type{PStruct}, s::Symbol) =getfield(PStruct, s)
struct QStruct end
Base.getproperty(::Type{QStruct}, s::Symbol) =getfield(QStruct, s)
struct RStruct end
Base.getproperty(::Type{RStruct}, s::Symbol) =getfield(RStruct, s)
# The rest corresponds to the DynamicPPL bitsfunctiong(xs)
returnbroadcast(x -> (exp(x), x), xs)
endfunctionf(x::AbstractVector)
logp =Ref(0.0)
ts =broadcast(g, x)
logp[] += ts[1][1]
return logp[]
end
x = [0.5, 1.0]
f(x)
Enzyme.gradient(Reverse, f, x)
(If this info is of any use: the using MLDatasets causes a lot of models that were previously perfectly fine to error. This table https://turinglang.org/ADTests/pr/ is built from TuringLang/ADTests#23, where I added a model that used MLDatasets. The error messages are quite varied -- many of them segfault (example) and some of them do the illegal type analysis error (example) -- but I am pretty sure that they are all traceable to the MLDatasets import, so hopefully they all have the same underlying cause!)
Uh oh!
There was an error while loading. Please reload this page.
I found a very weird interaction between DynamicPPL / MLDatasets / Enzyme:
Original DynamicPPL / MLDatasets code
MWE (Base only)
Stack trace
Without the Ref
In the minimised example, if I remove the
Ref
and just writethis gives a different error (
Conversion of boxed type Any is not allowed
):The text was updated successfully, but these errors were encountered: