Following up from #20 (comment).
I think both errors look most likely to be genuine Enzyme bugs (there's a possibility it could be a DI thing but I don't suspect that at first glance). I'm not super surprised, we've never really tested anything beyond just gradients so there are definitely more bugs out there to be squished :-)
With Enzyme bugs traditionally what I've done is to try to minimise them to strip away all the extra bits. For example, I'm fairly sure this can probably be stripped down to something that calls hvp on a function that calls logpdf(dist, x). I'd be happy to help with that (at some point in time).
Setup
I'm running this with the code currently on #20 (my fork), but I get the same results with current main (ed83efc).
(jl) pkg> st
Status `~/jl/Project.toml`
[31c24e10] Distributions v0.25.125
[366bfd00] DynamicPPL v0.41.7
[1a970f40] ParallelMCMC v0.0.2 `ParallelMCMC.jl`
(jl) pkg> st --manifest
Status `~/jl/Manifest.toml`
[47edcb42] ADTypes v1.22.0
[621f4979] AbstractFFTs v1.5.0
[80f14c24] AbstractMCMC v5.15.1
[7a57a42e] AbstractPPL v0.14.2
[1520ce14] AbstractTrees v0.4.5
[7d9f7c33] Accessors v0.1.44
[79e6a3ab] Adapt v4.5.2
[66dad0bd] AliasTables v1.1.3
[dce04be8] ArgCheck v2.5.0
[a9b6321e] Atomix v1.1.3
[13072b0f] AxisAlgorithms v1.1.0
[39de3d68] AxisArrays v0.4.8
[ab4f0b2a] BFloat16s v0.6.1
[198e06fe] BangBang v0.4.9
[76274a88] Bijectors v0.15.24
[fa961155] CEnum v0.5.0
⌃ [052768ef] CUDA v5.11.2
[1af6417a] CUDA_Runtime_Discovery v2.0.0
[d360d2e6] ChainRulesCore v1.26.1
[0ca39b1e] Chairmarks v1.3.1
[9e997f8a] ChangesOfVariables v0.1.10
[38540f10] CommonSolve v0.2.6
[34da2185] Compat v4.18.1
[a33af91c] CompositionsBase v0.1.2
[88cd18e8] ConsoleProgressMonitor v0.1.2
[187b0558] ConstructionBase v1.6.0
[a8cc5b0e] Crayons v4.1.1
[9a962f9c] DataAPI v1.16.0
[864edb3b] DataStructures v0.19.4
[e2d170a0] DataValueInterfaces v1.0.0
[b429d917] DensityInterface v0.4.0
[a0c0ee7d] DifferentiationInterface v0.7.17
[31c24e10] Distributions v0.25.125
[ffbed154] DocStringExtensions v0.9.5
[366bfd00] DynamicPPL v0.41.7
[7da242da] Enzyme v0.13.140
[f151be2c] EnzymeCore v0.8.20
[e2ba6199] ExprTools v0.1.10
[b86e33f2] FFTA v0.3.1
[1a297f60] FillArrays v1.16.0
[d9f16b24] Functors v0.5.2
[0c68f7d7] GPUArrays v11.5.3
[46192b85] GPUArraysCore v0.2.0
[61eb1bfa] GPUCompiler v1.9.1
[096a3bc2] GPUToolbox v1.1.1
[076d061b] HashArrayMappedTries v0.2.0
[34004b35] HypergeometricFunctions v0.3.28
[22cec73e] InitialValues v0.3.1
[18e54dd8] IntegerMathUtils v0.1.3
[a98d9a8b] Interpolations v0.16.2
[8197267c] IntervalSets v0.7.14
[3587e190] InverseFunctions v0.1.17
[41ab1584] InvertedIndices v1.3.1
[92d709cd] IrrationalConstants v0.2.6
[c8e1da08] IterTools v1.10.0
[82899510] IteratorInterfaceExtensions v1.0.0
[692b3bcd] JLLWrappers v1.7.1
[682c06a0] JSON v1.5.2
[63c18a36] KernelAbstractions v0.9.41
[5ab0869b] KernelDensity v0.6.11
[929cbde3] LLVM v9.7.1
[8b046642] LLVMLoopInfo v1.0.0
[b964fa9f] LaTeXStrings v1.4.0
[1d6d02ad] LeftChildRightSiblingTrees v0.2.1
[6fdf6af0] LogDensityProblems v2.2.0
[2ab3a3ac] LogExpFunctions v0.3.29
[e6f89c97] LoggingExtras v1.2.0
[c7f686f2] MCMCChains v7.7.0
[be115224] MCMCDiagnosticTools v0.3.17
[e80e1ace] MLJModelInterface v1.12.1
[1914dd2f] MacroTools v0.5.16
[dbb5928d] MappedArrays v0.4.3
[e1d29d7a] Missings v1.2.0
[46d2c3a1] MuladdMacro v0.2.4
[5da4648a] NVTX v1.0.3
[c020b1a1] NaturalSort v1.0.0
[d8793406] ObjectFile v0.5.0
[6fe1bfb0] OffsetArrays v1.17.0
[bac558e1] OrderedCollections v1.8.1
[90014a1f] PDMats v0.11.37
[1a970f40] ParallelMCMC v0.0.2 `ParallelMCMC.jl`
[69de0a69] Parsers v2.8.4
[569bd051] PartitionedDistributions v0.0.1
⌅ [aea7be01] PrecompileTools v1.2.1
[21216c6a] Preferences v1.5.2
[08abe8d2] PrettyTables v3.3.2
[27ebfcd6] Primes v0.5.7
[33c8b6b6] ProgressLogging v0.1.6
[92933f4c] ProgressMeter v1.11.0
[43287f4e] PtrArrays v1.4.0
[1fd47b50] QuadGK v2.11.3
[74087812] Random123 v1.7.1
[e6cf234a] RandomNumbers v1.6.0
[b3c3ace0] RangeArrays v0.3.2
[c84ed2f1] Ratios v0.4.5
[3cdcf5f2] RecipesBase v1.3.4
[189a3867] Reexport v1.2.2
[ae029012] Requires v1.3.1
[79098fc4] Rmath v0.9.0
[f2b01f46] Roots v3.0.0
[30f210dd] ScientificTypesBase v3.1.0
[7e506255] ScopedValues v1.6.2
[6c6a2e73] Scratch v1.3.0
[a2af1166] SortingAlgorithms v1.2.2
[276daf66] SpecialFunctions v2.7.2
[90137ffa] StaticArrays v1.9.18
[1e83bf80] StaticArraysCore v1.4.4
[64bff920] StatisticalTraits v3.5.0
[10745b16] Statistics v1.11.1
[82ae8749] StatsAPI v1.8.0
[2913bbd2] StatsBase v0.34.10
[4c63d2b9] StatsFuns v1.5.2
[892a3eda] StringManipulation v0.4.4
[53d494c1] StructIO v0.3.1
[ec057cc2] StructUtils v2.8.1
[3783bdb8] TableTraits v1.0.1
[bd369af6] Tables v1.12.1
[5d786b92] TerminalLoggers v0.1.7
[e689c965] Tracy v0.1.6
[013be700] UnsafeAtomics v0.3.1
[efce3f68] WoodburyMatrices v1.1.0
[d1e2174e] CUDA_Compiler_jll v0.4.3+0
[4ee394cb] CUDA_Driver_jll v13.2.1+0
[76a88914] CUDA_Runtime_jll v0.21.0+1
[7cc45869] Enzyme_jll v0.0.258+0
[9c1d0b0a] JuliaNVTXCallbacks_jll v0.2.1+0
[dad2f222] LLVMExtra_jll v0.0.42+0
[ad6e5548] LibTracyClient_jll v0.13.1+0
[e98f9f5b] NVTX_jll v3.2.2+0
[efe28fd5] OpenSpecFun_jll v0.5.6+0
[f50d1b31] Rmath_jll v0.5.1+0
[1e29f10c] demumble_jll v1.3.0+0
[0dad84c5] ArgTools v1.1.2
[56f22d72] Artifacts v1.11.0
[2a0f44e3] Base64 v1.11.0
[ade2ca70] Dates v1.11.0
[8ba89e20] Distributed v1.11.0
[f43a241f] Downloads v1.6.0
[7b1f6079] FileWatching v1.11.0
[b77e0a4c] InteractiveUtils v1.11.0
[4af54fe1] LazyArtifacts v1.11.0
[b27032c2] LibCURL v0.6.4
[76f85450] LibGit2 v1.11.0
[8f399da3] Libdl v1.11.0
[37e2e46d] LinearAlgebra v1.11.0
[56ddb016] Logging v1.11.0
[d6f4376e] Markdown v1.11.0
[a63ad114] Mmap v1.11.0
[ca575930] NetworkOptions v1.2.0
[44cfe95a] Pkg v1.11.0
[de0858da] Printf v1.11.0
[3fa0cd96] REPL v1.11.0
[9a3f8284] Random v1.11.0
[ea8e919c] SHA v0.7.0
[9e88b42a] Serialization v1.11.0
[1a1011a3] SharedArrays v1.11.0
[6462fe0b] Sockets v1.11.0
[2f01184e] SparseArrays v1.11.0
[f489334b] StyledStrings v1.11.0
[4607b0f0] SuiteSparse
[fa267f1f] TOML v1.0.3
[a4e569a6] Tar v1.10.0
[8dfed614] Test v1.11.0
[cf7118a7] UUIDs v1.11.0
[4ec0a83e] Unicode v1.11.0
[e66e0078] CompilerSupportLibraries_jll v1.1.1+0
[deac9b47] LibCURL_jll v8.6.0+0
[e37daf67] LibGit2_jll v1.7.2+0
[29816b5a] LibSSH2_jll v1.11.0+1
[c8ffd9c3] MbedTLS_jll v2.28.6+0
[14a3606d] MozillaCACerts_jll v2023.12.12
[4536629a] OpenBLAS_jll v0.3.27+1
[05823500] OpenLibm_jll v0.8.5+0
[bea87d4a] SuiteSparse_jll v7.7.0+0
[83775a58] Zlib_jll v1.2.13+1
[8e850b90] libblastrampoline_jll v5.11.0+0
[8e850ede] nghttp2_jll v1.59.0+0
[3f19e933] p7zip_jll v17.4.0+2
Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m`
julia> versioninfo()
Julia Version 1.11.9
Commit 53a02c0720c (2026-02-06 00:27 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: macOS (arm64-apple-darwin24.0.0)
CPU: 10 × Apple M1 Pro
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)
Normal works
using DynamicPPL, Distributions, ParallelMCMC, LinearAlgebra
sampler = ParallelMALASampler(0.1)
@model f1() = x ~ Normal()
sample(DensityModel(f1()), sampler, 500)
MvNormal fails
@model f2() = x ~ MvNormal(zeros(2), I)
sample(DensityModel(f2()), sampler, 500)
#=
ERROR: AssertionError: ety == eltype(vt)
Stacktrace:
[1] sret_ty(fn::LLVM.Function, idx::Int64)
@ Enzyme ~/.julia/packages/Enzyme/9OkvN/src/utils.jl:575
[2] removeDeadArgs!(mod::LLVM.Module, tm::LLVM.TargetMachine, post_gc_fixup::Bool)
@ Enzyme.Compiler ~/.julia/packages/Enzyme/9OkvN/src/llvm/transforms.jl:2667
[3] optimize!(mod::LLVM.Module, tm::LLVM.TargetMachine)
@ Enzyme.Compiler ~/.julia/packages/Enzyme/9OkvN/src/compiler/optimize.jl:200
[4] compile_unhooked(output::Symbol, job::GPUCompiler.CompilerJob{…})
@ Enzyme.Compiler ~/.julia/packages/Enzyme/9OkvN/src/compiler.jl:5493
[5] #compile#163
@ ~/.julia/packages/GPUCompiler/Yuvf5/src/driver.jl:67 [inlined]
[6] compile
@ ~/.julia/packages/GPUCompiler/Yuvf5/src/driver.jl:55 [inlined]
[7] _thunk(job::GPUCompiler.CompilerJob{…}, postopt::Bool)
@ Enzyme.Compiler ~/.julia/packages/Enzyme/9OkvN/src/compiler.jl:6776
[8] _thunk
@ ~/.julia/packages/Enzyme/9OkvN/src/compiler.jl:6774 [inlined]
[9] cached_compilation
@ ~/.julia/packages/Enzyme/9OkvN/src/compiler.jl:6832 [inlined]
[10] thunkbase(mi::Core.MethodInstance, World::UInt64, FA::Type{…}, A::Type{…}, TT::Type, Mode::Enzyme.API.CDerivativeMode, width::Int64, ModifiedBetween::NTuple{…} where N, ReturnPrimal::Bool, ShadowInit::Bool, ABI::Type, ErrIfFuncWritten::Bool, RuntimeActivity::Bool, StrongZero::Bool, edges::Vector{…})
@ Enzyme.Compiler ~/.julia/packages/Enzyme/9OkvN/src/compiler.jl:6948
[11] thunk_generator(world::UInt64, source::Union{…}, FA::Type, A::Type, TT::Type, Mode::Enzyme.API.CDerivativeMode, Width::Int64, ModifiedBetween::NTuple{…} where N, ReturnPrimal::Bool, ShadowInit::Bool, ABI::Type, ErrIfFuncWritten::Bool, RuntimeActivity::Bool, StrongZero::Bool, self::Any, fakeworld::Any, fa::Type, a::Type, tt::Type, mode::Type, width::Type, modifiedbetween::Type, returnprimal::Type, shadowinit::Type, abi::Type, erriffuncwritten::Type, runtimeactivity::Type, strongzero::Type)
@ Enzyme.Compiler ~/.julia/packages/Enzyme/9OkvN/src/compiler.jl:7092
[12] autodiff
@ ~/.julia/packages/Enzyme/9OkvN/src/Enzyme.jl:665 [inlined]
[13] autodiff
@ ~/.julia/packages/Enzyme/9OkvN/src/Enzyme.jl:569 [inlined]
[14] pushforward(::typeof(DifferentiationInterface.shuffled_gradient), ::DifferentiationInterfaceEnzymeExt.EnzymeOneArgPushforwardPrep{…}, ::ADTypes.AutoEnzyme{…}, ::Vector{…}, ::Tuple{…}, ::DifferentiationInterface.FunctionContext{…}, ::DifferentiationInterface.Constant{…}, ::DifferentiationInterface.Constant{…})
@ DifferentiationInterfaceEnzymeExt ~/.julia/packages/DifferentiationInterface/IS0Dg/ext/DifferentiationInterfaceEnzymeExt/forward_onearg.jl:76
[15] hvp
@ ~/.julia/packages/DifferentiationInterface/IS0Dg/src/second_order/hvp.jl:331 [inlined]
[16] _logdensity_hvp_prepared
@ ~/jl/ParallelMCMC.jl/src/DEER/DEER.jl:166 [inlined]
[17] #12
@ ~/jl/ParallelMCMC.jl/src/interface.jl:396 [inlined]
[18] mala_step_taped_and_jvp!(x_next::Vector{…}, jvp_out::Vector{…}, ws::ParallelMCMC.MALA.MALAWorkspace{…}, logp::ParallelMCMC.LogDensityProblemPrimal{…}, gradlogp::ParallelMCMC.LogDensityProblemGradient{…}, x::Vector{…}, ε::Float64, ξ::SubArray{…}, u::Float64, v::Vector{…}, hvp_fn::ParallelMCMC.var"#12#18"{…}; cholM::Nothing)
@ ParallelMCMC.MALA ~/jl/ParallelMCMC.jl/src/MALA/MALA.jl:766
[19] mala_step_taped_and_jvp!
@ ~/jl/ParallelMCMC.jl/src/MALA/MALA.jl:730 [inlined]
[20] #mala_step_taped_and_jvp#27
@ ~/jl/ParallelMCMC.jl/src/MALA/MALA.jl:809 [inlined]
[21] mala_step_taped_and_jvp
@ ~/jl/ParallelMCMC.jl/src/MALA/MALA.jl:795 [inlined]
[22] #15
@ ~/jl/ParallelMCMC.jl/src/interface.jl:411 [inlined]
[23] deer_update!(ws::ParallelMCMC.DEER.DEERWorkspace{…}, S_out::Matrix{…}, rec::ParallelMCMC.DEER.TapedRecursion{…}, s0_in::Vector{…}, S_in::Matrix{…}; jacobian::Symbol, damping::Float64, probes::Int64, rng::Random.TaskLocalRNG)
@ ParallelMCMC.DEER ~/jl/ParallelMCMC.jl/src/DEER/DEER.jl:336
[24] deer_update!
@ ~/jl/ParallelMCMC.jl/src/DEER/DEER.jl:275 [inlined]
[25] solve(rec::ParallelMCMC.DEER.TapedRecursion{…}, s0_in::Vector{…}; init::Nothing, tol_abs::Float64, tol_rel::Float64, maxiter::Int64, jacobian::Symbol, damping::Float64, probes::Int64, rng::Random.TaskLocalRNG, return_info::Bool, workspace::ParallelMCMC.DEER.DEERWorkspace{…}, copy_result::Bool)
@ ParallelMCMC.DEER ~/jl/ParallelMCMC.jl/src/DEER/DEER.jl:455
[26] solve
@ ~/jl/ParallelMCMC.jl/src/DEER/DEER.jl:406 [inlined]
[27] #_deer_solve_new_tape#24
@ ~/jl/ParallelMCMC.jl/src/interface.jl:512 [inlined]
[28] macro expansion
@ ~/jl/ParallelMCMC.jl/src/interface.jl:671 [inlined]
[29] (::ParallelMCMC.var"#33#34"{…})()
@ ParallelMCMC ~/.julia/packages/AbstractMCMC/C1aKp/src/logging.jl:134
[30] with_logstate(f::ParallelMCMC.var"#33#34"{…}, logstate::Base.CoreLogging.LogState)
@ Base.CoreLogging ./logging/logging.jl:526
[31] with_logger(f::Function, logger::LoggingExtras.TeeLogger{Tuple{…}})
@ Base.CoreLogging ./logging/logging.jl:637
[32] with_progresslogger(f::Function, _module::Module, logger::Base.CoreLogging.ConsoleLogger)
@ AbstractMCMC ~/.julia/packages/AbstractMCMC/C1aKp/src/logging.jl:157
[33] macro expansion
@ ~/.julia/packages/AbstractMCMC/C1aKp/src/logging.jl:133 [inlined]
[34] _sample_parallel_mala_blocks(rng::Random.TaskLocalRNG, model::DensityModel{…}, sampler::ParallelMALASampler{…}, N::Int64; initial_params::Nothing, progress::Bool, progressname::String)
@ ParallelMCMC ~/jl/ParallelMCMC.jl/src/interface.jl:667
[35] _sample_parallel_mala_blocks
@ ~/jl/ParallelMCMC.jl/src/interface.jl:645 [inlined]
[36] #mcmcsample#36
@ ~/jl/ParallelMCMC.jl/src/interface.jl:778 [inlined]
[37] mcmcsample
@ ~/jl/ParallelMCMC.jl/src/interface.jl:720 [inlined]
[38] #sample#21
@ ~/.julia/packages/AbstractMCMC/C1aKp/src/sample.jl:61 [inlined]
[39] sample
@ ~/.julia/packages/AbstractMCMC/C1aKp/src/sample.jl:54 [inlined]
[40] #sample#20
@ ~/.julia/packages/AbstractMCMC/C1aKp/src/sample.jl:23 [inlined]
[41] sample(model_or_logdensity::DensityModel{…}, sampler::ParallelMALASampler{…}, N_or_isdone::Int64)
@ AbstractMCMC ~/.julia/packages/AbstractMCMC/C1aKp/src/sample.jl:20
[42] top-level scope
@ REPL[20]:1
Some type information was truncated. Use `show(err)` to see complete types.
=#
Dirichlet fails with a different error
@model f3() = x ~ Dirichlet(ones(3))
sample(DensityModel(f3()), sampler, 500)
#=
ERROR: BoundsError: attempt to access 1-element Vector{LLVM.LLVMType} at index [2]
Stacktrace:
[1] throw_boundserror(A::Vector{LLVM.LLVMType}, I::Tuple{Int64})
@ Base ./essentials.jl:14
[2] getindex
@ ./essentials.jl:916 [inlined]
[3] handle_param(args::Vector{…}, codegen_types::Vector{…}, source_typ::Type, rooted_typ::Union{…}, source_i::Int64, orig_i::Int64, arg_jl_i::Int64, codegen_i::Int64, last_cc::GPUCompiler.ArgumentCC, parmsRemoved::Vector{…})
@ Enzyme.Compiler ~/.julia/packages/Enzyme/9OkvN/src/typeutils/jltypes.jl:180
[4] classify_arguments(source_sig::Type, codegen_ft::LLVM.FunctionType, has_sret::Bool, has_returnroots::Bool, has_swiftself::Bool, parmsRemoved::Vector{…}, mi::Core.MethodInstance, world::UInt64)
@ Enzyme.Compiler ~/.julia/packages/Enzyme/9OkvN/src/typeutils/jltypes.jl:303
[5] set_module_types!(interp::Enzyme.Compiler.Interpreter.EnzymeInterpreter{…}, mod::LLVM.Module, primalf::LLVM.Function, job::GPUCompiler.CompilerJob{…}, edges::Vector{…}, run_enzyme::Bool, mode::Enzyme.API.CDerivativeMode)
@ Enzyme.Compiler ~/.julia/packages/Enzyme/9OkvN/src/compiler.jl:1153
[6] compile_unhooked(output::Symbol, job::GPUCompiler.CompilerJob{…})
@ Enzyme.Compiler ~/.julia/packages/Enzyme/9OkvN/src/compiler.jl:5344
[7] #compile#163
@ ~/.julia/packages/GPUCompiler/Yuvf5/src/driver.jl:67 [inlined]
[8] compile
@ ~/.julia/packages/GPUCompiler/Yuvf5/src/driver.jl:55 [inlined]
[9] _thunk(job::GPUCompiler.CompilerJob{…}, postopt::Bool)
@ Enzyme.Compiler ~/.julia/packages/Enzyme/9OkvN/src/compiler.jl:6776
[10] _thunk
@ ~/.julia/packages/Enzyme/9OkvN/src/compiler.jl:6774 [inlined]
[11] cached_compilation
@ ~/.julia/packages/Enzyme/9OkvN/src/compiler.jl:6832 [inlined]
[12] thunkbase(mi::Core.MethodInstance, World::UInt64, FA::Type{…}, A::Type{…}, TT::Type, Mode::Enzyme.API.CDerivativeMode, width::Int64, ModifiedBetween::NTuple{…} where N, ReturnPrimal::Bool, ShadowInit::Bool, ABI::Type, ErrIfFuncWritten::Bool, RuntimeActivity::Bool, StrongZero::Bool, edges::Vector{…})
@ Enzyme.Compiler ~/.julia/packages/Enzyme/9OkvN/src/compiler.jl:6948
[13] thunk_generator(world::UInt64, source::Union{…}, FA::Type, A::Type, TT::Type, Mode::Enzyme.API.CDerivativeMode, Width::Int64, ModifiedBetween::NTuple{…} where N, ReturnPrimal::Bool, ShadowInit::Bool, ABI::Type, ErrIfFuncWritten::Bool, RuntimeActivity::Bool, StrongZero::Bool, self::Any, fakeworld::Any, fa::Type, a::Type, tt::Type, mode::Type, width::Type, modifiedbetween::Type, returnprimal::Type, shadowinit::Type, abi::Type, erriffuncwritten::Type, runtimeactivity::Type, strongzero::Type)
@ Enzyme.Compiler ~/.julia/packages/Enzyme/9OkvN/src/compiler.jl:7092
[14] autodiff
@ ~/.julia/packages/Enzyme/9OkvN/src/Enzyme.jl:665 [inlined]
[15] autodiff
@ ~/.julia/packages/Enzyme/9OkvN/src/Enzyme.jl:569 [inlined]
[16] pushforward(::typeof(DifferentiationInterface.shuffled_gradient), ::DifferentiationInterfaceEnzymeExt.EnzymeOneArgPushforwardPrep{…}, ::ADTypes.AutoEnzyme{…}, ::Vector{…}, ::Tuple{…}, ::DifferentiationInterface.FunctionContext{…}, ::DifferentiationInterface.Constant{…}, ::DifferentiationInterface.Constant{…})
@ DifferentiationInterfaceEnzymeExt ~/.julia/packages/DifferentiationInterface/IS0Dg/ext/DifferentiationInterfaceEnzymeExt/forward_onearg.jl:76
[17] hvp
@ ~/.julia/packages/DifferentiationInterface/IS0Dg/src/second_order/hvp.jl:331 [inlined]
[18] _logdensity_hvp_prepared
@ ~/jl/ParallelMCMC.jl/src/DEER/DEER.jl:166 [inlined]
[19] #12
@ ~/jl/ParallelMCMC.jl/src/interface.jl:396 [inlined]
[20] mala_step_taped_and_jvp!(x_next::Vector{…}, jvp_out::Vector{…}, ws::ParallelMCMC.MALA.MALAWorkspace{…}, logp::ParallelMCMC.LogDensityProblemPrimal{…}, gradlogp::ParallelMCMC.LogDensityProblemGradient{…}, x::Vector{…}, ε::Float64, ξ::SubArray{…}, u::Float64, v::Vector{…}, hvp_fn::ParallelMCMC.var"#12#18"{…}; cholM::Nothing)
@ ParallelMCMC.MALA ~/jl/ParallelMCMC.jl/src/MALA/MALA.jl:766
[21] mala_step_taped_and_jvp!
@ ~/jl/ParallelMCMC.jl/src/MALA/MALA.jl:730 [inlined]
[22] #mala_step_taped_and_jvp#27
@ ~/jl/ParallelMCMC.jl/src/MALA/MALA.jl:809 [inlined]
[23] mala_step_taped_and_jvp
@ ~/jl/ParallelMCMC.jl/src/MALA/MALA.jl:795 [inlined]
[24] #15
@ ~/jl/ParallelMCMC.jl/src/interface.jl:411 [inlined]
[25] deer_update!(ws::ParallelMCMC.DEER.DEERWorkspace{…}, S_out::Matrix{…}, rec::ParallelMCMC.DEER.TapedRecursion{…}, s0_in::Vector{…}, S_in::Matrix{…}; jacobian::Symbol, damping::Float64, probes::Int64, rng::Random.TaskLocalRNG)
@ ParallelMCMC.DEER ~/jl/ParallelMCMC.jl/src/DEER/DEER.jl:336
[26] deer_update!
@ ~/jl/ParallelMCMC.jl/src/DEER/DEER.jl:275 [inlined]
[27] solve(rec::ParallelMCMC.DEER.TapedRecursion{…}, s0_in::Vector{…}; init::Nothing, tol_abs::Float64, tol_rel::Float64, maxiter::Int64, jacobian::Symbol, damping::Float64, probes::Int64, rng::Random.TaskLocalRNG, return_info::Bool, workspace::ParallelMCMC.DEER.DEERWorkspace{…}, copy_result::Bool)
@ ParallelMCMC.DEER ~/jl/ParallelMCMC.jl/src/DEER/DEER.jl:455
[28] solve
@ ~/jl/ParallelMCMC.jl/src/DEER/DEER.jl:406 [inlined]
[29] #_deer_solve_new_tape#24
@ ~/jl/ParallelMCMC.jl/src/interface.jl:512 [inlined]
[30] macro expansion
@ ~/jl/ParallelMCMC.jl/src/interface.jl:671 [inlined]
[31] (::ParallelMCMC.var"#33#34"{…})()
@ ParallelMCMC ~/.julia/packages/AbstractMCMC/C1aKp/src/logging.jl:134
[32] with_logstate(f::ParallelMCMC.var"#33#34"{…}, logstate::Base.CoreLogging.LogState)
@ Base.CoreLogging ./logging/logging.jl:526
[33] with_logger(f::Function, logger::LoggingExtras.TeeLogger{Tuple{…}})
@ Base.CoreLogging ./logging/logging.jl:637
[34] with_progresslogger(f::Function, _module::Module, logger::Base.CoreLogging.ConsoleLogger)
@ AbstractMCMC ~/.julia/packages/AbstractMCMC/C1aKp/src/logging.jl:157
[35] macro expansion
@ ~/.julia/packages/AbstractMCMC/C1aKp/src/logging.jl:133 [inlined]
[36] _sample_parallel_mala_blocks(rng::Random.TaskLocalRNG, model::DensityModel{…}, sampler::ParallelMALASampler{…}, N::Int64; initial_params::Nothing, progress::Bool, progressname::String)
@ ParallelMCMC ~/jl/ParallelMCMC.jl/src/interface.jl:667
[37] _sample_parallel_mala_blocks
@ ~/jl/ParallelMCMC.jl/src/interface.jl:645 [inlined]
[38] #mcmcsample#36
@ ~/jl/ParallelMCMC.jl/src/interface.jl:778 [inlined]
[39] mcmcsample
@ ~/jl/ParallelMCMC.jl/src/interface.jl:720 [inlined]
[40] #sample#21
@ ~/.julia/packages/AbstractMCMC/C1aKp/src/sample.jl:61 [inlined]
[41] sample
@ ~/.julia/packages/AbstractMCMC/C1aKp/src/sample.jl:54 [inlined]
[42] #sample#20
@ ~/.julia/packages/AbstractMCMC/C1aKp/src/sample.jl:23 [inlined]
[43] sample(model_or_logdensity::DensityModel{…}, sampler::ParallelMALASampler{…}, N_or_isdone::Int64)
@ AbstractMCMC ~/.julia/packages/AbstractMCMC/C1aKp/src/sample.jl:20
[44] top-level scope
@ REPL[28]:1
Some type information was truncated. Use `show(err)` to see complete types.
=#
Following up from #20 (comment).
I think both errors look most likely to be genuine Enzyme bugs (there's a possibility it could be a DI thing but I don't suspect that at first glance). I'm not super surprised, we've never really tested anything beyond just gradients so there are definitely more bugs out there to be squished :-)
With Enzyme bugs traditionally what I've done is to try to minimise them to strip away all the extra bits. For example, I'm fairly sure this can probably be stripped down to something that calls hvp on a function that calls
logpdf(dist, x). I'd be happy to help with that (at some point in time).Setup
I'm running this with the code currently on #20 (my fork), but I get the same results with current main (ed83efc).
NormalworksMvNormalfailsDirichletfails with a different error