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

**URL:** https://discourse.julialang.org/t/enzyme-attempting-to-call-an-indirect-active-function-whose-runtime-value-is-inactive-in-forward-over-reverse-mode/116841
**Category:** General Usage
**Tags:** forwarddiff, reversediff, autodiff, enzyme
**Created:** [July 9, 2024, 8:48pm UTC](https://discourse.julialang.org/t/enzyme-attempting-to-call-an-indirect-active-function-whose-runtime-value-is-inactive-in-forward-over-reverse-mode/116841 "2024-07-09T20:48:15Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![dleather](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dleather/32/43762_2.png) [@dleather](https://discourse.julialang.org/u/dleather)
#### Post date: [July 9, 2024, 8:48pm UTC](https://discourse.julialang.org/t/enzyme-attempting-to-call-an-indirect-active-function-whose-runtime-value-is-inactive-in-forward-over-reverse-mode/116841/1 "2024-07-09T20:48:15Z")

</div>

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:

```julia
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:

```julia
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)),
)

```

---

<div class="post-metadata">

### Author: ![Maysam\_Gholampour](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maysam_gholampour/32/218184_2.png) [@Maysam\_Gholampour](https://discourse.julialang.org/u/Maysam_Gholampour)
#### Post date: [July 10, 2024, 12:15am UTC](https://discourse.julialang.org/t/enzyme-attempting-to-call-an-indirect-active-function-whose-runtime-value-is-inactive-in-forward-over-reverse-mode/116841/2 "2024-07-10T00:15:13Z")

</div>

[FAQ · Enzyme.jl](https://enzyme.mit.edu/julia/stable/faq/) might be helpful.

---

<div class="post-metadata">

### Author: ![dleather](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dleather/32/43762_2.png) [@dleather](https://discourse.julialang.org/u/dleather)
#### Post date: [July 10, 2024, 12:37am UTC](https://discourse.julialang.org/t/enzyme-attempting-to-call-an-indirect-active-function-whose-runtime-value-is-inactive-in-forward-over-reverse-mode/116841/3 "2024-07-10T00:37:43Z")

</div>

Thanks! It sounds like it has something to do with [activity of temporary storage](https://enzyme.mit.edu/julia/stable/faq/#Activity-of-temporary-storage) for my specific function.

---

<div class="post-metadata">

### Author: ![Maysam\_Gholampour](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maysam_gholampour/32/218184_2.png) [@Maysam\_Gholampour](https://discourse.julialang.org/u/Maysam_Gholampour)
#### Post date: [July 10, 2024, 12:56am UTC](https://discourse.julialang.org/t/enzyme-attempting-to-call-an-indirect-active-function-whose-runtime-value-is-inactive-in-forward-over-reverse-mode/116841/4 "2024-07-10T00:56:28Z")

</div>

Also, if you run it on GPU or encounter any problems, I suggest taking a look at [Enzyme.jl/test at main · EnzymeAD/Enzyme.jl · GitHub](https://github.com/EnzymeAD/Enzyme.jl/tree/main/test).  
It was very helpful for me. I think it is a common way to get some ideas on how to write your code when using any packages.

---

<div class="post-metadata">

### Author: ![wsmoses](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wsmoses/32/26497_2.png) [@wsmoses](https://discourse.julialang.org/u/wsmoses)
#### Post date: [July 10, 2024, 2:13am UTC](https://discourse.julialang.org/t/enzyme-attempting-to-call-an-indirect-active-function-whose-runtime-value-is-inactive-in-forward-over-reverse-mode/116841/5 "2024-07-10T02:13:44Z")

</div>

Mind posting a complete MWE as an issue?

It’s hard to offer advice without more context on the code.

---

<div class="post-metadata">

### Author: ![dleather](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dleather/32/43762_2.png) [@dleather](https://discourse.julialang.org/u/dleather)
#### Post date: [July 10, 2024, 4:15am UTC](https://discourse.julialang.org/t/enzyme-attempting-to-call-an-indirect-active-function-whose-runtime-value-is-inactive-in-forward-over-reverse-mode/116841/6 "2024-07-10T04:15:44Z")

</div>

Upon creating a MWE I found that declaring all types in my functions to be `<: Real` resolved the issue.

If that surprises you and you want to take a look at the MWE I’ll post to Github.

---

<div class="post-metadata">

### Author: ![wsmoses](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wsmoses/32/26497_2.png) [@wsmoses](https://discourse.julialang.org/u/wsmoses)
#### Post date: [July 10, 2024, 12:40pm UTC](https://discourse.julialang.org/t/enzyme-attempting-to-call-an-indirect-active-function-whose-runtime-value-is-inactive-in-forward-over-reverse-mode/116841/7 "2024-07-10T12:40:33Z")

</div>

Yeah still probably helpful to see!

---

<div class="post-metadata">

### Author: ![dleather](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dleather/32/43762_2.png) [@dleather](https://discourse.julialang.org/u/dleather)
#### Post date: [July 10, 2024, 9:34pm UTC](https://discourse.julialang.org/t/enzyme-attempting-to-call-an-indirect-active-function-whose-runtime-value-is-inactive-in-forward-over-reverse-mode/116841/8 "2024-07-10T21:34:36Z")

</div>

Done. [Error in Forward over Reverse Mode for Hessian · Issue #1628 · EnzymeAD/Enzyme.jl · GitHub](https://github.com/EnzymeAD/Enzyme.jl/issues/1628)
