Neuroblox / Neuroblox.jl

Other
4 stars 0 forks source link

ADVI crashes with segmentation fault #43

Closed hstrey closed 2 years ago

hstrey commented 2 years ago
using DifferentialEquations
using Turing
using Distributions
using Random
using Turing: Variational

function vanderpol(du,u,p,t)
    x1,x2 = u
    θ,ϕ = p

    du[1] = x2
    du[2] = θ*(1-x1^2)*x2 - x1
end

function add_noise(du,u,p,t)
    x1,x2 = u
    θ,ϕ = p

    du[1] = ϕ #   0 
    du[2] = ϕ
end

u0 = [0.1, 0.1]
tspan = [0.0, 20]
p = [1.0,0.1]

dt=0.1
prob1 = SDEProblem(vanderpol, add_noise, u0, tspan, p)
sol = solve(prob1,EM(),dt=dt)
time = sol.t

# add noise to the solution
x1 = sol[1,:]
x1n = x1 .+ rand(Normal(0,.3),length(x1))
x2 = sol[2,:]
x2n = x2 .+ rand(Normal(0,.3),length(x2))

@model function fitvpEMn(datax, datay)
    σ = 0.3
    θ ~ Gamma(0.25,4.0)
    ϕ ~ Uniform(0,0.2)
    # create arrays for hidden variables
    xh = zero(datax)
    yh = zero(datay)
    xh[1] = 0.1
    yh[1] = 0.1
    for i in 2:length(datax)
        dxh = yh[i-1]
        dyh = θ * (1.0 - xh[i-1]^2) * yh[i-1] - xh[i-1]
        xh[i] ~ Normal(xh[i-1] + dxh * dt,ϕ*sqrt(dt))
        yh[i] ~ Normal(yh[i-1] + dyh * dt,ϕ*sqrt(dt))
    end
    datax ~ MvNormal(xh,σ)
    datay ~ MvNormal(yh,σ)
end

model = fitvpEMn(x1n,x2n)

# ADVI
advi = ADVI(10, 1000)
q = vi(model, advi)

# sampling
z = rand(q, 1000)
avg = vec(mean(z; dims = 2))
zstd = vec(std(z; dims = 2))
chainx_advi_mean = avg[3:202]
chainy_advi_mean = avg[203:end]
chainx_advi_std = zstd[3:202]
chainy_advi_std = zstd[203:end]

this will give the following error: signal (11): Segmentation fault: 11 in expression starting at REPL[42]:1 finish_unionall at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) intersectunionall at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) intersect_unionall at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) intersect at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) intersect at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) intersect at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) intersectunionall at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) intersect_unionall at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) intersect at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) intersect_all at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) jl_type_intersection_env_s at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) ml_matches at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) jl_matching_methods at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) _methods_by_ftype at ./reflection.jl:867 [inlined]

findall#216 at ./compiler/methodtable.jl:57 [inlined]

findall##kw at ./compiler/methodtable.jl:54 jfptr_findallYY.YY.kw_13406.clone_1 at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line) jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)

218 at ./compiler/methodtable.jl:67

get! at ./iddict.jl:163 [inlined]

findall#217 at ./compiler/methodtable.jl:66 [inlined]

findall##kw at ./compiler/methodtable.jl:65 jfptr_findallYY.YY.kw_13401.clone_1 at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line) jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:84 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_apply at ./compiler/abstractinterpretation.jl:753 abstract_call_known at ./compiler/abstractinterpretation.jl:967 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call at ./compiler/abstractinterpretation.jl:1069 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1455 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_ext at ./compiler/typeinfer.jl:892 typeinf_ext_toplevel at ./compiler/typeinfer.jl:925 typeinf_ext_toplevel at ./compiler/typeinfer.jl:921 jfptr_typeinf_ext_toplevel_13611.clone_1 at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line) jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) jl_type_infer at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) jl_generate_fptr at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) jl_compile_method_internal at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)

vi#11 at /Users/hstrey/.julia/packages/Turing/rl6ku/src/variational/advi.jl:96

vi at /Users/hstrey/.julia/packages/Turing/rl6ku/src/variational/advi.jl:95 unknown function (ip: 0x1e816d1df) jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) do_call at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) eval_body at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) jl_interpret_toplevel_thunk at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) jl_toplevel_eval_flex at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) jl_toplevel_eval_flex at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) jl_toplevel_eval_in at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) eval at ./boot.jl:360 [inlined] eval_user_input at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:139 repl_backend_loop at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:200 start_repl_backend at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:185

run_repl#42 at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:317

run_repl at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:305 jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)

875 at ./client.jl:387

jfptr_YY.875_23517.clone_1 at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line) jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) jl_f__call_latest at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)

invokelatest#2 at ./essentials.jl:708 [inlined]

invokelatest at ./essentials.jl:706 [inlined] run_main_repl at ./client.jl:372 exec_options at ./client.jl:302 _start at ./client.jl:485 jfptr__start_30686.clone_1 at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line) jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) true_main at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) repl_entrypoint at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) Allocations: 307500239 (Pool: 307459010; Big: 41229); GC: 128

ChrisRackauckas commented 2 years ago

Fixed version:

using DifferentialEquations
using Turing
using Distributions
using Random
using Turing: Variational

function vanderpol(du,u,p,t)
    x1,x2 = u
    θ,ϕ = p

    du[1] = x2
    du[2] = θ*(1-x1^2)*x2 - x1
end

function add_noise(du,u,p,t)
    x1,x2 = u
    θ,ϕ = p

    du[1] = ϕ #   0
    du[2] = ϕ
end

u0 = [0.1, 0.1]
tspan = [0.0, 20]
p = [1.0,0.1]

dt=0.1
prob1 = SDEProblem(vanderpol, add_noise, u0, tspan, p)
sol = solve(prob1,EM(),dt=dt)
time = sol.t

# add noise to the solution
x1 = sol[1,:]
x1n = x1 .+ rand(Normal(0,.3),length(x1))
x2 = sol[2,:]
x2n = x2 .+ rand(Normal(0,.3),length(x2))

@model function fitvpEMn(datax, datay)
    σ = 0.3
    θ ~ Gamma(0.25,4.0)
    ϕ ~ Uniform(0,0.2)
    # create arrays for hidden variables
    xh = zero(datax)
    yh = zero(datay)
    xh[1] = 0.1
    yh[1] = 0.1
    for i in 2:length(datax)
        dxh = yh[i-1]
        dyh = θ * (1.0 - xh[i-1]^2) * yh[i-1] - xh[i-1]
        xh[i] ~ Normal(xh[i-1] + dxh * dt,ϕ*sqrt(dt))
        yh[i] ~ Normal(yh[i-1] + dyh * dt,ϕ*sqrt(dt))
    end
    datax ~ MvNormal(xh,σ)
    datay ~ MvNormal(yh,σ)
end

model = fitvpEMn(x1n,x2n)

# ADVI
Turing.setadbackend(:tracker)

advi = ADVI(10, 1000)

Turing.setadbackend(:forwarddiff)
setchunksize(8)
Turing.ADBackend()
q = vi(model, advi)

The default chunksize of 40 is insane and just straight-up crashes inference. That should get changed.

hstrey commented 2 years ago

great. Thank you. That works. Is there a reason why you use tracker and not Zygote? And why the switch between them before and after advi?

ChrisRackauckas commented 2 years ago

it's showing that it's a chunk size issue.

ChrisRackauckas commented 2 years ago

ReverseDiff compiled mode is:

Turing.setadbackend(:reversediff)
using Memoization
Turing.setrdcache(true)
advi = ADVI(10, 1000)

I'd assume that ends up the fastest.

hstrey commented 2 years ago

ReverseDiff compiled mode is:

Turing.setadbackend(:reversediff)
using Memoization
Turing.setrdcache(true)
advi = ADVI(10, 1000)

I'd assume that ends up the fastest.

I tried that combination with setchunksize(8) and it crashed

ChrisRackauckas commented 2 years ago

how did it crash?

hstrey commented 2 years ago

signal (11): Segmentation fault: 11 in expression starting at REPL[48]:1 finish_unionall at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) intersectunionall at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) intersect_unionall at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) intersect at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) intersect at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) intersect at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) intersectunionall at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) intersect_unionall at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) intersect at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) intersect_all at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) jl_type_intersection_env_s at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) ml_matches at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) jl_matching_methods at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) _methods_by_ftype at ./reflection.jl:867 [inlined]

findall#216 at ./compiler/methodtable.jl:57 [inlined]

findall##kw at ./compiler/methodtable.jl:54 jfptr_findallYY.YY.kw_13406.clone_1 at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line) jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)

218 at ./compiler/methodtable.jl:67

get! at ./iddict.jl:163 [inlined]

findall#217 at ./compiler/methodtable.jl:66 [inlined]

findall##kw at ./compiler/methodtable.jl:65 jfptr_findallYY.YY.kw_13401.clone_1 at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line) jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:84 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_apply at ./compiler/abstractinterpretation.jl:753 abstract_call_known at ./compiler/abstractinterpretation.jl:967 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call at ./compiler/abstractinterpretation.jl:1069 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1455 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call at ./compiler/abstractinterpretation.jl:1069 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1455 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_edge at ./compiler/typeinfer.jl:806 abstract_call_method at ./compiler/abstractinterpretation.jl:490 abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:143 abstract_call_known at ./compiler/abstractinterpretation.jl:1048 abstract_call at ./compiler/abstractinterpretation.jl:1071 abstract_call at ./compiler/abstractinterpretation.jl:1055 abstract_eval_statement at ./compiler/abstractinterpretation.jl:1182 typeinf_local at ./compiler/abstractinterpretation.jl:1470 typeinf_nocycle at ./compiler/abstractinterpretation.jl:1534 _typeinf at ./compiler/typeinfer.jl:214 typeinf at ./compiler/typeinfer.jl:209 typeinf_ext at ./compiler/typeinfer.jl:892 typeinf_ext_toplevel at ./compiler/typeinfer.jl:925 typeinf_ext_toplevel at ./compiler/typeinfer.jl:921 jfptr_typeinf_ext_toplevel_13611.clone_1 at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line) jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) jl_type_infer at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) jl_generate_fptr at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) jl_compile_method_internal at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)

vi#11 at /Users/hstrey/.julia/packages/Turing/rl6ku/src/variational/advi.jl:96

vi at /Users/hstrey/.julia/packages/Turing/rl6ku/src/variational/advi.jl:95 unknown function (ip: 0x1d976f5ef) jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) do_call at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) eval_body at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) jl_interpret_toplevel_thunk at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) jl_toplevel_eval_flex at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) jl_toplevel_eval_flex at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) jl_toplevel_eval_in at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) eval at ./boot.jl:360 [inlined] eval_user_input at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:139 repl_backend_loop at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:200 start_repl_backend at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:185

run_repl#42 at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:317

run_repl at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:305 jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)

875 at ./client.jl:387

jfptr_YY.875_23517.clone_1 at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line) jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) jl_f__call_latest at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)

invokelatest#2 at ./essentials.jl:708 [inlined]

invokelatest at ./essentials.jl:706 [inlined] run_main_repl at ./client.jl:372 exec_options at ./client.jl:302 _start at ./client.jl:485 jfptr__start_30686.clone_1 at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line) jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) true_main at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) repl_entrypoint at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line) Allocations: 261324802 (Pool: 261283696; Big: 41106); GC: 112

hstrey commented 2 years ago

I tried without Turing.setrdcache(true) and it still crashes

hstrey commented 2 years ago

@ChrisRackauckas I tried to run reversediff with and without compiled mode using a smaller model. Instead of 200 points I only used 20 points (20+2 parameters). ADVI now works in both cases. So it is just a matter of length.

Is there a limit for the tape? Would a computer with more memory help?

hstrey commented 2 years ago

I am closing this issue, even though we don't really have a solution.