Open jgreener64 opened 1 month ago
With debug info:
Cannot create a null constant of that type!
UNREACHABLE executed at /home/wmoses/git/Enzyme.jl/julia10/deps/srccache/llvm-julia-15.0.7-10/llvm/lib/IR/Constants.cpp:374!
[3398190] signal (6.-6): Aborted
in expression starting at /home/wmoses/git/Enzyme.jl/cubc.jl:6
pthread_kill at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
raise at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
llvm_unreachable_internal at /home/wmoses/git/Enzyme.jl/julia10/deps/srccache/llvm-julia-15.0.7-10/llvm/lib/Support/ErrorHandling.cpp:212
getNullValue at /home/wmoses/git/Enzyme.jl/julia10/deps/srccache/llvm-julia-15.0.7-10/llvm/lib/IR/Constants.cpp:374
handleAdjointForIntrinsic at /home/wmoses/.julia/scratchspaces/7cc45869-7501-5eee-bdea-0790c847d4ef/src/Enzyme/enzyme/Enzyme/AdjointGenerator.h:4023
visitIntrinsicInst at /home/wmoses/.julia/scratchspaces/7cc45869-7501-5eee-bdea-0790c847d4ef/src/Enzyme/enzyme/Enzyme/AdjointGenerator.h:3696
@jgreener64 the forward mode assertion should no longer err that way. It for some reason has a size mismatch error come up though.
If you have cycles, some minimization through the broadcast impl would definitely be helpful here.
The forward mode error is
ERROR: DimensionMismatch: arrays could not be broadcast to a common size; got a dimension with lengths 5 and 5
Stacktrace:
[1] _bcs1
@ ./broadcast.jl:555 [inlined]
[2] _bcs
@ ./broadcast.jl:549 [inlined]
[3] broadcast_shape
@ ./broadcast.jl:543 [inlined]
[4] combine_axes
@ ./broadcast.jl:524 [inlined]
[5] instantiate
@ ./broadcast.jl:306 [inlined]
[6] materialize
@ ./broadcast.jl:903 [inlined]
[7] f
@ ./REPL[3]:1 [inlined]
[8] fwddiffejulia_f_4514wrap
@ ./REPL[3]:0
[9] macro expansion
@ ~/.julia/dev/Enzyme/src/compiler.jl:5916 [inlined]
[10] enzyme_call
@ ~/.julia/dev/Enzyme/src/compiler.jl:5566 [inlined]
[11] ForwardModeThunk
@ ~/.julia/dev/Enzyme/src/compiler.jl:5446 [inlined]
[12] autodiff
@ ~/.julia/dev/Enzyme/src/Enzyme.jl:399 [inlined]
[13] autodiff(::ForwardMode{FFIABI}, ::typeof(f), ::Type{Duplicated}, ::Duplicated{CuArray{…}}, ::Const{CuArray{…}})
@ Enzyme ~/.julia/dev/Enzyme/src/Enzyme.jl:303
[14] top-level scope
@ REPL[9]:1
[15] top-level scope
@ ~/.julia/dev/CUDA/src/initialization.jl:209
Some type information was truncated. Use `show(err)` to see complete types.
which certainly seems a strange one. Adding
println("a ", typeof(a), " ", a, " b ", typeof(b), " ", b, " ", a == b)
to the start of Base.Broadcast._bcs1(a, b)
(https://github.com/JuliaLang/julia/blob/0b4590a5507d3f3046e5bafc007cacbbfc9b310b/base/broadcast.jl#L555), where a
and b
are the dimension sizes of the broadcasted arrays, gives the following for the primal function:
f(x, y)
a Base.OneTo{Int64} Base.OneTo(5) b Base.OneTo{Int64} Base.OneTo(5) true
a Base.OneTo{Int64} Base.OneTo(1) b Base.OneTo{Int64} Base.OneTo(1) true
a Base.OneTo{Int64} Base.OneTo(1) b Base.OneTo{Int64} Base.OneTo(1) true
5.617565028176828
and this for the gradient:
autodiff(Forward, f, Duplicated, Duplicated(x, dx), Const(y))
a Base.OneTo{Int64} Base.OneTo(5) b Base.OneTo{Int64} Base.OneTo(5) true
[error as above]
The error is effectively thrown when a != b
, but the failure case doesn't seem to print. I wonder if Enzyme does some conversion of the types of the dimension sizes such that a == b
no longer holds.
I also tried Infiltrator.jl and Debugger.jl but didn't have much luck.
@jgreener64 is that still the case, I thought on main that should now be fixed
Still the case for me on 21b0762d with CUDA 5.3.4 and Julia 1.10.3.
Opening this to track progress in taking gradients through
CuArray
broadcasting. With Enzyme main (a68bf83) and CUDA v5.3.4:For forward mode:
For reverse mode: