Repository navigation
Unbound GlobalRef not allowed in value position #211
Copy link
Copy link
Closed
Description
Reporting here because I assume it's a Libtask bug, and that there's a Turing-free MWE which I don't have time to find right now.
Fails with Turing 0.41.3, AdvancedPS 0.7.0, Libtask 0.9.10.
using Turing
N = 60
K = 2
D = 2
w = [0.5, 0.5]
μ0 = [-3.5 +0.5; +3.5 -0.5]
μ1 = [0.0 0.0; 0.0 0.0]
@model function bayesianMixtureModel(x)
k = Vector{Int64}(undef, N)
μ = Array{Float64}(undef, (D, K))
for k in 1:K
μ[:, k] ~ MvNormal(μ1[:, k], 2.0 .* I)
end
end
mixtureModel0 = MixtureModel([MvNormal(μ0[:, k], I) for k in 1:K], w)
x = rand(mixtureModel0, N)
model = bayesianMixtureModel(x)
spl = PG(10)
chains = sample(model, spl, 100)julia> chains = sample(model, spl, 100)
Unbound GlobalRef not allowed in value position
Sampling 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| Time: 0:00:05
ERROR:
Stacktrace:
[1] error(s::String)
@ Core.Compiler ./error.jl:35
[2] check_op(ir::Core.Compiler.IRCode, domtree::Core.Compiler.GenericDomTree{…}, op::Any, use_bb::Int64, use_idx::Int64, printed_use_idx::Int64, print::Bool, isforeigncall::Bool, arg_idx::Int64, allow_frontend_forms::Bool)
@ Core.Compiler ./compiler/ssair/verify.jl:61
[3] verify_ir(ir::Core.Compiler.IRCode, print::Bool, allow_frontend_forms::Bool, 𝕃ₒ::Core.Compiler.PartialsLattice{Core.Compiler.ConstsLattice})
@ Core.Compiler ./compiler/ssair/verify.jl:393
[4] verify_ir
@ ./compiler/ssair/verify.jl:98 [inlined]
[5] optimise_ir!(ir::Core.Compiler.IRCode; show_ir::Bool, do_inline::Bool)
@ Libtask ~/.julia/packages/Libtask/AGx8L/src/utils.jl:46
[6] optimise_ir!
@ ~/.julia/packages/Libtask/AGx8L/src/utils.jl:40 [inlined]
[7] build_callable(sig::Type{Tuple{typeof(bayesianMixtureModel), DynamicPPL.Model{…}, DynamicPPL.VarInfo{…}, Matrix{…}}})
@ Libtask ~/.julia/packages/Libtask/AGx8L/src/copyable_task.jl:98
[8] Libtask.TapedTask(::AdvancedPSLibtaskExt.TapedGlobals{AdvancedPS.TracedRNG{UInt64, 1, Random123.Philox2x{UInt64, 10}}}, ::Function, ::Vararg{Any}; kwargs::@Kwargs{})
@ Libtask ~/.julia/packages/Libtask/AGx8L/src/copyable_task.jl:313
[9] Libtask.TapedTask(::AdvancedPSLibtaskExt.TapedGlobals{AdvancedPS.TracedRNG{UInt64, 1, Random123.Philox2x{UInt64, 10}}}, ::Function, ::Vararg{Any})
@ Libtask ~/.julia/packages/Libtask/AGx8L/src/copyable_task.jl:303
[10] #TapedTask#69
@ ~/ppl/lib/src/mcmc/particle_mcmc.jl:54 [inlined]
[11] TapedTask
@ ~/ppl/lib/src/mcmc/particle_mcmc.jl:53 [inlined]
[12] AdvancedPS.LibtaskModel(::Turing.Inference.TracedModel{DynamicPPL.VarInfo{…}, DynamicPPL.Model{…}, Tuple{…}}, ::AdvancedPS.TracedRNG{UInt64, 1, Random123.Philox2x{…}})
@ AdvancedPSLibtaskExt ~/.julia/packages/AdvancedPS/mkUwY/ext/AdvancedPSLibtaskExt.jl:38
[13] AdvancedPS.Trace(::Turing.Inference.TracedModel{DynamicPPL.VarInfo{…}, DynamicPPL.Model{…}, Tuple{…}}, ::AdvancedPS.TracedRNG{UInt64, 1, Random123.Philox2x{…}})
@ AdvancedPSLibtaskExt ~/.julia/packages/AdvancedPS/mkUwY/ext/AdvancedPSLibtaskExt.jl:84
[14] AdvancedPS.Trace(model::DynamicPPL.Model{…}, varinfo::DynamicPPL.VarInfo{…}, rng::AdvancedPS.TracedRNG{…}, resample::Bool)
@ Turing.Inference ~/ppl/lib/src/mcmc/particle_mcmc.jl:454
[15] (::Turing.Inference.var"#78#79"{DynamicPPL.Model{…}, DynamicPPL.VarInfo{…}})(::Int64)
@ Turing.Inference ./none:0
[16] iterate
@ ./generator.jl:48 [inlined]
[17] collect(itr::Base.Generator{UnitRange{Int64}, Turing.Inference.var"#78#79"{DynamicPPL.Model{…}, DynamicPPL.VarInfo{…}}})
@ Base ./array.jl:791
[18] initialstep(rng::Random.TaskLocalRNG, model::DynamicPPL.Model{…}, spl::PG{…}, vi::DynamicPPL.VarInfo{…}; kwargs::@Kwargs{…})
@ Turing.Inference ~/ppl/lib/src/mcmc/particle_mcmc.jl:264
[19] step(rng::Random.TaskLocalRNG, model::DynamicPPL.Model{…}, spl::PG{…}; initial_params::InitFromPrior, kwargs::@Kwargs{})
@ Turing.Inference ~/ppl/lib/src/mcmc/abstractmcmc.jl:180
[20] step
@ ~/ppl/lib/src/mcmc/abstractmcmc.jl:162 [inlined]
[21] macro expansion
@ ~/.julia/packages/AbstractMCMC/mcqES/src/sample.jl:188 [inlined]
[22] (::AbstractMCMC.var"#29#30"{Nothing, Int64, Int64, Int64, UnionAll, Nothing, @Kwargs{…}, Random.TaskLocalRNG, DynamicPPL.Model{…}, PG{…}, Int64, Float64, Int64, Int64})()
@ AbstractMCMC ~/.julia/packages/AbstractMCMC/mcqES/src/logging.jl:134
[23] with_logstate(f::AbstractMCMC.var"#29#30"{…}, logstate::Base.CoreLogging.LogState)
@ Base.CoreLogging ./logging/logging.jl:524
[24] with_logger(f::Function, logger::LoggingExtras.TeeLogger{Tuple{LoggingExtras.EarlyFilteredLogger{…}, LoggingExtras.EarlyFilteredLogger{…}}})
@ Base.CoreLogging ./logging/logging.jl:635
[25] with_progresslogger(f::Function, _module::Module, logger::Base.CoreLogging.ConsoleLogger)
@ AbstractMCMC ~/.julia/packages/AbstractMCMC/mcqES/src/logging.jl:157
[26] macro expansion
@ ~/.julia/packages/AbstractMCMC/mcqES/src/logging.jl:133 [inlined]
[27] mcmcsample(rng::Random.TaskLocalRNG, model::DynamicPPL.Model{…}, sampler::PG{…}, N::Int64; progress::Bool, progressname::String, callback::Nothing, num_warmup::Int64, discard_initial::Int64, thinning::Int64, chain_type::Type, initial_state::Nothing, kwargs::@Kwargs{…})
@ AbstractMCMC ~/.julia/packages/AbstractMCMC/mcqES/src/sample.jl:168
[28] sample(rng::Random.TaskLocalRNG, model::DynamicPPL.Model{…}, spl::PG{…}, N::Int64; initial_params::InitFromPrior, check_model::Bool, chain_type::Type, kwargs::@Kwargs{})
@ Turing.Inference ~/ppl/lib/src/mcmc/abstractmcmc.jl:85
[29] sample
@ ~/ppl/lib/src/mcmc/abstractmcmc.jl:74 [inlined]
[30] #sample#1
@ ~/ppl/lib/src/mcmc/abstractmcmc.jl:71 [inlined]
[31] sample(model::DynamicPPL.Model{typeof(bayesianMixtureModel), (:x,), (), (), Tuple{…}, Tuple{}, DynamicPPL.DefaultContext}, spl::PG{AdvancedPS.ResampleWithESSThreshold{…}}, N::Int64)
@ Turing.Inference ~/ppl/lib/src/mcmc/abstractmcmc.jl:68
[32] top-level scope
@ REPL[13]:1
Some type information was truncated. Use `show(err)` to see complete types.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
penelopeysm commentedon Mar 18, 2026
Still reproducible on Turing 0.43.2, Libtask v0.9.14
penelopeysm commentedon Mar 18, 2026
Stupendously, Claude minimised this in about 2 minutes