EnzymeAD / EnzymeAD/Reactant.jl

Crash on `Enzyme.autodiff` with `Active` annotation

Open
#658 2 comments 1 reaction 0 assignees View on GitHub
autodiff
Dominant language
Julia
Stars
370
Forks
74
Avg merge
18h 47m
Merged PRs (30d)
30

Description

```julia
julia> f(x,y) = sum(x .* y)
f (generic function with 1 method)

julia> a = rand(2)
2-element Vector{Float64}:
0.41323466569127665
0.4525169547907606

julia> b = rand(2)
2-element Vector{Float64}:
0.37009493514138525
0.818796709700481

julia> a_re = adapt(ConcreteRArray, a)
2-element ConcreteRArray{Float64, 1}:
0.41323466569127665
0.4525169547907606

julia> b_re = adapt(ConcreteRArray, b)
2-element ConcreteRArray{Float64, 1}:
0.37009493514138525
0.818796709700481

julia> f_grad(x,y) = Enzyme.autodiff(ReverseWithPrimal, f, Const, Active(x), Active(y))
f_grad (generic function with 1 method)

julia> @code_hlo optimize=false f_grad(a_re, b_re)
ERROR: type Active has no field dval
Stacktrace:
[1] getproperty
@ ./Base.jl:49 [inlined]
[2] overload_autodiff(::ReverseMode{true, false, FFIABI, false, true}, ::Const{typeof(f)}, ::Type{Const}, ::Active{Reactant.TracedRArray{Float64, 1}}, ::Active{Reactant.TracedRArray{Float64, 1}})
@ Reactant ~/.julia/packages/Reactant/B09Ss/src/Interpreter.jl:339
[3] autodiff(::ReverseMode{true, false, FFIABI, false, true}, ::Const{typeof(f)}, ::Type{Const}, ::Active{Reactant.TracedRArray{Float64, 1}}, ::Active{Reactant.TracedRArray{Float64, 1}})
@ Reactant ~/.julia/packages/Reactant/B09Ss/src/Overlay.jl:31
[4] autodiff
@ ~/.julia/packages/Enzyme/R6sE8/src/Enzyme.jl:524 [inlined]
[5] f_grad
@ ./REPL[19]:1 [inlined]
[6] f_grad(none::Reactant.TracedRArray{Float64, 1}, none::Reactant.TracedRArray{Float64, 1})
@ Reactant ./:0
[7] Active
@ ~/.julia/packages/EnzymeCore/15Zff/src/EnzymeCore.jl:50 [inlined]
[8] f_grad
@ ./REPL[19]:1 [inlined]
[9] call_with_reactant(::typeof(f_grad), ::Reactant.TracedRArray{Float64, 1}, ::Reactant.TracedRArray{Float64, 1})
@ Reactant ~/.julia/packages/Reactant/B09Ss/src/utils.jl:0
[10] make_mlir_fn(f::Function, args::Tuple{ConcreteRArray{Float64, 1}, ConcreteRArray{Float64, 1}}, kwargs::Tuple{}, name::String, concretein::Bool; toscalar::Bool, return_dialect::Symbol, do_transpose::Bool, no_args_in_result::Bool)
@ Reactant.TracedUtils ~/.julia/packages/Reactant/B09Ss/src/TracedUtils.jl:216
[11] make_mlir_fn
@ ~/.julia/packages/Reactant/B09Ss/src/TracedUtils.jl:129 [inlined]
[12] compile_mlir!(mod::Reactant.MLIR.IR.Module, f::Function, args::Tuple{ConcreteRArray{Float64, 1}, ConcreteRArray{Float64, 1}}; optimize::Bool, no_nan::Bool)
@ Reactant.Compiler ~/.julia/packages/Reactant/B09Ss/src/Compiler.jl:441
[13] compile_mlir!
@ ~/.julia/packages/Reactant/B09Ss/src/Compiler.jl:432 [inlined]
[14] #7
@ ~/.julia/packages/Reactant/B09Ss/src/Compiler.jl:366 [inlined]
[15] context!(f::Reactant.Compiler.var"#7#8"{@Kwargs{no_nan::Bool, optimize::Bool}, typeof(f_grad), Tuple{ConcreteRArray{Float64, 1}, ConcreteRArray{Float64, 1}}}, ctx::Reactant.MLIR.IR.Context)
@ Reactant.MLIR.IR ~/.julia/packages/Reactant/B09Ss/src/mlir/IR/Context.jl:76
[16] compile_mlir(f::Function, args::Tuple{ConcreteRArray{Float64, 1}, ConcreteRArray{Float64, 1}}; kwargs::@Kwargs{no_nan::Bool, optimize::Bool})
@ Reactant.Compiler ~/.julia/packages/Reactant/B09Ss/src/Compiler.jl:364
[17] top-level scope
@ ~/.julia/packages/Reactant/B09Ss/src/Compiler.jl:695
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.