Open ranocha opened 2 years ago
This is what I get:
julia> using Enzyme, Polyester
julia> function f(x)
y = similar(x)
@batch for i in eachindex(x, y)
y[i] = x[i]^2
end
return y
end
f (generic function with 1 method)
julia> Threads.nthreads()
2
julia> jacobian(Forward, f, [2.0, 3.0])
2×2 Matrix{Float64}:
4.0 0.0
0.0 6.0
julia version 1.7.3 enzyme version 0.10.4 macOS arm
@ranocha can you retry on latest release and see if this reproduces still?
For me, the error did not occur for the latest releases of Enzyme (v0.10.12) and Polyester (v0.6.16) on both Linux x86_64 and macOS ARM, with Julia v1.7 and v1.8, single-threaded. However, when switching to using julia -t 2
, both Julia v1.7 and v1.8, on both Linux and macOS, die a fiery death with a core dump (here's the one from Julia v1.8.2 on Linux):
julia> using Pkg; Pkg.activate(temp=true); Pkg.add(["Enzyme", "Polyester"]); using Enzyme, Polyester
julia> function f(x)
y = similar(x)
@batch for i in eachindex(x, y)
y[i] = x[i]^2
end
return y
end
f (generic function with 1 method)
julia> jacobian(Forward, f, [2.0, 3.0])
<analysis>
{}* inttoptr (i64 139737793205024 to {}*): {[-1]:Anything}, intvals: {}
i64 1: {[-1]:Integer}, intvals: {1,}
i64 0: {[-1]:Anything}, intvals: {0,}
i32 1: {[-1]:Integer}, intvals: {1,}
i64 8: {[-1]:Integer}, intvals: {8,}
i64 2: {[-1]:Integer}, intvals: {2,}
<snip>
unknown function (ip: 0x401098)
Allocations: 60806253 (Pool: 60758024; Big: 48229); GC: 44
Aborted (core dumped)
As far as I know, Polyester.jl generates plain serial code without wrapping it in the serial case - it basically executes the loop without @batch
. They only do something in the really parallel case - which breaks as described by @sloede.
This is fixed by https://github.com/EnzymeAD/Enzyme.jl/pull/557 and https://github.com/EnzymeAD/Enzyme/pull/949 . Note that after the latter lands, you will need to wait for the jll to update here.
Rephrasing, those PR's will fix the type analysis assertion, however, incidentally this does then reproduce (on 2 threads, 1.8.3) the e-310
correctness issue.
Using Julia v1.7.3 with 2 threads, I get