Enzyme.jl
Enzyme.jl copied to clipboard
Segmentation fault when puting a complex number to power 0
Hi,
I've encountered a bug with Enzyme which took me a while to localize. Basically, the following code results in a segmentation fault:
using Enzyme
function aux(f, μ)
result = 0.0im
z = exp(im)
result += z^μ # Bug here
result
end
g = 1.0
μ = 0
loss(g, μ) = sum(abs.(aux(g, μ)))
@show loss(g, μ)
autodiff(Reverse, loss, Active, Active(g), μ)
Having non-zero power or a float power or a real number in z
does not cause the segfault.
I have Enzyme v0.10.4
and Julia 1.7. Obviously I don't fancy optimizing such functions but I can provide context if needed! :)
Can you paste whatever you see in a log/backtrace?
I'm not able to reproduce it from your code snippet on main.
julia> using Enzyme
julia>
julia> function aux(f, μ)
result = 0.0im
z = exp(im)
result += z^μ # Bug here
result
end
aux (generic function with 1 method)
julia>
julia> g = 1.0
1.0
julia> μ = 0
0
julia> loss(g, μ) = sum(abs.(aux(g, μ)))
loss (generic function with 1 method)
julia>
julia> @show loss(g, μ)
loss(g, μ) = 1.0
1.0
julia> autodiff(Reverse, loss, Active, Active(g), μ)
(0.0,)
Sure, here it is
signal (11): Segmentation fault: 11
in expression starting at REPL[20]:1
unknown function (ip: 0x10e7d7c6c)
Allocations: 33515273 (Pool: 33500453; Big: 14820); GC: 40
I'm on Mac M1 with an intel build (Rosetta). So that may be a problem.
@gaspardbb does this still reproduce for you?
Just tried with Enzyme v0.10.11 and Julia 1.8 (M1 build) and this does not reproduce! We can close the issue.