SciML / DiffEqFlux.jl

Pre-built implicit layer architectures with O(1) backprop, GPUs, and stiff+non-stiff DE solvers, demonstrating scientific machine learning (SciML) and physics-informed machine learning methods
https://docs.sciml.ai/DiffEqFlux/stable
MIT License
870 stars 157 forks source link

signal (11.1): Segmentation fault in uODE #851

Closed ghost closed 1 year ago

ghost commented 1 year ago

Hi,

I am having problems running a uODE in SciML. Whenever I run my script in REPL of vscode I do not get errors.

When I run the script in the terminal with julia ./script.jl I get a segmentation fault:

Here is the script:

using OrdinaryDiffEq, ModelingToolkit, DataDrivenDiffEq, SciMLSensitivity, DataDrivenSparse
using Optimization, OptimizationOptimisers, OptimizationOptimJL

using LinearAlgebra, Statistics

using ComponentArrays, Lux, Zygote, Plots, LaTeXStrings, StableRNGs, IterTools

rng = StableRNG(1111)

function lotka!(du, u, p, t)
    α, β, γ, δ = [1.3, 0.9, 0.8, 1.8]
    du[1] = α * u[1] - β * u[2] * u[1]
    du[2] = γ * u[1] * u[2] - δ * u[2]
end

function get_train_data()
    t_true = LinRange(0.0,5.0,300)
    tspan = (0.0, 5.0)
    u0 = 5.0f0 * rand(rng, 2)
    prob = ODEProblem(lotka!, u0, tspan, zeros(4))
    solution = solve(prob, Vern7(), abstol = 1e-12, reltol = 1e-12, saveat = t_true);

    Xₙ = Array(solution);
    t = solution.t;

    data = DataLoader([vcat(Xₙ, t')], batchsize = 1)
    return data
end

train_loader = get_train_data();

rbf(x) = exp.(-(x .^ 2))

# Multilayer FeedForward
U = Lux.Chain(  Lux.Dense(6, 25, rbf), 
                Lux.Dense(25, 25, rbf), 
                Lux.Dense(25, 25, rbf),
                Lux.Dense(25, 6))

ps, st = Lux.setup(rng, U)

p_ = zeros(4)

p = ComponentArray{Float64}(p=ps, p_true=p_) 

function nn_dynamics!(du, u, p, t)
    û = U(u, p.p, st)[1] 

    du[1] = p.p_true[1] * u[1] + û[1]
    du[2] = -p.p_true[4] * u[2] + û[2]

    du[3] = p.p_true[1] * u[1] + û[3]
    du[4] = -p.p_true[4] * u[2] + û[4]

    du[5] = p.p_true[1] * u[1] + û[5]
    du[6] = -p.p_true[4] * u[2] + û[6]
end

# Define the problem
prob_nn = ODEProblem(nn_dynamics!, repeat(first(train_loader)[1][1:2,1],3), (0.0, 5.0), p)

function predict(θ, batch)
    T = batch[3, :];  

    IC = batch[1:2, 1];

    _prob = remake(prob_nn, u0 = repeat(IC,3), tspan = (T[1], T[end]), p=ComponentArray(p=θ, p_true=[1.3, 0.9, 0.8, 1.8]))

    Array(solve(_prob, AutoTsit5(Rodas5()), saveat = T,
                abstol = 1e-6, reltol = 1e-6,  verbose=false))
end

function loss(θ, batch)
    X̂ = predict(θ, batch);

    X_true = @view batch[1:2, :]; 

    mean(abs2, X_true .- X̂[1:2,:])
end

losses = Float64[]

callback = function (p, l)
    push!(losses, l)
    if length(losses) % 10 == 0
        println("Current loss after $(length(losses)) iterations: $(losses[end])")
    end
    return false
end

adtype = Optimization.AutoZygote();
optfun = Optimization.OptimizationFunction((θ, p, batch) -> loss(θ, batch), adtype); 
optprob = Optimization.OptimizationProblem(optfun, p.p);

res = Optimization.solve(  optprob,
                            ADAM(0.001), 
                            IterTools.ncycle(train_loader, 100),
                            callback = callback)

This is mock-example of the LV tutorial case, solving 3x the same equations using batches.

The solution I am getting when I run the script in the terminal julia ./myscript.jl is:

┌ Warning: Using fallback BLAS replacements, performance may be degraded
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/cy24l/src/utils.jl:56
Current loss after 10 iterations: 71953.88637127848
Current loss after 20 iterations: 42047.4531789665
Current loss after 30 iterations: 24953.907322388743
Current loss after 40 iterations: 14816.790391119554
Current loss after 50 iterations: 8173.798307112623
Current loss after 60 iterations: 3138.2214048185783
Current loss after 70 iterations: 1198.2880244383134
Current loss after 80 iterations: 619.1022424925653
Current loss after 90 iterations: 306.62778078466096
Current loss after 100 iterations: 149.59638116576286

When I run it in REPL of vscode I do not see the warning:

┌ Warning: Using fallback BLAS replacements, performance may be degraded
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/cy24l/src/utils.jl:56

However, sometimes I also get a segmentation fault when I do julia ./myscript.jl:

┌ Warning: Using fallback BLAS replacements, performance may be degraded
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/cy24l/src/utils.jl:56

[116948] signal (11.1): Segmentation fault
in expression starting at /TJ/Desktop/test/script.jl:117
gc_mark_loop at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gc.c:2819
_jl_gc_collect at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gc.c:3400
ijl_gc_collect at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gc.c:3707
maybe_collect at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gc.c:1078 [inlined]
jl_gc_pool_alloc_inner at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gc.c:1443 [inlined]
jl_gc_pool_alloc_noinline at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gc.c:1504 [inlined]
jl_gc_alloc_ at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia_internal.h:460 [inlined]
jl_gc_alloc at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gc.c:3754
jl_gc_alloc_buf at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia_internal.h:498 [inlined]
jl_gc_alloc_buf at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia_internal.h:496 [inlined]
array_resize_buffer at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/array.c:698
jl_array_grow_at_end at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/array.c:893
_growend! at ./array.jl:1014 [inlined]
resize! at ./array.jl:1249 [inlined]
copy! at ./abstractarray.jl:926
copy! at ./compiler/ssair/domtree.jl:103 [inlined]
DFS! at ./compiler/ssair/domtree.jl:113
update_domtree! at ./compiler/ssair/domtree.jl:239 [inlined]
construct_domtree at ./compiler/ssair/domtree.jl:229
get! at ./compiler/ssair/passes.jl:607 [inlined]
perform_lifting! at ./compiler/ssair/passes.jl:646
sroa_pass! at ./compiler/ssair/passes.jl:1022
run_passes at ./compiler/optimize.jl:539
run_passes at ./compiler/optimize.jl:554 [inlined]
optimize at ./compiler/optimize.jl:503 [inlined]
_typeinf at ./compiler/typeinfer.jl:273
typeinf at ./compiler/typeinfer.jl:216
typeinf_edge at ./compiler/typeinfer.jl:933
abstract_call_method at ./compiler/abstractinterpretation.jl:611
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:152
abstract_call_known at ./compiler/abstractinterpretation.jl:1949
abstract_call at ./compiler/abstractinterpretation.jl:2020
abstract_call at ./compiler/abstractinterpretation.jl:1999
abstract_eval_statement_expr at ./compiler/abstractinterpretation.jl:2183
abstract_eval_statement at ./compiler/abstractinterpretation.jl:2396
abstract_eval_basic_statement at ./compiler/abstractinterpretation.jl:2684
typeinf_local at ./compiler/abstractinterpretation.jl:2869
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2957
_typeinf at ./compiler/typeinfer.jl:246
typeinf at ./compiler/typeinfer.jl:216
typeinf_edge at ./compiler/typeinfer.jl:933
abstract_call_method at ./compiler/abstractinterpretation.jl:611
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:152
abstract_call_known at ./compiler/abstractinterpretation.jl:1949
abstract_call at ./compiler/abstractinterpretation.jl:2020
abstract_call at ./compiler/abstractinterpretation.jl:1999
abstract_eval_statement_expr at ./compiler/abstractinterpretation.jl:2183
abstract_eval_statement at ./compiler/abstractinterpretation.jl:2396
abstract_eval_basic_statement at ./compiler/abstractinterpretation.jl:2660
typeinf_local at ./compiler/abstractinterpretation.jl:2869
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2957
_typeinf at ./compiler/typeinfer.jl:246
typeinf at ./compiler/typeinfer.jl:216
typeinf_edge at ./compiler/typeinfer.jl:933
abstract_call_method at ./compiler/abstractinterpretation.jl:611
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:152
abstract_call_known at ./compiler/abstractinterpretation.jl:1949
abstract_call at ./compiler/abstractinterpretation.jl:2020
abstract_call at ./compiler/abstractinterpretation.jl:1999
abstract_eval_statement_expr at ./compiler/abstractinterpretation.jl:2183
abstract_eval_statement at ./compiler/abstractinterpretation.jl:2396
abstract_eval_basic_statement at ./compiler/abstractinterpretation.jl:2660
typeinf_local at ./compiler/abstractinterpretation.jl:2869
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2957
_typeinf at ./compiler/typeinfer.jl:246
typeinf at ./compiler/typeinfer.jl:216
typeinf_edge at ./compiler/typeinfer.jl:933
abstract_call_method at ./compiler/abstractinterpretation.jl:611
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:152
abstract_call_known at ./compiler/abstractinterpretation.jl:1949
abstract_call at ./compiler/abstractinterpretation.jl:2020
abstract_call at ./compiler/abstractinterpretation.jl:1999
abstract_eval_statement_expr at ./compiler/abstractinterpretation.jl:2183
abstract_eval_statement at ./compiler/abstractinterpretation.jl:2396
abstract_eval_basic_statement at ./compiler/abstractinterpretation.jl:2660
typeinf_local at ./compiler/abstractinterpretation.jl:2869
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2957
_typeinf at ./compiler/typeinfer.jl:246
typeinf at ./compiler/typeinfer.jl:216
typeinf_edge at ./compiler/typeinfer.jl:933
abstract_call_method at ./compiler/abstractinterpretation.jl:611
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:152
abstract_call_known at ./compiler/abstractinterpretation.jl:1949
abstract_call at ./compiler/abstractinterpretation.jl:2020
abstract_apply at ./compiler/abstractinterpretation.jl:1566
abstract_call_known at ./compiler/abstractinterpretation.jl:1855
abstract_call at ./compiler/abstractinterpretation.jl:2020
abstract_call at ./compiler/abstractinterpretation.jl:1999
abstract_eval_statement_expr at ./compiler/abstractinterpretation.jl:2183
abstract_eval_statement at ./compiler/abstractinterpretation.jl:2396
abstract_eval_basic_statement at ./compiler/abstractinterpretation.jl:2684
typeinf_local at ./compiler/abstractinterpretation.jl:2869
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2957
_typeinf at ./compiler/typeinfer.jl:246
typeinf at ./compiler/typeinfer.jl:216
typeinf_edge at ./compiler/typeinfer.jl:933
abstract_call_method at ./compiler/abstractinterpretation.jl:611
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:152
abstract_call_known at ./compiler/abstractinterpretation.jl:1949
abstract_call at ./compiler/abstractinterpretation.jl:2020
abstract_apply at ./compiler/abstractinterpretation.jl:1566
abstract_call_known at ./compiler/abstractinterpretation.jl:1855
abstract_call at ./compiler/abstractinterpretation.jl:2020
abstract_call at ./compiler/abstractinterpretation.jl:1999
abstract_eval_statement_expr at ./compiler/abstractinterpretation.jl:2183
abstract_eval_statement at ./compiler/abstractinterpretation.jl:2396
abstract_eval_basic_statement at ./compiler/abstractinterpretation.jl:2684
typeinf_local at ./compiler/abstractinterpretation.jl:2869
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2957
_typeinf at ./compiler/typeinfer.jl:246
typeinf at ./compiler/typeinfer.jl:216
typeinf_edge at ./compiler/typeinfer.jl:933
abstract_call_method at ./compiler/abstractinterpretation.jl:611
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:152
abstract_call_known at ./compiler/abstractinterpretation.jl:1949
abstract_call at ./compiler/abstractinterpretation.jl:2020
abstract_apply at ./compiler/abstractinterpretation.jl:1566
abstract_call_known at ./compiler/abstractinterpretation.jl:1855
abstract_call at ./compiler/abstractinterpretation.jl:2020
abstract_call at ./compiler/abstractinterpretation.jl:1999
abstract_eval_statement_expr at ./compiler/abstractinterpretation.jl:2183
abstract_eval_statement at ./compiler/abstractinterpretation.jl:2396
abstract_eval_basic_statement at ./compiler/abstractinterpretation.jl:2684
typeinf_local at ./compiler/abstractinterpretation.jl:2869
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2957
_typeinf at ./compiler/typeinfer.jl:246
typeinf at ./compiler/typeinfer.jl:216
typeinf_edge at ./compiler/typeinfer.jl:933
abstract_call_method at ./compiler/abstractinterpretation.jl:611
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:152
abstract_call_known at ./compiler/abstractinterpretation.jl:1949
abstract_call at ./compiler/abstractinterpretation.jl:2020
abstract_apply at ./compiler/abstractinterpretation.jl:1566
abstract_call_known at ./compiler/abstractinterpretation.jl:1855
abstract_call at ./compiler/abstractinterpretation.jl:2020
abstract_call at ./compiler/abstractinterpretation.jl:1999
abstract_eval_statement_expr at ./compiler/abstractinterpretation.jl:2183
abstract_eval_statement at ./compiler/abstractinterpretation.jl:2396
abstract_eval_basic_statement at ./compiler/abstractinterpretation.jl:2684
typeinf_local at ./compiler/abstractinterpretation.jl:2869
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2957
_typeinf at ./compiler/typeinfer.jl:246
typeinf at ./compiler/typeinfer.jl:216
typeinf_ext at ./compiler/typeinfer.jl:1058
typeinf_ext_toplevel at ./compiler/typeinfer.jl:1091
typeinf_ext_toplevel at ./compiler/typeinfer.jl:1087
jfptr_typeinf_ext_toplevel_14294.clone_1 at /TJ/Desktop/Julia/julia-1.9.0/lib/julia/sys.so (unknown line)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1879 [inlined]
jl_type_infer at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:320
jl_generate_fptr_impl at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/jitlayers.cpp:444
jl_compile_method_internal at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2348 [inlined]
jl_compile_method_internal at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2237
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2750 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_nthfield_fwd at /TJ/Desktop/.julia/packages/Enzyme/EncRR/src/compiler.jl:2322
jl_nthfield_augfwd at /TJ/Desktop/.julia/packages/Enzyme/EncRR/src/compiler.jl:2357
unknown function (ip: 0x7fead65ad9cb)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
unknown function (ip: 0x7febfc1b01e5)
unknown function (ip: 0x7febfc1affd5)
operator() at /workspace/srcdir/Enzyme/enzyme/Enzyme/CApi.cpp:267 [inlined]
_M_invoke at /opt/x86_64-linux-gnu/x86_64-linux-gnu/include/c++/8.1.0/bits/std_function.h:297
operator() at /opt/x86_64-linux-gnu/x86_64-linux-gnu/include/c++/8.1.0/bits/std_function.h:687 [inlined]
visitCallInst at /workspace/srcdir/Enzyme/enzyme/Enzyme/AdjointGenerator.h:10314
delegateCallInst at /opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/include/llvm/IR/InstVisitor.h:302 [inlined]
visitCall at /opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/include/llvm/IR/Instruction.def:209 [inlined]
visit at /opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/include/llvm/IR/Instruction.def:209
visit at /opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/include/llvm/IR/InstVisitor.h:112 [inlined]
CreateAugmentedPrimal at /workspace/srcdir/Enzyme/enzyme/Enzyme/EnzymeLogic.cpp:2237
EnzymeCreateAugmentedPrimal at /workspace/srcdir/Enzyme/enzyme/Enzyme/CApi.cpp:506
EnzymeCreateAugmentedPrimal at /TJ/Desktop/.julia/packages/Enzyme/EncRR/src/api.jl:160
enzyme! at /TJ/Desktop/.julia/packages/Enzyme/EncRR/src/compiler.jl:6640
unknown function (ip: 0x7fead65a7be9)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
#codegen#146 at /TJ/Desktop/.julia/packages/Enzyme/EncRR/src/compiler.jl:7921
codegen at /TJ/Desktop/.julia/packages/Enzyme/EncRR/src/compiler.jl:7547 [inlined]
_thunk at /TJ/Desktop/.julia/packages/Enzyme/EncRR/src/compiler.jl:8434
_thunk at /TJ/Desktop/.julia/packages/Enzyme/EncRR/src/compiler.jl:8431 [inlined]
cached_compilation at /TJ/Desktop/.julia/packages/Enzyme/EncRR/src/compiler.jl:8469 [inlined]
#s286#175 at /TJ/Desktop/.julia/packages/Enzyme/EncRR/src/compiler.jl:8527 [inlined]
#s286#175 at ./none:0
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
GeneratedFunctionStub at ./boot.jl:602
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1879 [inlined]
jl_call_staged at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/method.c:530
ijl_code_for_staged at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/method.c:581
get_staged at ./compiler/utilities.jl:115
retrieve_code_info at ./compiler/utilities.jl:127 [inlined]
InferenceState at ./compiler/inferencestate.jl:354
typeinf_edge at ./compiler/typeinfer.jl:924
abstract_call_method at ./compiler/abstractinterpretation.jl:611
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:152
abstract_call_known at ./compiler/abstractinterpretation.jl:1949
abstract_call at ./compiler/abstractinterpretation.jl:2020
abstract_call at ./compiler/abstractinterpretation.jl:1999
abstract_eval_statement_expr at ./compiler/abstractinterpretation.jl:2183
abstract_eval_statement at ./compiler/abstractinterpretation.jl:2396
abstract_eval_basic_statement at ./compiler/abstractinterpretation.jl:2684
typeinf_local at ./compiler/abstractinterpretation.jl:2869
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2957
_typeinf at ./compiler/typeinfer.jl:246
typeinf at ./compiler/typeinfer.jl:216
typeinf_edge at ./compiler/typeinfer.jl:933
abstract_call_method at ./compiler/abstractinterpretation.jl:611
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:152
abstract_call_known at ./compiler/abstractinterpretation.jl:1949
abstract_call at ./compiler/abstractinterpretation.jl:2020
abstract_call at ./compiler/abstractinterpretation.jl:1999
abstract_eval_statement_expr at ./compiler/abstractinterpretation.jl:2183
abstract_eval_statement at ./compiler/abstractinterpretation.jl:2396
abstract_eval_basic_statement at ./compiler/abstractinterpretation.jl:2684
typeinf_local at ./compiler/abstractinterpretation.jl:2869
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2957
_typeinf at ./compiler/typeinfer.jl:246
typeinf at ./compiler/typeinfer.jl:216
typeinf_ext at ./compiler/typeinfer.jl:1058
typeinf_ext_toplevel at ./compiler/typeinfer.jl:1091
typeinf_ext_toplevel at ./compiler/typeinfer.jl:1087
jfptr_typeinf_ext_toplevel_14294.clone_1 at /TJ/Desktop/Julia/julia-1.9.0/lib/julia/sys.so (unknown line)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1879 [inlined]
jl_type_infer at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:320
jl_generate_fptr_impl at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/jitlayers.cpp:444
jl_compile_method_internal at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2348 [inlined]
jl_compile_method_internal at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2237
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2750 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
unknown function (ip: 0x7feb33626e30)
unknown function (ip: 0x7feb336294d9)
unknown function (ip: 0x7fead653e1ea)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1879 [inlined]
do_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/builtins.c:730
CombinedAdjointThunk at /TJ/Desktop/.julia/packages/Enzyme/EncRR/src/compiler.jl:8045
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1879 [inlined]
do_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/builtins.c:730
autodiff at /TJ/Desktop/.julia/packages/Enzyme/EncRR/src/Enzyme.jl:205
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1879 [inlined]
do_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/builtins.c:730
autodiff at /TJ/Desktop/.julia/packages/Enzyme/EncRR/src/Enzyme.jl:228
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
autodiff at /TJ/Desktop/.julia/packages/Enzyme/EncRR/src/Enzyme.jl:214 [inlined]
inplace_vjp at /TJ/Desktop/.julia/packages/SciMLSensitivity/NhfkF/src/concrete_solve.jl:16
automatic_sensealg_choice at /TJ/Desktop/.julia/packages/SciMLSensitivity/NhfkF/src/concrete_solve.jl:159
#_concrete_solve_adjoint#267 at /TJ/Desktop/.julia/packages/SciMLSensitivity/NhfkF/src/concrete_solve.jl:206
_concrete_solve_adjoint at /TJ/Desktop/.julia/packages/SciMLSensitivity/NhfkF/src/concrete_solve.jl:195 [inlined]
#_solve_adjoint#66 at /TJ/Desktop/.julia/packages/DiffEqBase/jvL5B/src/solve.jl:1390 [inlined]
_solve_adjoint at /TJ/Desktop/.julia/packages/DiffEqBase/jvL5B/src/solve.jl:1359 [inlined]
#rrule#64 at /TJ/Desktop/.julia/packages/DiffEqBase/jvL5B/src/solve.jl:1343 [inlined]
rrule at /TJ/Desktop/.julia/packages/DiffEqBase/jvL5B/src/solve.jl:1339 [inlined]
rrule at /TJ/Desktop/.julia/packages/ChainRulesCore/0t04l/src/rules.jl:140 [inlined]
chain_rrule_kw at /TJ/Desktop/.julia/packages/Zygote/JeHtr/src/compiler/chainrules.jl:235 [inlined]
macro expansion at /TJ/Desktop/.julia/packages/Zygote/JeHtr/src/compiler/interface2.jl:101 [inlined]
_pullback at /TJ/Desktop/.julia/packages/Zygote/JeHtr/src/compiler/interface2.jl:101 [inlined]
_apply at ./boot.jl:838 [inlined]
adjoint at /TJ/Desktop/.julia/packages/Zygote/JeHtr/src/lib/lib.jl:203 [inlined]
_pullback at /TJ/Desktop/.julia/packages/ZygoteRules/OgCVT/src/adjoint.jl:66 [inlined]
_pullback at /TJ/Desktop/.julia/packages/DiffEqBase/jvL5B/src/solve.jl:882 [inlined]
_pullback at /TJ/Desktop/.julia/packages/Zygote/JeHtr/src/compiler/interface2.jl:0
unknown function (ip: 0x7fead6dea122)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1879 [inlined]
do_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/builtins.c:730
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1879 [inlined]
do_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/builtins.c:730
_apply at ./boot.jl:838
adjoint at /TJ/Desktop/.julia/packages/Zygote/JeHtr/src/lib/lib.jl:203 [inlined]
_pullback at /TJ/Desktop/.julia/packages/ZygoteRules/OgCVT/src/adjoint.jl:66 [inlined]
_pullback at /TJ/Desktop/.julia/packages/DiffEqBase/jvL5B/src/solve.jl:872 [inlined]
_pullback at /TJ/Desktop/.julia/packages/Zygote/JeHtr/src/compiler/interface2.jl:0
unknown function (ip: 0x7fead6dde612)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
_pullback at /TJ/Desktop/test/script.jl:91 [inlined]
_pullback at /TJ/Desktop/.julia/packages/Zygote/JeHtr/src/compiler/interface2.jl:0
_pullback at /TJ/Desktop/test/script.jl:96 [inlined]
_pullback at /TJ/Desktop/.julia/packages/Zygote/JeHtr/src/compiler/interface2.jl:0
_pullback at /TJ/Desktop/test/script.jl:114 [inlined]
_pullback at /TJ/Desktop/.julia/packages/Zygote/JeHtr/src/compiler/interface2.jl:0
unknown function (ip: 0x7fead6d75fdd)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1879 [inlined]
do_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/builtins.c:730
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1879 [inlined]
do_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/builtins.c:730
_apply at ./boot.jl:838
adjoint at /TJ/Desktop/.julia/packages/Zygote/JeHtr/src/lib/lib.jl:203 [inlined]
adjoint at ./none:0
unknown function (ip: 0x7fead6d728ed)
_pullback at /TJ/Desktop/.julia/packages/ZygoteRules/OgCVT/src/adjoint.jl:66 [inlined]
_pullback at /TJ/Desktop/.julia/packages/SciMLBase/kTUaf/src/scimlfunctions.jl:3628 [inlined]
_pullback at /TJ/Desktop/.julia/packages/Zygote/JeHtr/src/compiler/interface2.jl:0
unknown function (ip: 0x7fead6d7266d)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1879 [inlined]
do_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/builtins.c:730
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1879 [inlined]
do_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/builtins.c:730
_apply at ./boot.jl:838
adjoint at /TJ/Desktop/.julia/packages/Zygote/JeHtr/src/lib/lib.jl:203 [inlined]
_pullback at /TJ/Desktop/.julia/packages/ZygoteRules/OgCVT/src/adjoint.jl:66 [inlined]
_pullback at /TJ/Desktop/.julia/packages/Optimization/72eCu/ext/OptimizationZygoteExt.jl:54 [inlined]
_pullback at /TJ/Desktop/.julia/packages/Zygote/JeHtr/src/compiler/interface2.jl:0
unknown function (ip: 0x7fead6d4a052)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1879 [inlined]
do_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/builtins.c:730
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1879 [inlined]
do_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/builtins.c:730
_apply at ./boot.jl:838
adjoint at /TJ/Desktop/.julia/packages/Zygote/JeHtr/src/lib/lib.jl:203 [inlined]
_pullback at /TJ/Desktop/.julia/packages/ZygoteRules/OgCVT/src/adjoint.jl:66 [inlined]
_pullback at /TJ/Desktop/.julia/packages/Optimization/72eCu/ext/OptimizationZygoteExt.jl:58 [inlined]
_pullback at /TJ/Desktop/.julia/packages/Zygote/JeHtr/src/compiler/interface2.jl:0
unknown function (ip: 0x7fead6d484cd)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
pullback at /TJ/Desktop/.julia/packages/Zygote/JeHtr/src/compiler/interface.jl:44
pullback at /TJ/Desktop/.julia/packages/Zygote/JeHtr/src/compiler/interface.jl:42 [inlined]
gradient at /TJ/Desktop/.julia/packages/Zygote/JeHtr/src/compiler/interface.jl:96
#20 at /TJ/Desktop/.julia/packages/Optimization/72eCu/ext/OptimizationZygoteExt.jl:56
unknown function (ip: 0x7fead6d4803e)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1879 [inlined]
do_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/builtins.c:730
macro expansion at /TJ/Desktop/.julia/packages/OptimizationOptimisers/wD0eI/src/OptimizationOptimisers.jl:65 [inlined]
macro expansion at /TJ/Desktop/.julia/packages/Optimization/72eCu/src/utils.jl:37 [inlined]
__solve at /TJ/Desktop/.julia/packages/OptimizationOptimisers/wD0eI/src/OptimizationOptimisers.jl:63
solve! at /TJ/Desktop/.julia/packages/SciMLBase/kTUaf/src/solve.jl:162
unknown function (ip: 0x7fead6d04ef2)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
#solve#561 at /TJ/Desktop/.julia/packages/SciMLBase/kTUaf/src/solve.jl:83
solve at /TJ/Desktop/.julia/packages/SciMLBase/kTUaf/src/solve.jl:80
unknown function (ip: 0x7febfc1ff03e)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1879 [inlined]
do_call at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/interpreter.c:126
eval_value at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/interpreter.c:226
eval_stmt_value at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/interpreter.c:177 [inlined]
eval_body at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/interpreter.c:624
jl_interpret_toplevel_thunk at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/interpreter.c:762
jl_toplevel_eval_flex at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/toplevel.c:912
jl_toplevel_eval_flex at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/toplevel.c:856
ijl_toplevel_eval_in at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/toplevel.c:971
eval at ./boot.jl:370 [inlined]
include_string at ./loading.jl:1864
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
_include at ./loading.jl:1924
include at ./Base.jl:457
jfptr_include_43521.clone_1 at /TJ/Desktop/Julia/julia-1.9.0/lib/julia/sys.so (unknown line)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
exec_options at ./client.jl:307
_start at ./client.jl:522
jfptr__start_37386.clone_1 at /TJ/Desktop/Julia/julia-1.9.0/lib/julia/sys.so (unknown line)
_jl_invoke at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/julia.h:1879 [inlined]
true_main at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/jlapi.c:573
jl_repl_entrypoint at /cache/build/default-amdci4-0/julialang/julia-release-1-dot-9/src/jlapi.c:717
main at julia (unknown line)
unknown function (ip: 0x7fec13312d8f)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x401098)
Allocations: 221422856 (Pool: 221336709; Big: 86147); GC: 313
Segmentation fault

Why am I getting a segmentation fault? Is the code above using memory it shouldn't? Or creating some sort of undefined behavior?

Using the same code structure, for more complex ODE's I have also seen the warning: warning: didn't implement memmove, using memcpy as fallback which can result in errors

Nothing else appeared in REPL. I did a grep under the .julia folder and this warning only exists in Enzyme library. Anyway to disable Enzyme in the script and just use Zygote?

Julia 1.9.0 Package versions:

  [6e4b80f9] BenchmarkTools v1.3.2
  [b0b7db55] ComponentArrays v0.14.0
  [2445eb08] DataDrivenDiffEq v1.2.0
  [5b588203] DataDrivenSparse v0.1.2
  [c8e1da08] IterTools v1.8.0
  [033835bb] JLD2 v0.4.33
  [b964fa9f] LaTeXStrings v1.3.0
  [b2108857] Lux v0.5.0
  [961ee093] ModelingToolkit v8.64.0
  [7f7a1694] Optimization v3.15.2
  [36348300] OptimizationOptimJL v0.1.9
  [42dfb2eb] OptimizationOptimisers v0.1.5
  [1dea7af3] OrdinaryDiffEq v6.53.4
  [91a5bcdd] Plots v1.38.17
  [1ed8b502] SciMLSensitivity v7.35.1
  [860ef19b] StableRNGs v1.0.0
  [90137ffa] StaticArrays v1.6.2
  [e88e6eb3] Zygote v0.6.62

Best Regards

ChrisRackauckas commented 1 year ago

Can you share ]st -m so we know what version of Enzyme?

Anyway to disable Enzyme in the script and just use Zygote?

Yes, just pass a sensealg and choose the autojacvec=ZygoteVJP(). For example:

    Array(solve(_prob, AutoTsit5(Rodas5()), saveat = T,
                abstol = 1e-6, reltol = 1e-6,  verbose=false, sensealg=QuadratureAdjoint(autojacvec=ZygoteVJP())))

That should be a workaround.

@wsmoses it looks like this is pointing to an issue with the GC mark loop after Enzyme? Is that something that's known? Cross referencing things like https://github.com/SciML/DiffEqFlux.jl/issues/812, it looks a bit different from the Enzyme errors I've seen before and it seems not fixed on master so I don't know if this one has been reported.

The MWE part is:

using Lux, ComponentArrays

rbf(x) = exp.(-(x .^ 2))

# Multilayer FeedForward
U = Lux.Chain(  Lux.Dense(6, 25, rbf), 
                Lux.Dense(25, 25, rbf), 
                Lux.Dense(25, 25, rbf),
                Lux.Dense(25, 6))

ps, st = Lux.setup(rng, U)

p_ = zeros(4)

p = ComponentArray{Float64}(p=ps, p_true=p_) 

function nn_dynamics!(du, u, p, t)
    û = U(u, p.p, st)[1] 

    du[1] = p.p_true[1] * u[1] + û[1]
    du[2] = -p.p_true[4] * u[2] + û[2]

    du[3] = p.p_true[1] * u[1] + û[3]
    du[4] = -p.p_true[4] * u[2] + û[4]

    du[5] = p.p_true[1] * u[1] + û[5]
    du[6] = -p.p_true[4] * u[2] + û[6]
end

and then just differentiating nn_dynamics!(du, u, p, t). Though I don't know if you'll recreate a GC issue in just one pass, while in the differential equation it'll do this derivative a few thousand times.

ChrisRackauckas commented 1 year ago

To make Enzyme work here, I think you just need to enclose the Lux st and U for type stability so the whole thing is non-dynamic.

wsmoses commented 1 year ago

I’m going to use this issue to strongly recommend that sciml change the docs in their examples to be type stable so folks don’t hit as many issues.

On Sat, Aug 12, 2023 at 6:49 PM Christopher Rackauckas < @.***> wrote:

To make Enzyme work here, I think you just need to enclose the Lux st and U for type stability so the whole thing is non-dynamic.

— Reply to this email directly, view it on GitHub https://github.com/SciML/DiffEqFlux.jl/issues/851#issuecomment-1676132779, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJTUXAX5UVE2M3KL4PAAVDXVAB6ZANCNFSM6AAAAAA3KMYZW4 . You are receiving this because you were mentioned.Message ID: @.***>

ChrisRackauckas commented 1 year ago

I guess if we have to now, though it's generally bad form to optimize on things which do not have an effect on performance, and this kind of case has no performance impact. Though if the conclusion is that Enzyme now works perfectly fine as long as those are enclosed in a let block then we'll change it. I.e., the minimum change is probably:

let
       function nn_dynamics!(du, u, p, t)
       û = U(u, p.p, st)[1] 

       du[1] = p.p_true[1] * u[1] + û[1]
       du[2] = -p.p_true[4] * u[2] + û[2]

       du[3] = p.p_true[1] * u[1] + û[3]
       du[4] = -p.p_true[4] * u[2] + û[4]

       du[5] = p.p_true[1] * u[1] + û[5]
       du[6] = -p.p_true[4] * u[2] + û[6]
       end
end
ChrisRackauckas commented 1 year ago

FWIW I'm testing this on latest Enzyme on Julia v1.9.1 and there's no segfault:

┌ Warning: EnzymeVJP tried and failed in the automated AD choice algorithm with the following error. (To turn off this printing, add `verbose = false` to the `solve` call)
└ @ SciMLSensitivity C:\Users\accou\.julia\packages\SciMLSensitivity\1hSPO\src\concrete_solve.jl:23
Enzyme execution failed.
Mismatched activity for:   store {} addrspace(10)* %12, {} addrspace(10)* addrspace(10)* %.repack, align 8, !dbg !22, !tbaa !78, !alias.scope !76, !noalias !81 const val:   %12 = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %11 unordered, align 8, !dbg !11, !tbaa !23, !invariant.load !10, !alias.scope !27, !noalias !30, !nonnull !10, !dereferenceable !35, !align !36
Type tree: {[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}
You may be using a constant variable as temporary storage for active memory (https://enzyme.mit.edu/julia/stable/#Activity-of-temporary-storage). If not, please open an issue, and either rewrite this variable to not be conditionally active or use Enzyme.API.runtimeActivity!(true) as a workaround for now

Stacktrace:
 [1] nn_dynamics2!
   @ c:\Users\accou\OneDrive\Computer\Desktop\test.jl:52

Current loss after 10 iterations: 71953.88637127848
Current loss after 20 iterations: 42047.4531789665
Current loss after 30 iterations: 24953.907322388743
Current loss after 40 iterations: 14816.790391119554
Current loss after 50 iterations: 8173.798307112623
Current loss after 60 iterations: 3138.2214048185783
Current loss after 70 iterations: 1198.2880244383134
Current loss after 80 iterations: 619.1022424925653
Current loss after 90 iterations: 306.62778078466096
Current loss after 100 iterations: 149.59638116576286
u: ComponentVector{Float64}(layer_1 = (weight = [0.40452204651727086 -0.3451561290413163 … 0.030378177742048325 -0.09746306437319036; 0.02909839230565981 0.1961682176524208 … 0.11693423422884815 -0.2117845626201238; … ; -0.1466388353350096 -0.42467623732652315 … -0.28671317804666624 -0.24416499356691912; -0.13454584729451652 -0.41059271757878585 … 0.08600029775795831 -0.14375619292120523], bias = [0.006291710086723531; -0.021337953871793852; … ; -0.008600696180751813; -0.03232915619903121;;]), layer_2 = (weight = [-0.10020940018159157 -0.32358169138772924 … 0.026880331372289058 -0.08931925025349811; -0.09640563585155952 -0.221320184809805 … -0.1134481661253655 -0.3009033025526279; … ; 0.05520696647133258 0.09816541916508571 … -0.2676881365057306 -0.2575610711970336; 0.29708984617055956 -0.13748616942405015 … -0.12310712253700094 -0.006683720416712566], bias = [-0.02869186500942819; 0.0022749381361329866; … ; -0.007717215129839446; -0.02843367129575026;;]), layer_3 = (weight = [0.020004164150970567 0.18986161613333954 … -0.23067573729529514 0.10358056609687911; -0.1022286898650569 -0.3192001529421505 … 0.2801869598615032 -0.03532521218572715; … ; 0.2704972693335152 0.05518713602484375 … -0.34561735453293807 0.1819011798714294; -0.07128807667303864 0.34633372942964497 … 0.048374187657259655 0.3156669042122709], bias = [-0.024951261120680034; -0.04205150910065041; … ; -0.03185848812212727; 0.02627807492518191;;]), layer_4 = (weight = [-0.3399382431778244 0.023937722102339947 … -0.3365740022401353 0.04804659850688229; -0.2607917815321767 0.12791129394814857 … 0.24164958922548876 0.17558191750612728; … ; -0.0738173360186803 -0.2844498528862972 … 0.3453896946025614 0.3920187682457453; 0.05813908691374911 -0.25795136869363333 … 0.3773047407070357 -0.2951935355911494], bias = [-0.05642461141732063; -0.020979247976346004; … ; -0.040805938036252876; -0.03653573514529774;;]))

I think this is just an issue with the op's versions.

FWIW, the type stable version enclosing the globals via a let block throw the same Enzyme error:

using OrdinaryDiffEq, SciMLSensitivity
using Optimization, OptimizationOptimisers, OptimizationOptimJL

using LinearAlgebra, Statistics

using ComponentArrays, Lux, Zygote, Plots, LaTeXStrings, StableRNGs, IterTools
import Flux

rng = StableRNG(1111)

function lotka!(du, u, p, t)
    α, β, γ, δ = [1.3, 0.9, 0.8, 1.8]
    du[1] = α * u[1] - β * u[2] * u[1]
    du[2] = γ * u[1] * u[2] - δ * u[2]
end

function get_train_data()
    t_true = LinRange(0.0,5.0,300)
    tspan = (0.0, 5.0)
    u0 = 5.0f0 * rand(rng, 2)
    prob = ODEProblem(lotka!, u0, tspan, zeros(4))
    solution = solve(prob, Vern7(), abstol = 1e-12, reltol = 1e-12, saveat = t_true);

    Xₙ = Array(solution);
    t = solution.t;

    data = Flux.DataLoader([vcat(Xₙ, t')], batchsize = 1)
    return data
end

train_loader = get_train_data();

rbf(x) = exp.(-(x .^ 2))

# Multilayer FeedForward
U = Lux.Chain(  Lux.Dense(6, 25, rbf), 
                Lux.Dense(25, 25, rbf), 
                Lux.Dense(25, 25, rbf),
                Lux.Dense(25, 6))

ps, st = Lux.setup(rng, U)

p_ = zeros(4)

p = ComponentArray{Float64}(p=ps, p_true=p_) 

nn_dynamics! = let
       function nn_dynamics!(du, u, p, t)
              û = U(u, p.p, st)[1] 

              du[1] = p.p_true[1] * u[1] + û[1]
              du[2] = -p.p_true[4] * u[2] + û[2]

              du[3] = p.p_true[1] * u[1] + û[3]
              du[4] = -p.p_true[4] * u[2] + û[4]

              du[5] = p.p_true[1] * u[1] + û[5]
              du[6] = -p.p_true[4] * u[2] + û[6]
       end
end

# Define the problem
prob_nn = ODEProblem(nn_dynamics!, repeat(first(train_loader)[1][1:2,1],3), (0.0, 5.0), p)

function predict(θ, batch)
    T = batch[3, :];  

    IC = batch[1:2, 1];

    _prob = remake(prob_nn, u0 = repeat(IC,3), tspan = (T[1], T[end]), p=ComponentArray(p=θ, p_true=[1.3, 0.9, 0.8, 1.8]))

    Array(solve(_prob, AutoTsit5(Rodas5()), saveat = T,
                abstol = 1e-6, reltol = 1e-6,  verbose=false))
end

function loss(θ, batch)
    X̂ = predict(θ, batch);

    X_true = @view batch[1:2, :]; 

    mean(abs2, X_true .- X̂[1:2,:])
end

losses = Float64[]

callback = function (p, l)
    push!(losses, l)
    if length(losses) % 10 == 0
        println("Current loss after $(length(losses)) iterations: $(losses[end])")
    end
    return false
end

adtype = Optimization.AutoZygote();
optfun = Optimization.OptimizationFunction((θ, p, batch) -> loss(θ, batch), adtype); 
optprob = Optimization.OptimizationProblem(optfun, p.p);

res = Optimization.solve(  optprob,
                            ADAM(0.001), 
                            IterTools.ncycle(train_loader, 100),
                            callback = callback)

I'm going to close this because it's fixed on latest versions, but I'd like to hear from Billy what we should do about that:

You may be using a constant variable as temporary storage for active memory (https://enzyme.mit.edu/julia/stable/#Activity-of-temporary-storage). If not, please open an issue, and either rewrite this variable to not be conditionally active or use Enzyme.API.runtimeActivity!(true) as a workaround for now

U and st are effectively constants: is that what's tripping up Enzyme?

ghost commented 1 year ago

Hi,

I have updated my packages: What I currently have ]st -m :

⌅ [47edcb42] ADTypes v0.1.6
  [c3fe647b] AbstractAlgebra v0.31.0
  [621f4979] AbstractFFTs v1.5.0
  [1520ce14] AbstractTrees v0.4.4
  [79e6a3ab] Adapt v3.6.2
  [dce04be8] ArgCheck v2.3.0
  [ec485272] ArnoldiMethod v0.2.0
  [4fba245c] ArrayInterface v7.4.11
  [30b0a656] ArrayInterfaceCore v0.1.29
  [a9b6321e] Atomix v0.1.0
  [198e06fe] BangBang v0.3.39
  [9718e550] Baselet v0.1.1
  [6e4b80f9] BenchmarkTools v1.3.2
  [e2ed5e7c] Bijections v0.1.4
  [d1d4a3ce] BitFlags v0.1.7
  [62783981] BitTwiddlingConvenienceFunctions v0.1.5
  [fa961155] CEnum v0.4.2
  [2a0fbf3d] CPUSummary v0.2.3
  [00ebfdb7] CSTParser v3.3.6
  [49dc2e85] Calculus v0.5.1
  [7057c7e9] Cassette v0.3.11
  [082447d4] ChainRules v1.53.0
  [d360d2e6] ChainRulesCore v1.16.0
  [fb6a15b2] CloseOpenIntervals v0.1.12
  [944b1d66] CodecZlib v0.7.2
  [35d6a980] ColorSchemes v3.23.0
  [3da002f7] ColorTypes v0.11.4
  [c3611d14] ColorVectorSpace v0.10.0
  [5ae59095] Colors v0.12.10
  [861a8166] Combinatorics v1.0.2
  [a80b9123] CommonMark v0.8.12
  [38540f10] CommonSolve v0.2.4
  [bbf7d656] CommonSubexpressions v0.3.0
  [34da2185] Compat v4.9.0
  [b0b7db55] ComponentArrays v0.14.0
  [b152e2b5] CompositeTypes v0.1.3
  [a33af91c] CompositionsBase v0.1.2
  [2569d6c7] ConcreteStructs v0.2.3
  [f0e56b4a] ConcurrentUtilities v2.2.1
  [88cd18e8] ConsoleProgressMonitor v0.1.2
  [187b0558] ConstructionBase v1.5.3
  [6add18c4] ContextVariablesX v0.1.3
  [d38c429a] Contour v0.6.2
  [adafc99b] CpuId v0.3.1
  [a8cc5b0e] Crayons v4.1.1
  [9a962f9c] DataAPI v1.15.0
  [2445eb08] DataDrivenDiffEq v1.2.0
  [5b588203] DataDrivenSparse v0.1.2
  [82cc6244] DataInterpolations v4.0.1
  [864edb3b] DataStructures v0.18.15
  [e2d170a0] DataValueInterfaces v1.0.0
  [244e2a9f] DefineSingletons v0.1.2
  [8bb1440f] DelimitedFiles v1.9.1
  [2b5f629d] DiffEqBase v6.128.1
  [459566f4] DiffEqCallbacks v2.27.0
  [77a26b50] DiffEqNoiseProcess v5.18.0
  [163ba53b] DiffResults v1.1.0
  [b552c78f] DiffRules v1.15.1
  [b4f34e82] Distances v0.10.9
  [31c24e10] Distributions v0.25.100
  [ffbed154] DocStringExtensions v0.9.3
  [5b8099bc] DomainSets v0.6.7
  [fa6b7ba4] DualNumbers v0.6.8
  [7c1d4256] DynamicPolynomials v0.5.2
  [da5c29d0] EllipsisNotation v1.7.0
  [4e289a0a] EnumX v1.0.4
  [7da242da] Enzyme v0.11.6
  [f151be2c] EnzymeCore v0.5.2
  [460bff9d] ExceptionUnwrapping v0.1.9
  [d4d017d3] ExponentialUtilities v1.24.0
  [e2ba6199] ExprTools v0.1.10
  [c87230d0] FFMPEG v0.4.1
  [cc61a311] FLoops v0.2.1
  [b9860ae5] FLoopsBase v0.1.1
  [7034ab61] FastBroadcast v0.2.6
  [9aa1b823] FastClosures v0.3.2
  [29a986be] FastLapackInterface v2.0.0
  [5789e2e9] FileIO v1.16.1
  [1a297f60] FillArrays v1.5.0
  [6a86dc24] FiniteDiff v2.21.1
  [53c48c17] FixedPointNumbers v0.8.4
  [59287772] Formatting v0.4.2
  [f6369f11] ForwardDiff v0.10.36
  [069b7b12] FunctionWrappers v1.1.3
  [77dc65aa] FunctionWrappersWrappers v0.1.3
  [d9f16b24] Functors v0.4.5
  [0c68f7d7] GPUArrays v8.8.1
  [46192b85] GPUArraysCore v0.1.5
⌅ [61eb1bfa] GPUCompiler v0.21.4
  [28b8d3ca] GR v0.72.9
  [c145ed77] GenericSchur v0.5.3
  [c27321d9] Glob v1.3.1
  [86223c79] Graphs v1.8.0
  [42e2da0e] Grisu v1.0.2
  [0b43b601] Groebner v0.4.2
  [d5909c97] GroupsCore v0.4.0
  [cd3eb016] HTTP v1.9.14
  [3e5b6fbb] HostCPUFeatures v0.1.16
  [34004b35] HypergeometricFunctions v0.3.23
  [7869d1d1] IRTools v0.4.10
  [615f187c] IfElse v0.1.1
  [d25df0c9] Inflate v0.1.3
  [22cec73e] InitialValues v0.3.1
  [18e54dd8] IntegerMathUtils v0.1.2
  [8197267c] IntervalSets v0.7.7
  [92d709cd] IrrationalConstants v0.2.2
  [c8e1da08] IterTools v1.8.0
  [82899510] IteratorInterfaceExtensions v1.0.0
  [033835bb] JLD2 v0.4.33
  [1019f520] JLFzf v0.1.5
  [692b3bcd] JLLWrappers v1.4.1
  [682c06a0] JSON v0.21.4
  [98e50ef6] JuliaFormatter v1.0.35
  [b14d175d] JuliaVariables v0.2.4
  [ccbc3e58] JumpProcesses v9.7.2
  [ef3ab10e] KLU v0.4.0
  [63c18a36] KernelAbstractions v0.9.8
  [ba0b0d4f] Krylov v0.9.3
  [929cbde3] LLVM v6.1.0
  [b964fa9f] LaTeXStrings v1.3.0
  [2ee39098] LabelledArrays v1.14.0
  [984bce1d] LambertW v0.4.6
  [23fbe1c1] Latexify v0.16.1
  [10f19ff3] LayoutPointers v0.1.14
  [50d2b5c4] Lazy v0.15.1
  [1d6d02ad] LeftChildRightSiblingTrees v0.2.0
  [2d8b4e74] LevyArea v1.0.0
  [d3d80556] LineSearches v7.2.0
  [7ed4a6bd] LinearSolve v2.5.0
  [2ab3a3ac] LogExpFunctions v0.3.24
  [e6f89c97] LoggingExtras v1.0.0
  [bdcacae8] LoopVectorization v0.12.165
  [b2108857] Lux v0.5.0
  [bb33d45b] LuxCore v0.1.4
  [34f89e08] LuxDeviceUtils v0.1.6
  [82251201] LuxLib v0.3.2
  [d8e11817] MLStyle v0.4.17
  [f1d291b0] MLUtils v0.4.3
  [1914dd2f] MacroTools v0.5.10
  [d125e4d3] ManualMemory v0.1.8
  [739be429] MbedTLS v1.1.7
  [442fdcdd] Measures v0.3.2
  [128add7d] MicroCollections v0.1.4
  [e1d29d7a] Missings v1.1.0
  [961ee093] ModelingToolkit v8.64.0
  [46d2c3a1] MuladdMacro v0.2.4
  [102ac46a] MultivariatePolynomials v0.5.1
  [d8a4904e] MutableArithmetics v1.3.0
  [d41bc354] NLSolversBase v7.8.3
  [2774e3e8] NLsolve v4.5.1
  [872c559c] NNlib v0.9.4
  [77ba4419] NaNMath v1.0.2
  [71a1bf82] NameResolution v0.1.5
  [8913a72c] NonlinearSolve v1.9.0
  [d8793406] ObjectFile v0.4.0
  [6fe1bfb0] OffsetArrays v1.12.10
  [4d8831e6] OpenSSL v1.4.1
  [429524aa] Optim v1.7.6
  [3bd65402] Optimisers v0.2.19
⌃ [7f7a1694] Optimization v3.14.0
⌃ [36348300] OptimizationOptimJL v0.1.8
⌃ [42dfb2eb] OptimizationOptimisers v0.1.2
  [bac558e1] OrderedCollections v1.6.2
  [1dea7af3] OrdinaryDiffEq v6.53.4
  [90014a1f] PDMats v0.11.17
  [65ce6f38] PackageExtensionCompat v1.0.1
  [d96e819e] Parameters v0.12.3
  [69de0a69] Parsers v2.7.2
  [570af359] PartialFunctions v1.1.1
  [b98c9c47] Pipe v1.3.0
  [ccf2f8ad] PlotThemes v3.1.0
  [995b91a9] PlotUtils v1.3.5
  [91a5bcdd] Plots v1.38.17
  [e409e4f3] PoissonRandom v0.4.4
  [f517fe37] Polyester v0.7.5
  [1d0040c9] PolyesterWeave v0.2.1
  [85a6dd25] PositiveFactorizations v0.2.4
  [d236fae5] PreallocationTools v0.4.12
  [aea7be01] PrecompileTools v1.1.2
  [21216c6a] Preferences v1.4.0
  [8162dcfd] PrettyPrint v0.2.0
  [27ebfcd6] Primes v0.5.4
  [33c8b6b6] ProgressLogging v0.1.4
  [92933f4c] ProgressMeter v1.7.2
  [1fd47b50] QuadGK v2.8.2
  [74087812] Random123 v1.6.1
  [fb686558] RandomExtensions v0.4.3
  [e6cf234a] RandomNumbers v1.5.3
  [c1ae055f] RealDot v0.1.0
  [3cdcf5f2] RecipesBase v1.3.4
  [01d81517] RecipesPipeline v0.6.12
  [731186ca] RecursiveArrayTools v2.38.7
  [f2c3362d] RecursiveFactorization v0.2.20
  [189a3867] Reexport v1.2.2
  [05181044] RelocatableFolders v1.0.0
  [ae029012] Requires v1.3.0
  [ae5879a3] ResettableStacks v1.1.1
  [37e2e3b7] ReverseDiff v1.15.0
  [79098fc4] Rmath v0.7.1
  [7e49a35a] RuntimeGeneratedFunctions v0.5.12
  [fdea26ae] SIMD v3.4.5
  [94e857df] SIMDTypes v0.1.0
  [476501e8] SLEEFPirates v0.6.39
  [0bca4576] SciMLBase v1.94.0
  [e9a6253c] SciMLNLSolve v0.1.8
  [c0aeaf25] SciMLOperators v0.3.6
  [1ed8b502] SciMLSensitivity v7.37.0
  [6c6a2e73] Scratch v1.2.0
  [efcf1570] Setfield v1.1.1
  [605ecd9f] ShowCases v0.1.0
  [992d4aef] Showoff v1.0.3
  [777ac1f9] SimpleBufferStream v1.1.0
  [727e6d20] SimpleNonlinearSolve v0.1.19
  [699a6c99] SimpleTraits v0.9.4
  [ce78b400] SimpleUnPack v1.1.0
  [66db9d55] SnoopPrecompile v1.0.3
  [a2af1166] SortingAlgorithms v1.1.1
  [47a9eef4] SparseDiffTools v2.4.1
  [e56a9233] Sparspak v0.3.9
  [276daf66] SpecialFunctions v2.3.1
  [171d559e] SplittablesBase v0.1.15
  [860ef19b] StableRNGs v1.0.0
  [aedffcd0] Static v0.8.8
  [0d7ed370] StaticArrayInterface v1.4.0
  [90137ffa] StaticArrays v1.6.2
  [1e83bf80] StaticArraysCore v1.4.2
  [82ae8749] StatsAPI v1.6.0
⌅ [2913bbd2] StatsBase v0.33.21
  [4c63d2b9] StatsFuns v1.3.0
  [789caeaf] StochasticDiffEq v6.62.0
  [7792a7ef] StrideArraysCore v0.4.17
  [09ab397b] StructArrays v0.6.15
  [53d494c1] StructIO v0.3.0
  [2efcf032] SymbolicIndexingInterface v0.2.2
  [d1185830] SymbolicUtils v1.2.0
  [0c5d862f] Symbolics v5.5.1
  [3783bdb8] TableTraits v1.0.1
  [bd369af6] Tables v1.10.1
  [62fd8b95] TensorCore v0.1.1
  [5d786b92] TerminalLoggers v0.1.7
  [8290d209] ThreadingUtilities v0.5.2
  [a759f4b9] TimerOutputs v0.5.23
  [0796e94c] Tokenize v0.5.25
  [9f7883ad] Tracker v0.2.26
  [3bb67fe8] TranscodingStreams v0.9.13
  [28d57a85] Transducers v0.4.78
  [a2a6695c] TreeViews v0.3.0
  [d5829a12] TriangularSolve v0.1.19
  [410a4b4d] Tricks v0.1.7
  [781d530d] TruncatedStacktraces v1.4.0
  [5c2747f8] URIs v1.5.0
  [3a884ed6] UnPack v1.0.2
  [1cfade01] UnicodeFun v0.4.1
  [1986cc42] Unitful v1.16.3
  [45397f5d] UnitfulLatexify v1.6.3
  [a7c27f48] Unityper v0.1.5
  [013be700] UnsafeAtomics v0.2.1
  [d80eeb9a] UnsafeAtomicsLLVM v0.1.3
  [41fe7b60] Unzip v0.2.0
  [3d5dd08c] VectorizationBase v0.21.64
  [19fa3120] VertexSafeGraphs v0.2.0
  [d49dbf32] WeightInitializers v0.1.0
  [e88e6eb3] Zygote v0.6.63
  [700de1a5] ZygoteRules v0.2.3
  [6e34b625] Bzip2_jll v1.0.8+0
  [83423d85] Cairo_jll v1.16.1+1
⌅ [7cc45869] Enzyme_jll v0.0.78+0
  [2e619515] Expat_jll v2.5.0+0
⌃ [b22a6f82] FFMPEG_jll v4.4.2+2
  [a3f928ae] Fontconfig_jll v2.13.93+0
  [d7e528f0] FreeType2_jll v2.13.1+0
  [559328eb] FriBidi_jll v1.0.10+0
  [0656b61e] GLFW_jll v3.3.8+0
  [d2c73de3] GR_jll v0.72.9+1
  [78b55507] Gettext_jll v0.21.0+0
  [7746bdde] Glib_jll v2.74.0+2
  [3b182d85] Graphite2_jll v1.3.14+0
  [2e76f6c2] HarfBuzz_jll v2.8.1+1
  [aacddb02] JpegTurbo_jll v2.1.91+0
  [c1c5ebd0] LAME_jll v3.100.1+0
  [88015f11] LERC_jll v3.0.0+1
  [dad2f222] LLVMExtra_jll v0.0.23+0
  [1d63c593] LLVMOpenMP_jll v15.0.4+0
  [dd4b983a] LZO_jll v2.10.1+0
⌅ [e9f186c6] Libffi_jll v3.2.2+1
  [d4300ac3] Libgcrypt_jll v1.8.7+0
  [7e76a0d4] Libglvnd_jll v1.6.0+0
  [7add5ba3] Libgpg_error_jll v1.42.0+0
  [94ce4f54] Libiconv_jll v1.16.1+2
  [4b2f31a3] Libmount_jll v2.35.0+0
  [89763e89] Libtiff_jll v4.5.1+1
  [38a345b3] Libuuid_jll v2.36.0+0
  [e7412a2a] Ogg_jll v1.3.5+1
⌅ [458c3c95] OpenSSL_jll v1.1.22+0
  [efe28fd5] OpenSpecFun_jll v0.5.5+0
  [91d4177d] Opus_jll v1.3.2+0
  [30392449] Pixman_jll v0.42.2+0
  [c0090381] Qt6Base_jll v6.4.2+3
  [f50d1b31] Rmath_jll v0.4.0+0
  [a2964d1f] Wayland_jll v1.21.0+0
  [2381bf8a] Wayland_protocols_jll v1.25.0+0
  [02c8fc9c] XML2_jll v2.10.3+0
  [aed1982a] XSLT_jll v1.1.34+0
  [ffd25f8a] XZ_jll v5.4.4+0
  [4f6342f7] Xorg_libX11_jll v1.8.6+0
  [0c0b7dd1] Xorg_libXau_jll v1.0.11+0
  [935fb764] Xorg_libXcursor_jll v1.2.0+4
  [a3789734] Xorg_libXdmcp_jll v1.1.4+0
  [1082639a] Xorg_libXext_jll v1.3.4+4
  [d091e8ba] Xorg_libXfixes_jll v5.0.3+4
  [a51aa0fd] Xorg_libXi_jll v1.7.10+4
  [d1454406] Xorg_libXinerama_jll v1.1.4+4
  [ec84b674] Xorg_libXrandr_jll v1.5.2+4
  [ea2f1a96] Xorg_libXrender_jll v0.9.10+4
  [14d82f49] Xorg_libpthread_stubs_jll v0.1.1+0
  [c7cfdc94] Xorg_libxcb_jll v1.15.0+0
  [cc61e674] Xorg_libxkbfile_jll v1.1.2+0
  [12413925] Xorg_xcb_util_image_jll v0.4.0+1
  [2def613f] Xorg_xcb_util_jll v0.4.0+1
  [975044d2] Xorg_xcb_util_keysyms_jll v0.4.0+1
  [0d47668e] Xorg_xcb_util_renderutil_jll v0.3.9+1
  [c22f9ab0] Xorg_xcb_util_wm_jll v0.4.1+1
  [35661453] Xorg_xkbcomp_jll v1.4.6+0
  [33bec58e] Xorg_xkeyboard_config_jll v2.39.0+0
  [c5fb5394] Xorg_xtrans_jll v1.5.0+0
  [3161d3a3] Zstd_jll v1.5.5+0
⌅ [214eeab7] fzf_jll v0.29.0+0
  [a4ae2306] libaom_jll v3.4.0+0
  [0ac62f75] libass_jll v0.15.1+0
  [f638f0a6] libfdk_aac_jll v2.0.2+0
  [b53b4c65] libpng_jll v1.6.38+0
  [f27f6e37] libvorbis_jll v1.3.7+1
  [1270edf5] x264_jll v2021.5.5+0
  [dfaa095f] x265_jll v3.5.0+0
  [d8fb68d0] xkbcommon_jll v1.4.1+0
  [0dad84c5] ArgTools v1.1.1
  [56f22d72] Artifacts
  [2a0f44e3] Base64
  [ade2ca70] Dates
  [8ba89e20] Distributed
  [f43a241f] Downloads v1.6.0
  [7b1f6079] FileWatching
  [9fa8497b] Future
  [b77e0a4c] InteractiveUtils
  [4af54fe1] LazyArtifacts
  [b27032c2] LibCURL v0.6.3
  [76f85450] LibGit2
  [8f399da3] Libdl
  [37e2e46d] LinearAlgebra
  [56ddb016] Logging
  [d6f4376e] Markdown
  [a63ad114] Mmap
  [ca575930] NetworkOptions v1.2.0
  [44cfe95a] Pkg v1.9.0
  [de0858da] Printf
  [9abbd945] Profile
  [3fa0cd96] REPL
  [9a3f8284] Random
  [ea8e919c] SHA v0.7.0
  [9e88b42a] Serialization
  [1a1011a3] SharedArrays
  [6462fe0b] Sockets
  [2f01184e] SparseArrays
  [10745b16] Statistics v1.9.0
  [4607b0f0] SuiteSparse
  [fa267f1f] TOML v1.0.3
  [a4e569a6] Tar v1.10.0
  [8dfed614] Test
  [cf7118a7] UUIDs
  [4ec0a83e] Unicode
  [e66e0078] CompilerSupportLibraries_jll v1.0.2+0
  [deac9b47] LibCURL_jll v7.84.0+0
  [29816b5a] LibSSH2_jll v1.10.2+0
  [c8ffd9c3] MbedTLS_jll v2.28.2+0
  [14a3606d] MozillaCACerts_jll v2022.10.11
  [4536629a] OpenBLAS_jll v0.3.21+4
  [05823500] OpenLibm_jll v0.8.1+0
  [efcefdf7] PCRE2_jll v10.42.0+0
  [bea87d4a] SuiteSparse_jll v5.10.1+6
  [83775a58] Zlib_jll v1.2.13+0
  [8e850b90] libblastrampoline_jll v5.7.0+0
  [8e850ede] nghttp2_jll v1.48.0+0
  [3f19e933] p7zip_jll v17.4.0+0

When I execute the code you posted I also get the warning that "Enzyme execution failed."

If I use the Enzyme.API.runtimeActivity!(true) flag, I get a new world error.

┌ Warning: EnzymeVJP tried and failed in the automated AD choice algorithm with the following error. (To turn off this printing, add `verbose = false` to the `solve` call)
└  SciMLSensitivity ~/.julia/packages/SciMLSensitivity/zGhCS/src/concrete_solve.jl:23
MethodError: no method matching asprogress(::Base.CoreLogging.LogLevel, ::String, ::Module, ::Symbol, ::Symbol, ::String, ::Int64)
The applicable method may be too new: running in world age 33653, while current world is 34030.

Closest candidates are:
  asprogress(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any; progress, kwargs...) (method too new to be called from this world context.)
    ProgressLogging ~/.julia/packages/ProgressLogging/6KXlp/src/ProgressLogging.jl:156
  asprogress(::Any, ::ProgressLogging.Progress, ::Any...; _...) (method too new to be called from this world context.)
    ProgressLogging ~/.julia/packages/ProgressLogging/6KXlp/src/ProgressLogging.jl:155
  asprogress(::Any, ::ProgressLogging.ProgressString, ::Any...; _...) (method too new to be called from this world context.)
    ProgressLogging ~/.julia/packages/ProgressLogging/6KXlp/src/ProgressLogging.jl:200

This message appeass with the verbose=false argument.

Can you reproduce this? If not, would you mind sharing the version of the packages you are using?

Also, is it possible to check what sensealg was used if nothing is provided?

ChrisRackauckas commented 1 year ago

If I use the Enzyme.API.runtimeActivity!(true) flag, I get a new world error.

Is that actually an error? There's a try/catch where the error is resurfaced as a warning. I saw a warning but no errors, the code ran. Are you mixing up the warning with an error?