-
Notifications
You must be signed in to change notification settings - Fork 220
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
ArgumentError: Union{} does not have elements
when trying to run a state space model
#2151
Comments
As the stacktrace states, the problem is that in Julia 1.10 the call to A few comments:
Regarding the second point, adding print statements such as ERROR: MethodError: vcat(::ReverseDiff.TrackedArray{Float64, Float64, 1, Vector{Float64}, Vector{Float64}}, ::ReverseDiff.TrackedArray{Float64, Float64, 1, Vector{Float64}, Vector{Float64}}, ::ReverseDiff.TrackedArray{Float64, Float64, 1, Vector{Float64}, Vector{Float64}}, ::ReverseDiff.TrackedArray{Float64, Float64, 1, Vector{Float64}, Vector{Float64}}) is ambiguous.
Candidates:
vcat(var"376"::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, var"377"::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, x::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, xs::AbstractVector...)
@ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:52
vcat(X1::Union{Number, AbstractVecOrMat{<:Number}}, X::Union{Number, AbstractVecOrMat{<:Number}}...)
@ SparseArrays ~/.asdf/installs/julia/1.10.0/share/julia/stdlib/v1.10/SparseArrays/src/sparsevector.jl:1235
vcat(var"376"::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, var"377"::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, x::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, xs::AbstractVecOrMat...)
@ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:52
vcat(var"376"::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, var"377"::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, x::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, xs::Union{Number, AbstractVector}...)
@ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:52
vcat(var"339"::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, x::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, xs::AbstractVector...)
@ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:52
vcat(var"348"::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, var"349"::AbstractVector, x::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, xs::AbstractVector...)
@ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:52
vcat(var"339"::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, x::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, xs::AbstractVecOrMat...)
@ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:52
vcat(var"339"::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, x::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, xs::Union{Number, AbstractVector}...)
@ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:52
vcat(var"348"::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, var"349"::AbstractVector, x::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, xs::AbstractVecOrMat...)
@ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:52
vcat(var"348"::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, var"349"::AbstractVector, x::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, xs::Union{Number, AbstractVector}...)
@ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:52
vcat(var"372"::AbstractVector, var"373"::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, x::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, xs::AbstractVector...)
@ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:52
vcat(x::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, xs::AbstractVector...)
@ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:52
vcat(var"372"::AbstractVector, var"373"::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, x::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, xs::AbstractVecOrMat...)
@ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:52
vcat(x::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, xs::AbstractVecOrMat...)
@ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:52
vcat(x::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, xs::Union{Number, AbstractVector}...)
@ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:52
vcat(var"372"::AbstractVector, var"373"::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, x::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, xs::Union{Number, AbstractVector}...)
@ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:52
vcat(var"337"::AbstractVector, x::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, xs::AbstractVector...)
@ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:52
vcat(var"344"::AbstractVector, var"345"::AbstractVector, x::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, xs::AbstractVector...)
@ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:52
vcat(var"337"::AbstractVector, x::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, xs::AbstractVecOrMat...)
@ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:52
vcat(var"337"::AbstractVector, x::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, xs::Union{Number, AbstractVector}...)
@ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:52
vcat(var"344"::AbstractVector, var"345"::AbstractVector, x::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, xs::AbstractVecOrMat...)
@ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:52
vcat(var"344"::AbstractVector, var"345"::AbstractVector, x::ReverseDiff.TrackedArray{V, D, 1} where {V, D}, xs::Union{Number, AbstractVector}...)
@ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/derivatives/arrays.jl:52
Possible fix, define
vcat(::ReverseDiff.TrackedArray{…} where {…}, ::ReverseDiff.TrackedArray{…} where {…}, ::ReverseDiff.TrackedArray{…} where {…}, ::Vararg{…})
Stacktrace:
[1] getindex(vi::TypedVarInfo{@NamedTuple{…}, ReverseDiff.TrackedReal{…}}, spl::Sampler{NUTS{…}})
@ DynamicPPL ~/.julia/dev/DynamicPPL/src/varinfo.jl:1447
[2] macro expansion
@ ./show.jl:1181 [inlined]
[3] eltype(vi::TypedVarInfo{@NamedTuple{…}, ReverseDiff.TrackedReal{…}}, spl::Sampler{NUTS{…}})
@ DynamicPPL ~/.julia/dev/DynamicPPL/src/abstract_varinfo.jl:368
[4] get_matching_type(spl::Sampler{NUTS{…}}, vi::TypedVarInfo{@NamedTuple{…}, ReverseDiff.TrackedReal{…}}, ::Type{Float64})
@ DynamicPPL ~/.julia/dev/DynamicPPL/src/compiler.jl:722
[5] matchingvalue(sampler::Sampler{NUTS{…}}, vi::TypedVarInfo{@NamedTuple{…}, ReverseDiff.TrackedReal{…}}, value::Type{Float64})
@ DynamicPPL ~/.julia/dev/DynamicPPL/src/compiler.jl:693
[6] matchingvalue(context::SamplingContext{Sampler{…}, DefaultContext, Random.TaskLocalRNG}, vi::TypedVarInfo{@NamedTuple{…}, ReverseDiff.TrackedReal{…}}, value::Type)
@ DynamicPPL ~/.julia/dev/DynamicPPL/src/compiler.jl:706
[7] macro expansion
@ ~/.julia/dev/DynamicPPL/src/model.jl:993 [inlined]
[8] make_evaluate_args_and_kwargs
@ ~/.julia/dev/DynamicPPL/src/model.jl:971 [inlined]
[9] _evaluate!!(model::Model{…}, varinfo::TypedVarInfo{…}, context::SamplingContext{…})
@ DynamicPPL ~/.julia/dev/DynamicPPL/src/model.jl:962
[10] evaluate_threadunsafe!!
@ ~/.julia/dev/DynamicPPL/src/model.jl:936 [inlined]
[11] evaluate!!
@ ~/.julia/dev/DynamicPPL/src/model.jl:889 [inlined]
[12] logdensity(f::LogDensityFunction{TypedVarInfo{…}, Model{…}, SamplingContext{…}}, θ::ReverseDiff.TrackedArray{Float64, Float64, 1, Vector{…}, Vector{…}})
@ DynamicPPL ~/.julia/dev/DynamicPPL/src/logdensityfunction.jl:94
[13] Fix1
@ Base ./operators.jl:1118 [inlined]
[14] ReverseDiff.GradientTape(f::Base.Fix1{…}, input::Vector{…}, cfg::ReverseDiff.GradientConfig{…})
@ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/api/tape.jl:199
[15] ReverseDiff.GradientTape(f::Function, input::Vector{Float64})
@ ReverseDiff ~/.julia/packages/ReverseDiff/UJhiD/src/api/tape.jl:198
[16] _compiledtape
@ LogDensityProblemsADReverseDiffExt ~/.julia/packages/LogDensityProblemsAD/OQ0BL/ext/LogDensityProblemsADReverseDiffExt.jl:56 [inlined]
[17] #ADgradient#1
@ LogDensityProblemsADReverseDiffExt ~/.julia/packages/LogDensityProblemsAD/OQ0BL/ext/LogDensityProblemsADReverseDiffExt.jl:50 [inlined]
[18] ADgradient(ad::AutoReverseDiff, ℓ::LogDensityFunction{TypedVarInfo{…}, Model{…}, SamplingContext{…}})
@ Turing.Essential ~/.julia/packages/Turing/tdsVz/src/essential/ad.jl:44
[19] ADgradient(ad::AutoReverseDiff, ℓ::LogDensityFunction{TypedVarInfo{…}, Model{…}, SamplingContext{…}})
@ Turing.Essential ~/.julia/packages/Turing/tdsVz/src/essential/ad.jl:20 [inlined]
[20] initialstep(rng::Random.TaskLocalRNG, model::Model{…}, spl::Sampler{…}, vi::TypedVarInfo{…}; init_params::Nothing, nadapts::Int64, kwargs::@Kwargs{…})
@ Turing.Inference ~/.julia/packages/Turing/tdsVz/src/mcmc/hmc.jl:148
[21] step(rng::Random.TaskLocalRNG, model::Model{…}, spl::Sampler{…}; initial_params::Nothing, kwargs::@Kwargs{…})
@ DynamicPPL ~/.julia/dev/DynamicPPL/src/sampler.jl:116
[22] step
@ ~/.julia/dev/DynamicPPL/src/sampler.jl:99 [inlined]
[23] macro expansion
@ ~/.julia/packages/AbstractMCMC/Es490/src/sample.jl:127 [inlined]
[24] macro expansion
@ ~/.julia/packages/ProgressLogging/6KXlp/src/ProgressLogging.jl:328 [inlined]
[25] macro expansion
@ ~/.julia/packages/AbstractMCMC/Es490/src/logging.jl:9 [inlined]
[26] mcmcsample(rng::Random.TaskLocalRNG, model::Model{…}, sampler::Sampler{…}, N::Int64; progress::Bool, progressname::String, callback::Nothing, discard_initial::Int64, thinning::Int64, chain_type::Type, initial_state::Nothing, kwargs::@Kwargs{…})
@ AbstractMCMC ~/.julia/packages/AbstractMCMC/Es490/src/sample.jl:117
[27] sample(rng::Random.TaskLocalRNG, model::Model{…}, sampler::Sampler{…}, N::Int64; chain_type::Type, resume_from::Nothing, initial_state::Nothing, progress::Bool, nadapts::Int64, discard_adapt::Bool, discard_initial::Int64, kwargs::@Kwargs{})
@ Turing.Inference ~/.julia/packages/Turing/tdsVz/src/mcmc/hmc.jl:117
[28] sample
@ Turing.Inference ~/.julia/packages/Turing/tdsVz/src/mcmc/hmc.jl:86 [inlined]
[29] #sample#2
@ Turing.Inference ~/.julia/packages/Turing/tdsVz/src/mcmc/Inference.jl:190 [inlined]
[30] sample
@ Turing.Inference ~/.julia/packages/Turing/tdsVz/src/mcmc/Inference.jl:183 [inlined]
[31] #sample#1
@ Turing.Inference ~/.julia/packages/Turing/tdsVz/src/mcmc/Inference.jl:180 [inlined]
[32] sample(model::Model{…}, alg::NUTS{…}, N::Int64)
@ Turing.Inference ~/.julia/packages/Turing/tdsVz/src/mcmc/Inference.jl:174
[33] top-level scope
@ REPL[18]:1
Some type information was truncated. Use `show(err)` to see complete types. |
Thanks for the quick response! I'll have a look at the resources you posted. |
+1 on this issue, I just ran into the same thing with my own state space model. |
The problem should be fixed by TuringLang/DynamicPPL.jl#568 (but tests currently fail due to an issue with LinearAlgebra on Julia 1.10 and a seemingly unrelated problem with Turing 0.30.2). |
Fixed by TuringLang/DynamicPPL.jl#568 which will be available in the next DynamicPPL release: JuliaRegistries/General#99754 |
I am trying to run a state space model, and I keep encountering the error in the subject line when using ReverseDiff. I found a previous issue raising it, but it was with Julia 1.4. (EDIT: link)
Here is a minimum reproducible example with Julia 1.10.0 and Turing 0.30.0
And here is the stacktrace
The text was updated successfully, but these errors were encountered: