[DynamicPPL] attempt to link a linked vi

I am getting this warning multiple times and the NUTS sampler doesn’t terminate. Can you please explain what is happening for an end user of Turing.jl? The warning message is not very helpful.

How can I further debug this issue? Is there a method in Turing.jl to debug whenever something goes wrong with a particular subset of samples?

2 Likes

Can you please provide a MWE of your model ?

I will try to come back to this issue, it is been 2 months…

Hi. Because I also stumbled upon such an issue I investigated a bit my model and I managed to narrow it down to:

"""
data : `Vector` of data
len: length of data (for prior analyisis)
"""
@model function attemptlinkedvi(data, len=missing)
	if data === missing
		data = Vector{Int}(undef, len)
	end
	μ = 100
	σ = 100

	prior ~ truncated(Normal(μ,σ),0,Inf)
	data ~ filldist(Exponential(prior), 20)
end

This model fits the data fine.
If I substitute σ = 100 with σ = Exponential(100) and then I get unending complaints about attempting to link a linked vi.
In both cases sampling the prior without respect to data works fine.

Warnings
┌ Warning: The current proposal will be rejected due to numerical error(s).
│   isfinite.((θ, r, ℓπ, ℓκ)) = (true, true, false, true)
└ @ AdvancedHMC ~/.julia/packages/AdvancedHMC/iWHPQ/src/hamiltonian.jl:47
┌ Warning: [DynamicPPL] attempt to link a linked vi
└ @ DynamicPPL ~/.julia/packages/DynamicPPL/zPOYL/src/varinfo.jl:821
┌ Warning: [DynamicPPL] attempt to link a linked vi
└ @ DynamicPPL ~/.julia/packages/DynamicPPL/zPOYL/src/varinfo.jl:821
┌ Warning: The current proposal will be rejected due to numerical error(s).
│   isfinite.((θ, r, ℓπ, ℓκ)) = (true, true, false, true)
└ @ AdvancedHMC ~/.julia/packages/AdvancedHMC/iWHPQ/src/hamiltonian.jl:47
┌ Warning: [DynamicPPL] attempt to link a linked vi
└ @ DynamicPPL ~/.julia/packages/DynamicPPL/zPOYL/src/varinfo.jl:821
┌ Warning: [DynamicPPL] attempt to link a linked vi
└ @ DynamicPPL ~/.julia/packages/DynamicPPL/zPOYL/src/varinfo.jl:821
┌ Warning: The current proposal will be rejected due to numerical error(s).
│   isfinite.((θ, r, ℓπ, ℓκ)) = (true, true, false, true)
└ @ AdvancedHMC ~/.julia/packages/AdvancedHMC/iWHPQ/src/hamiltonian.jl:47
┌ Warning: [DynamicPPL] attempt to link a linked vi
└ @ DynamicPPL ~/.julia/packages/DynamicPPL/zPOYL/src/varinfo.jl:821
┌ Warning: [DynamicPPL] attempt to link a linked vi
└ @ DynamicPPL ~/.julia/packages/DynamicPPL/zPOYL/src/varinfo.jl:821
┌ Warning: The current proposal will be rejected due to numerical error(s).
│   isfinite.((θ, r, ℓπ, ℓκ)) = (true, true, false, true)
└ @ AdvancedHMC ~/.julia/packages/AdvancedHMC/iWHPQ/src/hamiltonian.jl:47

I figured that it may be due to the truncated, i.e. MCMC samples the whole Normal and if the samplings are outside what the truncated requires it rejects the proposal.
So I substituted the truncated(Normal) with a strictly positive distribution Gamma, i.e. :

@model function attemptlinkedvi(data, len=missing)
	if data === missing
		data = Vector{Int}(undef, len)
	end
	μ = 100
	σ ~ Exponential(100)

	prior ~ Gamma(μ/σ, σ)
	data ~ filldist(Exponential(prior), 20)
end

and it fits nicely !

Still I am not sure if my hypothesis was correct, but this certainly suggests that sampling truncated distributions comes with some pitfalls.

@juliohm Can you remember if you also had similar truncated distributions in your model maybe ?

It would be nice to have an opinion of a Turing developer.

Thank you @filchristou for the follow up. In the model I was developing there are no truncated distributions. I only had Normal and LogitNormal distributions.