I am getting an error when trying to use MCMCthreads() for sampling. The following code works fine:
chain = sample(MSM(m, S, model),
MH(:θt => AdvancedMH.RandomWalkProposal(MvNormal(zeros(size(m,1)), tuning*Σp))),
length; init_params=m, discard_initial=burnin)
However, the following code
chain = sample(MSM(m, S, model),
MH(:θt => AdvancedMH.RandomWalkProposal(MvNormal(zeros(size(m,1)), tuning*Σp))),
MCMCThreads(), length, nchains; init_params=m, discard_initial=burnin)
gives an error “Provided initial value doesn’t match the dimension of the model”.
Before either of these are called, nchains, length, burnin and m are all defined, and are the same for both of the above calls. Also, Julia is started with julia -t 4, and the environment variable JULIA_NUM_THREADS=4 is set.
The code is from the file https://github.com/mcreel/SimulatedNeuralMoments.jl/blob/main/examples/MN/MNexample.jl
Strangely enough, the file https://github.com/mcreel/SimulatedNeuralMoments.jl/blob/main/examples/SV/SVexample.jl
contains identical code:
chain = sample(MSM(m, S, model),
MH(:θt => AdvancedMH.RandomWalkProposal(MvNormal(zeros(size(m,1)), tuning*Σp))),
MCMCThreads(), length, nchains; init_params=m, discard_initial=burnin)
# single thread
#=
chain = sample(MSM(m, S, model),
MH(:θt => AdvancedMH.RandomWalkProposal(MvNormal(zeros(3), tuning*Σp))),
length; init_params = m, discard_initial=burnin)
=#
and both of these run without problems. If anyone sees the problem, that would be much appreciated. If not, I guess I should file an issue with Turing.