# Error using pmap on autodiff ODE solver inside Turing @model function

**URL:** <https://discourse.julialang.org/t/error-using-pmap-on-autodiff-ode-solver-inside-turing-model-function/94449>\
**Category:** Probabilistic Programming\
**Tags:** distributed, turing, autodiff, ordinarydiffeq\
**Created:** [February 11, 2023, 12:58am UTC](https://discourse.julialang.org/t/error-using-pmap-on-autodiff-ode-solver-inside-turing-model-function/94449 "2023-02-11T00:58:24Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjmcnelis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mjmcnelis/32/46805_2.png) [@mjmcnelis](https://discourse.julialang.org/u/mjmcnelis)\
**Post date:** [February 11, 2023, 12:58am UTC](https://discourse.julialang.org/t/error-using-pmap-on-autodiff-ode-solver-inside-turing-model-function/94449/1 "2023-02-11T00:58:24Z")

</div>

Our group is interested in fitting unknown parameters in our multi-physics model using the variational inference package `AdvancedVI`. To fit the parameters, we use experimental data from multiple tests and run a dynamical simulation for each test. Since these simulations can take up to a half hour each, we would like to use the `pmap` function inside the Turing @model function to speed up the process.

The code below is a toy-model representation of the script we are using. A good chunk of it is borrowed from the [Turing.jl webpage](https://turinglang.org/v0.24/tutorials/10-bayesian-differential-equations/):

```julia
using Distributed
@everywhere using Turing, ForwardDiff, OrdinaryDiffEq, StatsPlots, 
                  AdvancedVI, LinearAlgebra, Random

@everywhere Random.seed!(1)
using Plots; plotly()

# toggle autodiff on/off in ODE solver
@everywhere autodiff = true

# toy ODE system
@everywhere function lotka_volterra(du, u, p, t)
    α, β, γ, δ = p
    x, y = u
    du[1] = (α - β*y) * x
    du[2] = (δ*x - γ) * y
    return nothing
end

# simulation output
@everywhere function gen_predict(p, jobid)
    @info "Started job $jobid"
    u0 = [1.0, 1.0]
    tspan = (0.0, 10.0)
    prob = ODEProblem(lotka_volterra, u0, tspan, p)
    sol = solve(prob, TRBDF2(; autodiff); saveat = 0.1)
    return vcat(sol.u...)
end

# note: ADVI requires @everywhere to be placed here 
@everywhere @model function fit_lv(data)
    # sampling
    σ² ~ filldist(truncated(Normal(0.05, 0.0125); lower = 0, upper = 1.0), 1)
    α ~ filldist(truncated(Normal(1.5, 0.5); lower = 0.5, upper = 2.5), 1)
    β ~ filldist(truncated(Normal(1.2, 0.5); lower = 0, upper = 2), 1)
    γ ~ filldist(truncated(Normal(3.0, 0.5); lower = 1, upper = 4), 1)
    δ ~ filldist(truncated(Normal(1.0, 0.5); lower = 0, upper = 2), 1)
    p = [α[1], β[1], γ[1], δ[1]]

    # distribute simulation runs over two tests
    joblist = 1:2
    predict = pmap(jobid -> gen_predict(p, jobid), joblist)
    y_sim = vcat(predict...)
    # simulation vs experiment
    data ~ MvNormal(y_sim, σ²[1] * I)
    return nothing
end

# target parameter values
p = [1.5, 1.0, 3.0, 1.0]
# generate mock data points covering two tests
u0 = [1.0, 1.0]
tspan = (0.0, 10.0)
prob = ODEProblem(lotka_volterra, u0, tspan, p)
sol = solve(prob, TRBDF2(; autodiff); saveat = 0.1)
u = vcat(sol.u...)
data = vcat(0.9.*u..., 1.1.*u...)

# configure inference model and fit parameters
model = fit_lv(data)
advi = ADVI(1, 1000)
optimizer = Turing.Variational.TruncatedADAGrad(0.01, 1.0, 10)
@time res = vi(model, advi; optimizer)
println("\ndone")

```

Inside the @model function `fit_lv` is where we want to apply `pmap` to distribute the simulation runs over two test days while sampling the parameters serially. In the simulation function `gen_predict`, we generally use the solver `TRBDF2(autodiff = true)` with forward-mode auto-diff since our multi-physics model is stiff.

This script works fine if you run it on the main thread via `julia`. However, if you run it with `julia -p 2` you get the following error on the `solve` line once `ADVI` is activated (Julia version is 1.8.5)

```julia
julia> include("sample_turing.jl")
┌ Info: [ADVI] Should only be seen once: optimizer created for θ
└ objectid(θ) = 0x914e03f08498020d
ERROR: LoadError: On worker 3:
First call to automatic differentiation for the Jacobian
failed. This means that the user `f` function is not compatible
with automatic differentiation. Methods to fix this include:

1. Turn off automatic differentiation (e.g. Rosenbrock23() becomes
   Rosenbrock23(autodiff=false)). More details can befound at
   https://docs.sciml.ai/DiffEqDocs/stable/features/performance_overloads/
2. Improving the compatibility of `f` with ForwardDiff.jl automatic 
   differentiation (using tools like PreallocationTools.jl). More details
   can be found at https://docs.sciml.ai/DiffEqDocs/stable/basics/faq/#Autodifferentiation-and-Dual-Numbers
3. Defining analytical Jacobians. More details can be
   found at https://docs.sciml.ai/DiffEqDocs/stable/types/ode_types/#SciMLBase.ODEFunction

Note: turning off automatic differentiation tends to have a very minimal
performance impact (for this use case, because it's forward mode for a
square Jacobian. This is different from optimization gradient scenarios).
However, one should be careful as some methods are more sensitive to
accurate gradients than others. Specifically, Rodas methods like `Rodas4`
and `Rodas5P` require accurate Jacobians in order to have good convergence,
while many other methods like BDF (`QNDF`, `FBDF`), SDIRK (`KenCarp4`),
and Rosenbrock-W (`Rosenbrock23`) do not. Thus if using an algorithm which
is sensitive to autodiff and solving at a low tolerance, please change the
algorithm as well.

"No matching function wrapper was found!"
Stacktrace:
  [1] jacobian!
    @ ~/.julia/packages/OrdinaryDiffEq/CWSFV/src/derivative_wrappers.jl:230
  [2] calc_J!
    @ ~/.julia/packages/OrdinaryDiffEq/CWSFV/src/derivative_utils.jl:144 [inlined]
  [3] calc_W!
    @ ~/.julia/packages/OrdinaryDiffEq/CWSFV/src/derivative_utils.jl:691
  [4] update_W!
    @ ~/.julia/packages/OrdinaryDiffEq/CWSFV/src/derivative_utils.jl:799 [inlined]
  [5] update_W!
    @ ~/.julia/packages/OrdinaryDiffEq/CWSFV/src/derivative_utils.jl:798 [inlined]
  [6] nlsolve!
    @ ~/.julia/packages/OrdinaryDiffEq/CWSFV/src/nlsolve/nlsolve.jl:25
  [7] perform_step!
    @ ~/.julia/packages/OrdinaryDiffEq/CWSFV/src/perform_step/sdirk_perform_step.jl:481
  [8] perform_step!
    @ ~/.julia/packages/OrdinaryDiffEq/CWSFV/src/perform_step/sdirk_perform_step.jl:458 [inlined]
  [9] solve!
    @ ~/.julia/packages/OrdinaryDiffEq/CWSFV/src/solve.jl:520
 [10] #__solve#618
    @ ~/.julia/packages/OrdinaryDiffEq/CWSFV/src/solve.jl:6
 [11] #solve_call#22
    @ ~/.julia/packages/DiffEqBase/190F1/src/solve.jl:494 [inlined]
 [12] #solve_up#29
    @ ~/.julia/packages/DiffEqBase/190F1/src/solve.jl:915
 [13] #solve#27
    @ ~/.julia/packages/DiffEqBase/190F1/src/solve.jl:825

```

You get the same error if you used the Bayesian inference model `NUTS` with `MCMCSerial`

```julia
res = sample(model, NUTS(0.65), MCMCSerial(), 100, 1)

```

On Julia 1.7.3, you get a dimension error when performing floating point operations with dual numbers (e.g. in `lokta_volterra`). We suspect there is a dual number configuration issue when trying to use `pmap` on an auto-diff compatible solver within the Turing @model. When we set `autodiff = false`, the above code is able to run with the distributed `pmap` but we lose out on solver robustness (risking simulation crashes and potentially skewing the parameter fit)

If someone knows how to fix this bug where we can use both `pmap` and `autodiff = true`, we would greatly appreciate it!

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [February 12, 2023, 12:17pm UTC](https://discourse.julialang.org/t/error-using-pmap-on-autodiff-ode-solver-inside-turing-model-function/94449/2 "2023-02-12T12:17:33Z")

</div>

> [@mjmcnelis](#):
>
> ```julia
> "No matching function wrapper was found!"
> Stacktrace:
> [1] jacobian!
> 
> ```

How come that’s the only thing that printed? Where’s all of the type information?

---

<div class="post-metadata">

**Author:** ![mbologna](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbologna/32/52659_2.png) [@mbologna](https://discourse.julialang.org/u/mbologna)\
**Post date:** [February 13, 2023, 7:29pm UTC](https://discourse.julialang.org/t/error-using-pmap-on-autodiff-ode-solver-inside-turing-model-function/94449/3 "2023-02-13T19:29:45Z")

</div>

@ChrisRackauckas

[stacktrace.jl](https://discourse.julialang.org/uploads/short-url/pgrfH3YIyscnqxgpfURUEkVPTPZ.jl) (3.0 MB)

I threw a try-catch and got the type information. It’s quite long, so that why I’m using a file upload.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [February 14, 2023, 12:55am UTC](https://discourse.julialang.org/t/error-using-pmap-on-autodiff-ode-solver-inside-turing-model-function/94449/4 "2023-02-14T00:55:11Z")

</div>

The easy solution here is just `ODEProblem{true, SciMLBase.FullSpecialize}(lotka_volterra, u0, tspan, p)`. Did that not work when you tried it?

---

<div class="post-metadata">

**Author:** ![mjmcnelis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mjmcnelis/32/46805_2.png) [@mjmcnelis](https://discourse.julialang.org/u/mjmcnelis)\
**Post date:** [February 14, 2023, 6:34am UTC](https://discourse.julialang.org/t/error-using-pmap-on-autodiff-ode-solver-inside-turing-model-function/94449/5 "2023-02-14T06:34:33Z")

</div>

Thanks for your suggestion. We tried it but it still didn’t work. It resolves the wrapper error but then you get the floating point operation error mentioned previously (ran with `julia -p 1` and `NUTS`)

```julia
      From worker 2: [ Info: Started job 1
      From worker 2: [ Info: Started job 2
      From worker 2: [ Info: Started job 1
Sampling (Chain 1 of 1) 0%| | ETA: N/A
Sampling (Chain 1 of 1) 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████| Time: 0:00:48
ERROR: LoadError: On worker 2:
First call to automatic differentiation for the Jacobian
failed. This means that the user `f` function is not compatible
with automatic differentiation. Methods to fix this include:

1. Turn off automatic differentiation (e.g. Rosenbrock23() becomes
   Rosenbrock23(autodiff=false)). More details can befound at
   https://docs.sciml.ai/DiffEqDocs/stable/features/performance_overloads/
2. Improving the compatibility of `f` with ForwardDiff.jl automatic 
   differentiation (using tools like PreallocationTools.jl). More details
   can be found at https://docs.sciml.ai/DiffEqDocs/stable/basics/faq/#Autodifferentiation-and-Dual-Numbers
3. Defining analytical Jacobians. More details can be
   found at https://docs.sciml.ai/DiffEqDocs/stable/types/ode_types/#SciMLBase.ODEFunction

Note: turning off automatic differentiation tends to have a very minimal
performance impact (for this use case, because it's forward mode for a
square Jacobian. This is different from optimization gradient scenarios).
However, one should be careful as some methods are more sensitive to
accurate gradients than others. Specifically, Rodas methods like `Rodas4`
and `Rodas5P` require accurate Jacobians in order to have good convergence,
while many other methods like BDF (`QNDF`, `FBDF`), SDIRK (`KenCarp4`),
and Rosenbrock-W (`Rosenbrock23`) do not. Thus if using an algorithm which
is sensitive to autodiff and solving at a low tolerance, please change the
algorithm as well.

MethodError: no method matching Float64(::ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, 1})
Closest candidates are:
  (::Type{T})(::Real, ::RoundingMode) where T<:AbstractFloat at rounding.jl:200
  (::Type{T})(::T) where T<:Number at boot.jl:772
  (::Type{T})(::AbstractChar) where T<:Union{AbstractChar, Number} at char.jl:50
  ...
Stacktrace:
  [1] jacobian!
    @ ~/.julia/packages/OrdinaryDiffEq/4OfcV/src/derivative_wrappers.jl:230
  [2] calc_J!
    @ ~/.julia/packages/OrdinaryDiffEq/4OfcV/src/derivative_utils.jl:144 [inlined]
  [3] calc_W!
    @ ~/.julia/packages/OrdinaryDiffEq/4OfcV/src/derivative_utils.jl:691
  [4] update_W!
    @ ~/.julia/packages/OrdinaryDiffEq/4OfcV/src/derivative_utils.jl:799 [inlined]
  [5] update_W!
    @ ~/.julia/packages/OrdinaryDiffEq/4OfcV/src/derivative_utils.jl:798 [inlined]
  [6] nlsolve!
    @ ~/.julia/packages/OrdinaryDiffEq/4OfcV/src/nlsolve/nlsolve.jl:25
  [7] perform_step!
    @ ~/.julia/packages/OrdinaryDiffEq/4OfcV/src/perform_step/sdirk_perform_step.jl:481
  [8] perform_step!
    @ ~/.julia/packages/OrdinaryDiffEq/4OfcV/src/perform_step/sdirk_perform_step.jl:458 [inlined]
  [9] solve!
    @ ~/.julia/packages/OrdinaryDiffEq/4OfcV/src/solve.jl:520
 [10] #__solve#623
    @ ~/.julia/packages/OrdinaryDiffEq/4OfcV/src/solve.jl:6
 [11] #solve_call#22
    @ ~/.julia/packages/DiffEqBase/egmnd/src/solve.jl:494 [inlined]
 [12] #solve_up#29
    @ ~/.julia/packages/DiffEqBase/egmnd/src/solve.jl:915
 [13] #solve#27
    @ ~/.julia/packages/DiffEqBase/egmnd/src/solve.jl:825

```

I attached a more informative stack trace, which you get by running the example file with `julia -p 1`  
[stacktrace\_nuts.jl](https://discourse.julialang.org/uploads/short-url/wzBjKoNo3P3GPDMsiHoOSIb7VUw.jl) (72.5 KB)  
[example\_turing.jl](https://discourse.julialang.org/uploads/short-url/2H2rn6iW8BKfH2mBTKQFcpJFzpZ.jl) (2.4 KB)  
Here I used `NUTS` instead of `ADVI` since the tags are less cumbersome (the errors are similar)

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [February 14, 2023, 4:12pm UTC](https://discourse.julialang.org/t/error-using-pmap-on-autodiff-ode-solver-inside-turing-model-function/94449/6 "2023-02-14T16:12:26Z")

</div>

I just downloaded and ran it just fine. Are you on the latest versions of the SciML stack? `]st` and `]st -m`?

---

<div class="post-metadata">

**Author:** ![mbologna](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbologna/32/52659_2.png) [@mbologna](https://discourse.julialang.org/u/mbologna)\
**Post date:** [February 14, 2023, 8:56pm UTC](https://discourse.julialang.org/t/error-using-pmap-on-autodiff-ode-solver-inside-turing-model-function/94449/7 "2023-02-14T20:56:43Z")

</div>

I ran the above code with `julia -p 1 --project`

versioninfo()  
Julia Version 1.8.3  
Commit 0434deb161e (2022-11-14 20:14 UTC)  
Platform Info:  
OS: macOS (arm64-apple-darwin21.3.0)  
CPU: 10 × Apple M1 Max  
WORD\_SIZE: 64  
LIBM: libopenlibm  
LLVM: libLLVM-13.0.1 (ORCJIT, apple-m1)  
Threads: 8 on 8 virtual cores  
Environment:  
JULIA\_NUM\_THREADS = auto  
JULIA\_PKG\_USE\_CLI\_GIT = true

`]st`  
⌅ [b5ca4192] AdvancedVI v0.1.6  
[f6369f11] ForwardDiff v0.10.34  
[1dea7af3] OrdinaryDiffEq v6.44.0  
[91a5bcdd] Plots v1.38.5  
[f3b207a7] StatsPlots v0.15.4  
[fce5fe82] Turing v0.24.0  
[37e2e46d] LinearAlgebra  
[9a3f8284] Random

`]st -m`  
[621f4979] AbstractFFTs v1.2.1  
[80f14c24] AbstractMCMC v4.4.0  
⌅ [7a57a42e] AbstractPPL v0.5.3  
[1520ce14] AbstractTrees v0.4.4  
[79e6a3ab] Adapt v3.5.0  
[0bf59076] AdvancedHMC v0.4.2  
[5b7e9947] AdvancedMH v0.7.2  
[576499cb] AdvancedPS v0.4.3  
⌅ [b5ca4192] AdvancedVI v0.1.6  
[dce04be8] ArgCheck v2.3.0  
[ec485272] ArnoldiMethod v0.2.0  
[7d9fca2a] Arpack v0.5.4  
[4fba245c] ArrayInterface v6.0.25  
[30b0a656] ArrayInterfaceCore v0.1.29  
[6ba088a2] ArrayInterfaceGPUArrays v0.2.2  
[015c0d05] ArrayInterfaceOffsetArrays v0.1.7  
[b0d46f97] ArrayInterfaceStaticArrays v0.1.5  
[dd5226c6] ArrayInterfaceStaticArraysCore v0.1.3  
[13072b0f] AxisAlgorithms v1.0.1  
[39de3d68] AxisArrays v0.4.6  
[198e06fe] BangBang v0.3.37  
[9718e550] Baselet v0.1.1  
⌅ [76274a88] Bijectors v0.10.6  
[d1d4a3ce] BitFlags v0.1.7  
[62783981] BitTwiddlingConvenienceFunctions v0.1.5  
[2a0fbf3d] CPUSummary v0.2.2  
[49dc2e85] Calculus v0.5.1  
[082447d4] ChainRules v1.47.0  
[d360d2e6] ChainRulesCore v1.15.7  
[9e997f8a] ChangesOfVariables v0.1.5  
[fb6a15b2] CloseOpenIntervals v0.1.11  
[aaaa29a8] Clustering v0.14.3  
[944b1d66] CodecZlib v0.7.1  
[35d6a980] ColorSchemes v3.20.0  
[3da002f7] ColorTypes v0.11.4  
[c3611d14] ColorVectorSpace v0.9.10  
[5ae59095] Colors v0.12.10  
[861a8166] Combinatorics v1.0.2  
[38540f10] CommonSolve v0.2.3  
[bbf7d656] CommonSubexpressions v0.3.0  
[34da2185] Compat v4.6.0  
[a33af91c] CompositionsBase v0.1.1  
[88cd18e8] ConsoleProgressMonitor v0.1.2  
[187b0558] ConstructionBase v1.4.1  
[d38c429a] Contour v0.6.2  
[adafc99b] CpuId v0.3.1  
[a8cc5b0e] Crayons v4.1.1  
[9a962f9c] DataAPI v1.14.0  
[864edb3b] DataStructures v0.18.13  
[e2d170a0] DataValueInterfaces v1.0.0  
[e7dc6d0d] DataValues v0.4.13  
[244e2a9f] DefineSingletons v0.1.2  
[b429d917] DensityInterface v0.4.0  
[2b5f629d] DiffEqBase v6.115.4  
[163ba53b] DiffResults v1.1.0  
[b552c78f] DiffRules v1.12.2  
[b4f34e82] Distances v0.10.7  
[31c24e10] Distributions v0.25.80  
[ced4e74d] DistributionsAD v0.6.43  
[ffbed154] DocStringExtensions v0.9.3  
[fa6b7ba4] DualNumbers v0.6.8  
⌅ [366bfd00] DynamicPPL v0.21.6  
[cad2338a] EllipticalSliceSampling v1.0.0  
[4e289a0a] EnumX v1.0.4  
[d4d017d3] ExponentialUtilities v1.22.1  
[e2ba6199] ExprTools v0.1.8  
[c87230d0] FFMPEG v0.4.1  
[7a1cc6ca] FFTW v1.5.0  
[7034ab61] FastBroadcast v0.2.4  
[9aa1b823] FastClosures v0.3.2  
[29a986be] FastLapackInterface v1.2.8  
[1a297f60] FillArrays v0.13.7  
[6a86dc24] FiniteDiff v2.17.0  
[53c48c17] FixedPointNumbers v0.8.4  
[59287772] Formatting v0.4.2  
[f6369f11] ForwardDiff v0.10.34  
[069b7b12] FunctionWrappers v1.1.3  
[77dc65aa] FunctionWrappersWrappers v0.1.3  
⌅ [d9f16b24] Functors v0.3.0  
[46192b85] GPUArraysCore v0.1.3  
[28b8d3ca] GR v0.71.7  
[c145ed77] GenericSchur v0.5.3  
[86223c79] Graphs v1.8.0  
[42e2da0e] Grisu v1.0.2  
[cd3eb016] HTTP v1.7.4  
[3e5b6fbb] HostCPUFeatures v0.1.14  
[34004b35] HypergeometricFunctions v0.3.11  
[615f187c] IfElse v0.1.1  
[d25df0c9] Inflate v0.1.3  
[83e8ac13] IniFile v0.5.1  
[22cec73e] InitialValues v0.3.1  
[505f98c9] InplaceOps v0.3.0  
[a98d9a8b] Interpolations v0.14.7  
[8197267c] IntervalSets v0.7.4  
[3587e190] InverseFunctions v0.1.8  
[41ab1584] InvertedIndices v1.2.0  
[92d709cd] IrrationalConstants v0.1.1  
[c8e1da08] IterTools v1.4.0  
[42fd0dbc] IterativeSolvers v0.9.2  
[82899510] IteratorInterfaceExtensions v1.0.0  
[1019f520] JLFzf v0.1.5  
[692b3bcd] JLLWrappers v1.4.1  
[682c06a0] JSON v0.21.3  
[ef3ab10e] KLU v0.4.0  
[5ab0869b] KernelDensity v0.6.5  
[ba0b0d4f] Krylov v0.9.0  
[0b1a1467] KrylovKit v0.6.0  
[8ac3fa9e] LRUCache v1.4.0  
[b964fa9f] LaTeXStrings v1.3.0  
[23fbe1c1] Latexify v0.15.18  
[10f19ff3] LayoutPointers v0.1.13  
[50d2b5c4] Lazy v0.15.1  
[1d6d02ad] LeftChildRightSiblingTrees v0.2.0  
[6f1fad26] Libtask v0.8.5  
[d3d80556] LineSearches v7.2.0  
[7ed4a6bd] LinearSolve v1.35.0  
[6fdf6af0] LogDensityProblems v2.1.0  
[996a588d] LogDensityProblemsAD v1.2.1  
[2ab3a3ac] LogExpFunctions v0.3.21  
[e6f89c97] LoggingExtras v1.0.0  
[bdcacae8] LoopVectorization v0.12.150  
[c7f686f2] MCMCChains v5.7.1  
[be115224] MCMCDiagnosticTools v0.2.6  
[e80e1ace] MLJModelInterface v1.8.0  
[1914dd2f] MacroTools v0.5.10  
[d125e4d3] ManualMemory v0.1.8  
[dbb5928d] MappedArrays v0.4.1  
[739be429] MbedTLS v1.1.7  
[442fdcdd] Measures v0.3.2  
[128add7d] MicroCollections v0.1.3  
[e1d29d7a] Missings v1.1.0  
[46d2c3a1] MuladdMacro v0.2.4  
[6f286f6a] MultivariateStats v0.10.1  
[d41bc354] NLSolversBase v7.8.3  
[2774e3e8] NLsolve v4.5.1  
[872c559c] NNlib v0.8.18  
[77ba4419] NaNMath v1.0.1  
[86f7a689] NamedArrays v0.9.6  
[c020b1a1] NaturalSort v1.0.0  
[b8a86587] NearestNeighbors v0.4.13  
[8913a72c] NonlinearSolve v1.3.0  
[510215fc] Observables v0.5.4  
[6fe1bfb0] OffsetArrays v1.12.9  
[4d8831e6] OpenSSL v1.3.3  
[3bd65402] Optimisers v0.2.14  
[bac558e1] OrderedCollections v1.4.1  
[1dea7af3] OrdinaryDiffEq v6.44.0  
[90014a1f] PDMats v0.11.16  
[d96e819e] Parameters v0.12.3  
[69de0a69] Parsers v2.5.6  
[b98c9c47] Pipe v1.3.0  
[ccf2f8ad] PlotThemes v3.1.0  
[995b91a9] PlotUtils v1.3.4  
[91a5bcdd] Plots v1.38.5  
[f517fe37] Polyester v0.7.2  
[1d0040c9] PolyesterWeave v0.2.1  
[d236fae5] PreallocationTools v0.4.11  
[21216c6a] Preferences v1.3.0  
[08abe8d2] PrettyTables v2.2.2  
[33c8b6b6] ProgressLogging v0.1.4  
[92933f4c] ProgressMeter v1.7.2  
[1fd47b50] QuadGK v2.8.1  
[74087812] Random123 v1.6.0  
[e6cf234a] RandomNumbers v1.5.3  
[b3c3ace0] RangeArrays v0.3.2  
[c84ed2f1] Ratios v0.4.3  
[c1ae055f] RealDot v0.1.0  
[3cdcf5f2] RecipesBase v1.3.3  
[01d81517] RecipesPipeline v0.6.11  
[731186ca] RecursiveArrayTools v2.37.0  
[f2c3362d] RecursiveFactorization v0.2.18  
[189a3867] Reexport v1.2.2  
[05181044] RelocatableFolders v1.0.0  
[ae029012] Requires v1.3.0  
[79098fc4] Rmath v0.7.1  
[f2b01f46] Roots v2.0.8  
[7e49a35a] RuntimeGeneratedFunctions v0.5.5  
[94e857df] SIMDTypes v0.1.0  
[476501e8] SLEEFPirates v0.6.38  
[0bca4576] SciMLBase v1.84.1  
[e9a6253c] SciMLNLSolve v0.1.3  
[c0aeaf25] SciMLOperators v0.1.21  
[30f210dd] ScientificTypesBase v3.0.0  
[6c6a2e73] Scratch v1.1.1  
[91c51154] SentinelArrays v1.3.17  
[efcf1570] Setfield v1.1.1  
[992d4aef] Showoff v1.0.3  
[777ac1f9] SimpleBufferStream v1.1.0  
[727e6d20] SimpleNonlinearSolve v0.1.10  
[699a6c99] SimpleTraits v0.9.4  
[66db9d55] SnoopPrecompile v1.0.3  
[a2af1166] SortingAlgorithms v1.1.0  
[47a9eef4] SparseDiffTools v1.30.0  
[e56a9233] Sparspak v0.3.9  
[276daf66] SpecialFunctions v2.1.7  
[171d559e] SplittablesBase v0.1.15  
[aedffcd0] Static v0.8.3  
[90137ffa] StaticArrays v1.5.15  
[1e83bf80] StaticArraysCore v1.4.0  
[64bff920] StatisticalTraits v3.2.0  
[82ae8749] StatsAPI v1.5.0  
[2913bbd2] StatsBase v0.33.21  
[4c63d2b9] StatsFuns v1.1.1  
[f3b207a7] StatsPlots v0.15.4  
[7792a7ef] StrideArraysCore v0.4.7  
[892a3eda] StringManipulation v0.3.0  
[09ab397b] StructArrays v0.6.14  
[2efcf032] SymbolicIndexingInterface v0.2.1  
[ab02a1b2] TableOperations v1.2.0  
[3783bdb8] TableTraits v1.0.1  
[bd369af6] Tables v1.10.0  
[62fd8b95] TensorCore v0.1.1  
[5d786b92] TerminalLoggers v0.1.6  
[8290d209] ThreadingUtilities v0.5.1  
[9f7883ad] Tracker v0.2.23  
[3bb67fe8] TranscodingStreams v0.9.11  
[28d57a85] Transducers v0.4.75  
[d5829a12] TriangularSolve v0.1.19  
[410a4b4d] Tricks v0.1.6  
[fce5fe82] Turing v0.24.0  
[5c2747f8] URIs v1.4.1  
[3a884ed6] UnPack v1.0.2  
[1cfade01] UnicodeFun v0.4.1  
[41fe7b60] Unzip v0.2.0  
[3d5dd08c] VectorizationBase v0.21.58  
[19fa3120] VertexSafeGraphs v0.2.0  
[cc8bc4a8] Widgets v0.6.6  
[efce3f68] WoodburyMatrices v0.5.5  
[700de1a5] ZygoteRules v0.2.2  
⌅ [68821587] Arpack\_jll v3.5.1+1  
[6e34b625] Bzip2\_jll v1.0.8+0  
[83423d85] Cairo\_jll v1.16.1+1  
[2e619515] Expat\_jll v2.4.8+0  
[b22a6f82] FFMPEG\_jll v4.4.2+2  
[f5851436] FFTW\_jll v3.3.10+0  
[a3f928ae] Fontconfig\_jll v2.13.93+0  
[d7e528f0] FreeType2\_jll v2.10.4+0  
[559328eb] FriBidi\_jll v1.0.10+0  
[0656b61e] GLFW\_jll v3.3.8+0  
[d2c73de3] GR\_jll v0.71.7+0  
[78b55507] Gettext\_jll v0.21.0+0  
[7746bdde] Glib\_jll v2.74.0+2  
[3b182d85] Graphite2\_jll v1.3.14+0  
[2e76f6c2] HarfBuzz\_jll v2.8.1+1  
[1d5cc7b8] IntelOpenMP\_jll v2018.0.3+2  
[aacddb02] JpegTurbo\_jll v2.1.2+0  
[c1c5ebd0] LAME\_jll v3.100.1+0  
[88015f11] LERC\_jll v3.0.0+1  
[dd4b983a] LZO\_jll v2.10.1+0  
⌅ [e9f186c6] Libffi\_jll v3.2.2+1  
[d4300ac3] Libgcrypt\_jll v1.8.7+0  
[7e76a0d4] Libglvnd\_jll v1.6.0+0  
[7add5ba3] Libgpg\_error\_jll v1.42.0+0  
[94ce4f54] Libiconv\_jll v1.16.1+2  
[4b2f31a3] Libmount\_jll v2.35.0+0  
[89763e89] Libtiff\_jll v4.4.0+0  
[38a345b3] Libuuid\_jll v2.36.0+0  
[856f044c] MKL\_jll v2022.2.0+0  
[e7412a2a] Ogg\_jll v1.3.5+1  
[458c3c95] OpenSSL\_jll v1.1.20+0  
[efe28fd5] OpenSpecFun\_jll v0.5.5+0  
[91d4177d] Opus\_jll v1.3.2+0  
[30392449] Pixman\_jll v0.40.1+0  
[ea2cea3b] Qt5Base\_jll v5.15.3+2  
[f50d1b31] Rmath\_jll v0.4.0+0  
[a2964d1f] Wayland\_jll v1.21.0+0  
[2381bf8a] Wayland\_protocols\_jll v1.25.0+0  
[02c8fc9c] XML2\_jll v2.10.3+0  
[aed1982a] XSLT\_jll v1.1.34+0  
[4f6342f7] Xorg\_libX11\_jll v1.6.9+4  
[0c0b7dd1] Xorg\_libXau\_jll v1.0.9+4  
[935fb764] Xorg\_libXcursor\_jll v1.2.0+4  
[a3789734] Xorg\_libXdmcp\_jll v1.1.3+4  
[1082639a] Xorg\_libXext\_jll v1.3.4+4  
[d091e8ba] Xorg\_libXfixes\_jll v5.0.3+4  
[a51aa0fd] Xorg\_libXi\_jll v1.7.10+4  
[d1454406] Xorg\_libXinerama\_jll v1.1.4+4  
[ec84b674] Xorg\_libXrandr\_jll v1.5.2+4  
[ea2f1a96] Xorg\_libXrender\_jll v0.9.10+4  
[14d82f49] Xorg\_libpthread\_stubs\_jll v0.1.0+3  
[c7cfdc94] Xorg\_libxcb\_jll v1.13.0+3  
[cc61e674] Xorg\_libxkbfile\_jll v1.1.0+4  
[12413925] Xorg\_xcb\_util\_image\_jll v0.4.0+1  
[2def613f] Xorg\_xcb\_util\_jll v0.4.0+1  
[975044d2] Xorg\_xcb\_util\_keysyms\_jll v0.4.0+1  
[0d47668e] Xorg\_xcb\_util\_renderutil\_jll v0.3.9+1  
[c22f9ab0] Xorg\_xcb\_util\_wm\_jll v0.4.1+1  
[35661453] Xorg\_xkbcomp\_jll v1.4.2+4  
[33bec58e] Xorg\_xkeyboard\_config\_jll v2.27.0+4  
[c5fb5394] Xorg\_xtrans\_jll v1.4.0+3  
[3161d3a3] Zstd\_jll v1.5.4+0  
⌅ [214eeab7] fzf\_jll v0.29.0+0  
[a4ae2306] libaom\_jll v3.4.0+0  
[0ac62f75] libass\_jll v0.15.1+0  
[f638f0a6] libfdk\_aac\_jll v2.0.2+0  
[b53b4c65] libpng\_jll v1.6.38+0  
[f27f6e37] libvorbis\_jll v1.3.7+1  
[1270edf5] x264\_jll v2021.5.5+0  
[dfaa095f] x265\_jll v3.5.0+0  
[d8fb68d0] xkbcommon\_jll v1.4.1+0  
[0dad84c5] ArgTools v1.1.1  
[56f22d72] Artifacts  
[2a0f44e3] Base64  
[ade2ca70] Dates  
[8bb1440f] DelimitedFiles  
[8ba89e20] Distributed  
[f43a241f] Downloads v1.6.0  
[7b1f6079] FileWatching  
[9fa8497b] Future  
[b77e0a4c] InteractiveUtils  
[4af54fe1] LazyArtifacts  
[b27032c2] LibCURL v0.6.3  
[76f85450] LibGit2  
[8f399da3] Libdl  
[37e2e46d] LinearAlgebra  
[56ddb016] Logging  
[d6f4376e] Markdown  
[a63ad114] Mmap  
[ca575930] NetworkOptions v1.2.0  
[44cfe95a] Pkg v1.8.0  
[de0858da] Printf  
[3fa0cd96] REPL  
[9a3f8284] Random  
[ea8e919c] SHA v0.7.0  
[9e88b42a] Serialization  
[1a1011a3] SharedArrays  
[6462fe0b] Sockets  
[2f01184e] SparseArrays  
[10745b16] Statistics  
[4607b0f0] SuiteSparse  
[fa267f1f] TOML v1.0.0  
[a4e569a6] Tar v1.10.1  
[8dfed614] Test  
[cf7118a7] UUIDs  
[4ec0a83e] Unicode  
[e66e0078] CompilerSupportLibraries\_jll v0.5.2+0  
[deac9b47] LibCURL\_jll v7.84.0+0  
[29816b5a] LibSSH2\_jll v1.10.2+0  
[c8ffd9c3] MbedTLS\_jll v2.28.0+0  
[14a3606d] MozillaCACerts\_jll v2022.2.1  
[4536629a] OpenBLAS\_jll v0.3.20+0  
[05823500] OpenLibm\_jll v0.8.1+0  
[efcefdf7] PCRE2\_jll v10.40.0+0  
[bea87d4a] SuiteSparse\_jll v5.10.1+0  
[83775a58] Zlib\_jll v1.2.12+3  
[8e850b90] libblastrampoline\_jll v5.1.1+0  
[8e850ede] nghttp2\_jll v1.48.0+0  
[3f19e933] p7zip\_jll v17.4.0+0

This is the top of the stacktrace I get using the example\_turing.jl script using `julia -p 1 --project`:

| From worker 2: | [ Info: Started job 1 |
| --- | --- |
| From worker 2: | [ Info: Started job 2 |
| From worker 2: | [ Info: Started job 1 |
| From worker 2: | ┌ Error: MethodError(Float64, (Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}}(Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}}(0.7816855694884302,0.0,0.0,0.0,0.0,0.0),Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}}(0.7816855694884302,0.0,0.0,0.0,0.0,0.0)),), 0x000000000000820c) |
| From worker 2: | └ @ Main ~/example\_turing.jl:27 |
| From worker 2: | ┌ Error: Error |
| From worker 2: | │ exception = |
| From worker 2: | │ MethodError: no method matching Float64(::ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, 1}) |
| From worker 2: | │ Closest candidates are: |
| From worker 2: | │ (::Type{T})(::Real, !Matched::RoundingMode) where T\<:AbstractFloat at rounding.jl:200 |
| From worker 2: | │ (::Type{T})(::T) where T\<:Number at boot.jl:772 |
| From worker 2: | │ (::Type{T})(!Matched::AbstractChar) where T\<:Union{AbstractChar, Number} at char.jl:50 |
| From worker 2: | │ … |
| From worker 2: | │ Stacktrace: |
| From worker 2: | │ [1] convert |
| From worker 2: | │ @ ~/.julia/packages/ForwardDiff/QdStj/src/dual.jl:433 [inlined] |
| From worker 2: | │ [2] Dual |
| From worker 2: | │ @ ~/.julia/packages/ForwardDiff/QdStj/src/dual.jl:78 [inlined] |
| From worker 2: | │ [3] convert |
| From worker 2: | │ @ ~/.julia/packages/ForwardDiff/QdStj/src/dual.jl:435 [inlined] |
| From worker 2: | │ [4] setindex!(A::Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, 1}}, x::ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, 1}, 5}, i1::Int64) |
| From worker 2: | │ @ Base ./array.jl:966 |
| From worker 2: | │ [5] lotka\_volterra(du::Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, 1}}, u::Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, 1}}, p::Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, t::Float64) |
| From worker 2: | │ @ Main ~/example\_turing.jl:24 |
| From worker 2: | │ [6] ODEFunction |
| From worker 2: | │ @ ~/.julia/packages/SciMLBase/hLrpl/src/scimlfunctions.jl:2096 [inlined] |
| From worker 2: | │ [7] UJacobianWrapper |
| From worker 2: | │ @ ~/.julia/packages/SciMLBase/hLrpl/src/function\_wrappers.jl:15 [inlined] |
| From worker 2: | │ [8] forwarddiff\_color\_jacobian!(J::Matrix{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, f::SciMLBase.UJacobianWrapper{ODEFunction{true, SciMLBase.FullSpecialize, typeof(lotka\_volterra), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT\_OBSERVED), Nothing, Nothing}, Float64, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}}, x::Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, jac\_cache::SparseDiffTools.ForwardColorJacCache{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Vector{Vector{Tuple{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}}}, UnitRange{Int64}, Nothing}) |
| From worker 2: | │ @ SparseDiffTools ~/.julia/packages/SparseDiffTools/zGdIo/src/differentiation/compute\_jacobian\_ad.jl:377 |
| From worker 2: | │ [9] jacobian!(J::Matrix{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, f::SciMLBase.UJacobianWrapper{ODEFunction{true, SciMLBase.FullSpecialize, typeof(lotka\_volterra), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT\_OBSERVED), Nothing, Nothing}, Float64, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}}, x::Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, fx::Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, integrator::OrdinaryDiffEq.ODEIntegrator{TRBDF2{1, true, LinearSolve.GenericLUFactorization{RowMaximum}, NLNewton{Rational{Int64}, Rational{Int64}, Rational{Int64}, Rational{Int64}}, typeof(OrdinaryDiffEq.DEFAULT\_PRECS), Val{:forward}, true, nothing}, true, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Nothing, Float64, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Float64, Float64, Float64, Float64, Vector{Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}}, ODESolution{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, 2, Vector{Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}}, Nothing, Nothing, Vector{Float64}, Vector{Vector{Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}}}, ODEProblem{Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Tuple{Float64, Float64}, true, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, ODEFunction{true, SciMLBase.FullSpecialize, typeof(lotka\_volterra), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT\_OBSERVED), Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, TRBDF2{1, true, LinearSolve.GenericLUFactorization{RowMaximum}, NLNewton{Rational{Int64}, Rational{Int64}, Rational{Int64}, Rational{Int64}}, typeof(OrdinaryDiffEq.DEFAULT\_PRECS), Val{:forward}, true, nothing}, OrdinaryDiffEq.InterpolationData{ODEFunction{true, SciMLBase.FullSpecialize, typeof(lotka\_volterra), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT\_OBSERVED), Nothing, Nothing}, Vector{Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}}, Vector{Float64}, Vector{Vector{Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}}}, OrdinaryDiffEq.TRBDF2Cache{Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, OrdinaryDiffEq.TRBDF2Tableau{Float64, Float64}, OrdinaryDiffEq.NLSolver{NLNewton{Rational{Int64}, Rational{Int64}, Rational{Int64}, Rational{Int64}}, true, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Float64, Nothing, Float64, OrdinaryDiffEq.NLNewtonCache{Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Float64, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Matrix{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Matrix{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, SciMLBase.UJacobianWrapper{ODEFunction{true, SciMLBase.FullSpecialize, typeof(lotka\_volterra), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT\_OBSERVED), Nothing, Nothing}, Float64, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}}, SparseDiffTools.ForwardColorJacCache{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Vector{Vector{Tuple{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}}}, UnitRange{Int64}, Nothing}, LinearSolve.LinearCache{Matrix{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, SciMLBase.NullParameters, LinearSolve.GenericLUFactorization{RowMaximum}, LU{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, Matrix{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Vector{Int64}}, LinearSolve.InvPreconditioner{Diagonal{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}}}, Diagonal{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}}, Float64, true}}}}}, DiffEqBase.DEStats, Nothing}, ODEFunction{true, SciMLBase.FullSpecialize, typeof(lotka\_volterra), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT\_OBSERVED), Nothing, Nothing}, OrdinaryDiffEq.TRBDF2Cache{Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, OrdinaryDiffEq.TRBDF2Tableau{Float64, Float64}, OrdinaryDiffEq.NLSolver{NLNewton{Rational{Int64}, Rational{Int64}, Rational{Int64}, Rational{Int64}}, true, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Float64, Nothing, Float64, OrdinaryDiffEq.NLNewtonCache{Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Float64, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Matrix{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Matrix{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, SciMLBase.UJacobianWrapper{ODEFunction{true, SciMLBase.FullSpecialize, typeof(lotka\_volterra), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT\_OBSERVED), Nothing, Nothing}, Float64, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}}, SparseDiffTools.ForwardColorJacCache{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Vector{Vector{Tuple{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}}}, UnitRange{Int64}, Nothing}, LinearSolve.LinearCache{Matrix{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, SciMLBase.NullParameters, LinearSolve.GenericLUFactorization{RowMaximum}, LU{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, Matrix{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Vector{Int64}}, LinearSolve.InvPreconditioner{Diagonal{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}}}, Diagonal{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}}, Float64, true}}}}, OrdinaryDiffEq.DEOptions{Float64, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, Float64, Float64, PIController{Rational{Int64}}, typeof(DiffEqBase.ODE\_DEFAULT\_NORM), typeof(opnorm), Nothing, CallbackSet{Tuple{}, Tuple{}}, typeof(DiffEqBase.ODE\_DEFAULT\_ISOUTOFDOMAIN), typeof(DiffEqBase.ODE\_DEFAULT\_PROG\_MESSAGE), typeof(DiffEqBase.ODE\_DEFAULT\_UNSTABLE\_CHECK), DataStructures.BinaryHeap{Float64, DataStructures.FasterForward}, DataStructures.BinaryHeap{Float64, DataStructures.FasterForward}, Nothing, Nothing, Int64, Tuple{}, Float64, Tuple{}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, Nothing, OrdinaryDiffEq.DefaultInit}, jac\_config::SparseDiffTools.ForwardColorJacCache{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}, Vector{Vector{Tuple{ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 5}}}}, UnitRange{Int64}, Nothing}) |
| From worker 2: | │ @ OrdinaryDiffEq ~/.julia/packages/OrdinaryDiffEq/4OfcV/src/derivative\_wrappers.jl:228 |

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [February 14, 2023, 11:58pm UTC](https://discourse.julialang.org/t/error-using-pmap-on-autodiff-ode-solver-inside-turing-model-function/94449/8 "2023-02-14T23:58:34Z")

</div>

> [@mbologna](#):
>
> Julia Version 1.8.3

Do you see the issue on v1.8.5? I’ve been running it on v1.9-beta3.

---

<div class="post-metadata">

**Author:** ![mjmcnelis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mjmcnelis/32/46805_2.png) [@mjmcnelis](https://discourse.julialang.org/u/mjmcnelis)\
**Post date:** [February 15, 2023, 5:52pm UTC](https://discourse.julialang.org/t/error-using-pmap-on-autodiff-ode-solver-inside-turing-model-function/94449/10 "2023-02-15T17:52:38Z")

</div>

(remaking deleted post)

I had run the above code examples on Julia 1.8.5 to generate those error stack traces. I also installed 1.9.0-beta3 but get a similar error. This is the stack trace I get (without the extra try-catch in `example_turing.jl`)  
[stacktrace\_1\_9.jl](https://discourse.julialang.org/uploads/short-url/d9W4P4jgjTFE6Ta6tGoL2GCwCw2.jl) (36.7 KB)  
Here are my installed packages on 1.9  
[status.jl](https://discourse.julialang.org/uploads/short-url/5CT6WX5Vr1hPjeMpe9buxncCtc1.jl) (11.9 KB)

I just wanted to make sure we’re on the same page with how the file is run. The script works if you run it with `julia` but not when you use multiple processes with `julia -p <N>` (at least that’s what we’re seeing). Were you running the latter?

---

<div class="post-metadata">

**Author:** ![mbologna](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbologna/32/52659_2.png) [@mbologna](https://discourse.julialang.org/u/mbologna)\
**Post date:** [February 23, 2023, 4:53pm UTC](https://discourse.julialang.org/t/error-using-pmap-on-autodiff-ode-solver-inside-turing-model-function/94449/11 "2023-02-23T16:53:53Z")

</div>

@ChrisRackauckas yes, I still see the same issue on 1.9. I suggest you start Julia with -p 1 to get the same error as us.
