mschauer / ZigZagBoomerang.jl

Sleek implementations of the ZigZag, Boomerang and other assorted piecewise deterministic Markov processes for Markov Chain Monte Carlo including Sticky PDMPs for variable selection
MIT License
100 stars 7 forks source link

Turing example broken with MethodError on whiten() #122

Open svilupp opened 2 years ago

svilupp commented 2 years ago

First of all, thank you for the awesome package!

I was keen to try it but I got stuck with a method error on whiten()

ERROR: MethodError: no method matching whiten(::Float64, ::Vector{Float64})

I've tried to execute by running the example turing/lr.jl as is.

My debugging efforts have been unsuccessful:

Error trace:

julia> el = @elapsed begin

       trace, final, (acc, num), cs = @time pdmp(
               dneglogp, # return first two directional derivatives of negative target log-likelihood in direction v
               ∇neglogp!, # return gradient of negative target log-likelihood
               t0, x0, θ0, T, # initial state and duration
               ZZB.LocalBound(c), # use Hessian information
               Z; # sampler
               adapt=true, # adapt bound c
               progress=true, # show progress bar
               subsample=true # keep only samples at refreshment times
       )
       end

ERROR: MethodError: no method matching whiten(::Float64, ::Vector{Float64})
Closest candidates are:
  whiten(::AbstractMatrix, ::AbstractVecOrMat) at ~/.julia/packages/PDMats/ZW0lN/src/generics.jl:75
Stacktrace:
  [1] record_rate(θ::Vector{Float64}, F::BouncyParticle{Nothing, Nothing, Float64, Float64, Diagonal{Float64, Vector{Float64}}})
    @ ZigZagBoomerang ~/.julia/packages/ZigZagBoomerang/BNuRn/src/not_fact_samplers.jl:197
  [2] pdmp(::var"#139#143"{Turing.LogDensityFunction{DynamicPPL.TypedVarInfo{NamedTuple{(:α, :β), Tuple{DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:α, Setfield.IdentityLens}, Int64}, Vector{Normal{Float64}}, Vector{AbstractPPL.VarName{:α, Setfield.IdentityLens}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:β, Setfield.IdentityLens}, Int64}, Vector{DiagNormal}, Vector{AbstractPPL.VarName{:β, Setfield.IdentityLens}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}}}, Float64}, DynamicPPL.Model{typeof(lr_nuts), (:x, :y, :σ), (), (), Tuple{Matrix{Float64}, Vector{Float64}, Float64}, Tuple{}, DynamicPPL.DefaultContext}, DynamicPPL.SampleFromPrior, Turing.ModeEstimation.OptimizationContext{DynamicPPL.DefaultContext}}}, ::var"#141#145"{Turing.LogDensityFunction{DynamicPPL.TypedVarInfo{NamedTuple{(:α, :β), Tuple{DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:α, Setfield.IdentityLens}, Int64}, Vector{Normal{Float64}}, Vector{AbstractPPL.VarName{:α, Setfield.IdentityLens}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}, DynamicPPL.Metadata{Dict{AbstractPPL.VarName{:β, Setfield.IdentityLens}, Int64}, Vector{DiagNormal}, Vector{AbstractPPL.VarName{:β, Setfield.IdentityLens}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}}}, Float64}, DynamicPPL.Model{typeof(lr_nuts), (:x, :y, :σ), (), (), Tuple{Matrix{Float64}, Vector{Float64}, Float64}, Tuple{}, DynamicPPL.DefaultContext}, DynamicPPL.SampleFromPrior, Turing.ModeEstimation.OptimizationContext{DynamicPPL.DefaultContext}}}, ::Float64, ::Vector{Float64}, ::Vector{Float64}, ::Float64, ::ZigZagBoomerang.LocalBound{Float64}, ::BouncyParticle{Nothing, Nothing, Float64, Float64, Diagonal{Float64, Vector{Float64}}}; iter_offset::Int64, adapt_mass::Bool, oscn::Bool, adapt::Bool, subsample::Bool, progress::Bool, progress_stops::Int64, islocal::Bool, seed::Tuple{UInt64, UInt64}, factor::Float64)
    @ ZigZagBoomerang ~/.julia/packages/ZigZagBoomerang/BNuRn/src/not_fact_samplers.jl:339

System Info:

Julia Version 1.8.0 Commit 5544a0fab76 (2022-08-17 13:38 UTC) Platform Info: OS: macOS (arm64-apple-darwin21.3.0) CPU: 8 × Apple M1 Pro WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-13.0.1 (ORCJIT, apple-m1) Threads: 1 on 6 virtual cores Environment: JULIA_EDITOR = nvim

Environment info: (slightly different from the Project.toml in the repo, as it was for Julia 1.7 and it still had a local dev dependency on ZigZag, which I had to free first)

⌃ [f6369f11] ForwardDiff v0.10.30 ⌃ [e9467ef8] GLMakie v0.6.3 ⌃ [c7f686f2] MCMCChains v5.3.0 ⌅ [ee78f7c6] Makie v0.17.3 ⌃ [b1d3bc72] Pathfinder v0.4.5 ⌃ [295af30f] Revise v3.3.3 ⌃ [fce5fe82] Turing v0.21.3 [36347407] ZigZagBoomerang v0.13.1