theogf / ThermodynamicIntegration.jl

Thermodynamic Integration for Turing models and more
MIT License
13 stars 1 forks source link

running multiple ThermInt algorithms in multiple threads causes DomainError #13

Closed imLew closed 2 years ago

imLew commented 3 years ago

Not sure if it makes sense to post the whole stack trace here. The end result is:

ERROR: TaskFailedException:
DomainError with -1.0:
log will only return a complex result if called with a complex argument. Try log(Complex(x)).

To reproduce start a julia REPL with --threads 2 and run

using Distributions
using ThermodynamicIntegration

function do_therm_int()
    prior = MvNormal(ones(3))
    logprior(θ) = logpdf(prior, θ)
    loglikelihood(θ) = logpdf(prior, θ)
    alg = ThermInt(n_steps=30, n_samples=3000)
    logZ = alg(logprior, loglikelihood, rand(prior))
end

Threads.@threads for i in 1:5
    do_therm_int()
end
theogf commented 3 years ago

Hmm that sounds weird. I will try to reproduce it and see what's wrong. It's probably better anyway to parallelize over the different steps of the schedule.

theogf commented 3 years ago

Ok when I run it on 1.6, I get a different error, but it seems to come from AdvancedHMC I will try to fix it.

theogf commented 2 years ago

This should be solved by #15 I think