EnzymeAD / EnzymeAD/Enzyme.jl

Strange `EnzymeRuntimeActivityError` on 1.12

Open
#3,100 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
586
Forks
108
Avg merge
1d 5h
Merged PRs (30d)
44

Description

Here's what I see

```
Error in testset test_reverse: MatrixAlgebraKit.eigh_full ∘ MatrixAlgebraKit.project_hermitian with return activity EnzymeCore.Duplicated on (::TensorKit.TensorMap{Float64, TensorKit.GradedSpace{TensorKitSectors.ProductSector{Tuple{TensorKitSectors.A4Irrep, TensorKitSectors.Z4Element{2}}}, NTuple{16, Int64}}, 1, 1, Vector{Float64}}, EnzymeCore.Duplicated):
Error During Test at /Users/khyatt/.julia/packages/EnzymeTestUtils/yGBt1/src/test_reverse.jl:84
Got exception outside of a @test
EnzymeRuntimeActivityError: Detected potential need for runtime activity.

Constant memory is stored (or returned) to a differentiable variable and correctness cannot be guaranteed with static activity analysis.
This might be due to the use of a constant variable as temporary storage for active memory (https://enzyme.mit.edu/julia/stable/faq/#faq-runtime-activity).
If Enzyme should be able to prove this use non-differentable, open an issue!

To work around this issue, either:
a) rewrite this variable to not be conditionally active (fastest performance, slower to setup), or
b) set the Enzyme mode to turn on runtime activity (e.g. autodiff(set_runtime_activity(Reverse), ...) ). This will maintain correctness, but may slightly reduce performance.

Failure within method:

call_with_kwargs(::@NamedTuple{}, ::ComposedFunction{typeof(MatrixAlgebraKit.eigh_full), typeof(MatrixAlgebraKit.project_hermitian)}, ::TensorKit.TensorMap{Float64, TensorKit.GradedSpace{TensorKitSectors.ProductSector{Tuple{TensorKitSectors.A4Irrep, TensorKitSectors.Z4Element{2}}}, NTuple{16, Int64}}, 1, 1, Vector{Float64}})
@ EnzymeTestUtils ~/.julia/packages/EnzymeTestUtils/yGBt1/src/test_reverse.jl:8

Hint: catch this exception as `err` and call `code_typed(err)` to inspect the surrounding code.

Mismatched activity for: %.fca.0.0.insert = insertvalue { { ptr addrspace(10), { [16 x i64], i8 } }, { ptr addrspace(10), [2 x [1 x [1 x { [16 x i64], i8 }]]] } } poison, ptr addrspace(10) %innersret.sroa.0.0.innersret.sroa.0.0.innersret.sroa.0.0.innersret.sroa.0.0.innersret.sroa.0.0.innersret.sroa.0.0.innersret.sroa.0.0.innersret.sroa.0.0.innersret.sroa.0.0.innersret.sroa.0.0..fca.0.0.load, 0, 0, !dbg !8 const val: %innersret.sroa.0.0.innersret.sroa.0.0.innersret.sroa.0.0.innersret.sroa.0.0.innersret.sroa.0.0.innersret.sroa.0.0.innersret.sroa.0.0.innersret.sroa.0.0.innersret.sroa.0.0.innersret.sroa.0.0..fca.0.0.load = load ptr addrspace(10), ptr addrspace(11) %15, align 8, !dbg !8
Julia value causing error: Unknown object of type Any
LLVM view of erring value: %innersret.sroa.0.0.innersret.sroa.0.0.innersret.sroa.0.0.innersret.sroa.0.0.innersret.sroa.0.0.innersret.sroa.0.0.innersret.sroa.0.0.innersret.sroa.0.0.innersret.sroa.0.0.innersret.sroa.0.0..fca.0.0.load = load ptr addrspace(10), ptr addrspace(11) %15, align 8, !dbg !8

Stacktrace:
[1] call_with_kwargs
@ ~/.julia/packages/EnzymeTestUtils/yGBt1/src/test_reverse.jl:0
```

This is on:

```
[7da242da] Enzyme v0.13.146
[f151be2c] EnzymeCore v0.8.20
[12d8515a] EnzymeTestUtils v0.2.6
```

To repro:

check out https://github.com/QuantumKitHub/TensorKit.jl/tree/ksh/enzyme and run

`julia --project -e 'using Pkg; Pkg.test(; test_args=["enzyme-factorizations/eigh"])'`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.