Enzyme "Attempting to call an indirect active function whose runtime value is inactive" in Forward Over Reverse Mode

dleather
Tue, 09 Jul 2024 20:48:15 +0000
General Usage

I’m attempting to apply forward over reverse mode following the Enzyme.jl tutorial. The function, f:\mathbb{R}^N \rightarrow \mathbb{R^{++}}, is complicated but doesn’t involve any terms more difficult than hyperbolic functions. Reverse mode works fine for computing the gradient, but then when I apply FoR to compute the Hessian I receive the follow and don’t understand what is happening:

ERROR: Attempting to call an indirect active function whose runtime value is inactive:
Backtrace

Stacktrace:
 [1] macro expansion
   @ C:\Users\davle\.julia\packages\Enzyme\baiSZ\src\compiler.jl:6606
 [2] enzyme_call
   @ C:\Users\davle\.julia\packages\Enzyme\baiSZ\src\compiler.jl:6207
 [3] AugmentedForwardThunk
   @ C:\Users\davle\.julia\packages\Enzyme\baiSZ\src\compiler.jl:6095
 [4] runtime_generic_augfwd
   @ C:\Users\davle\.julia\packages\Enzyme\baiSZ\src\rules\jitrules.jl:311
 [5] runtime_generic_augfwd
   @ C:\Users\davle\.julia\packages\Enzyme\baiSZ\src\rules\jitrules.jl:0

ERROR: Attempting to call an indirect active function whose runtime value is inactive:
Backtrace

Stacktrace:
 [1] macro expansion
   @ C:\Users\davle\.julia\packages\Enzyme\baiSZ\src\compiler.jl:6606
 [2] enzyme_call
   @ C:\Users\davle\.julia\packages\Enzyme\baiSZ\src\compiler.jl:6207
 [3] AugmentedForwardThunk
   @ C:\Users\davle\.julia\packages\Enzyme\baiSZ\src\compiler.jl:6095
 [4] runtime_generic_augfwd
   @ C:\Users\davle\.julia\packages\Enzyme\baiSZ\src\rules\jitrules.jl:311
 [5] runtime_generic_augfwd
   @ C:\Users\davle\.julia\packages\Enzyme\baiSZ\src\rules\jitrules.jl:0

While the function itself is likely too long to post, here is my adapted FoR template:

function fn!(z::Vector{Float64}, y::Vector{Float64})
    y[1] = compute_var_y_aug(z, t0, T, θz, θy1, σz, σy, ξ0, ξ1)
    return nothing
end

y = [0.0]
x = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1]
dy = [0.0]
dx = [1.0, 0.0, 0.0, 0.0, 0.0, 0.0]

bx = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
by = [1.0]
dbx = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
dby = [0.0]

Enzyme.autodiff(
    Forward,
    (zz,yy) -> Enzyme.autodiff_deferred(Reverse, fn!, zz, yy),
    Duplicated(Duplicated(z, bx), Duplicated(dx, dbx)),
    Duplicated(Duplicated(y, by), Duplicated(dy, dby)),
)

8 posts - 3 participants