Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tenet + Reactant + Enzyme.gradient broken on last releases #593

Closed
mofeing opened this issue Jan 21, 2025 · 1 comment · Fixed by #604
Closed

Tenet + Reactant + Enzyme.gradient broken on last releases #593

mofeing opened this issue Jan 21, 2025 · 1 comment · Fixed by #604
Labels
help wanted Extra attention is needed

Comments

@mofeing
Copy link
Collaborator

mofeing commented Jan 21, 2025

after updating Tenet.jl to the last releases of Reactant.jl, I'm getting the following error when trying to use differentiate through Enzyme.gradient:

julia> using Tenet, Reactant, Adapt, Enzyme
AssertionError("Could not find registered platform with name: \"cuda\". Available platform names are: ")

julia> ψ = rand(MPS; n=2, maxdim=2, eltype=ComplexF64)
MPS (inputs=0, outputs=2)

julia> H = rand(MPO; n=2, maxdim=4, eltype=ComplexF64)
MPO (inputs=2, outputs=2)

julia> ψ_re = adapt(ConcreteRArray, ψ)
MPS (inputs=0, outputs=2)

julia> H_re = adapt(ConcreteRArray, H)
MPO (inputs=2, outputs=2)

julia> f(a, b) = only(expect(a, b))
f (generic function with 1 method)

julia> expect_grad = Reactant.compile((ψ_re, H_re)) do ψ_traced, H_traced
           return Enzyme.gradient(ReverseWithPrimal, f, ψ_traced, Const(H_traced))
       end

[91244] signal 11 (1): Segmentation fault
in expression starting at REPL[9]:1
_ZNK4mlir9FloatAttr8getValueEv at /home/ssanche1/.julia/artifacts/61a0f246197e7e645f6bc64671d7a12105b6c13f/lib/libReactantExtra.so (unknown line)
_ZN4mlir17DenseElementsAttr3getENS_10ShapedTypeEN4llvm8ArrayRefINS_9AttributeEEE at /home/ssanche1/.julia/artifacts/61a0f246197e7e645f6bc64671d7a12105b6c13f/lib/libReactantExtra.so (unknown line)
mlirDenseElementsAttrSplatGet at /home/ssanche1/.julia/artifacts/61a0f246197e7e645f6bc64671d7a12105b6c13f/lib/libReactantExtra.so (unknown line)
mlirDenseElementsAttrSplatGet at /home/ssanche1/.julia/packages/Reactant/mOTWj/src/mlir/libMLIR_h.jl:3963 [inlined]
fill at /home/ssanche1/.julia/packages/Reactant/mOTWj/src/mlir/IR/Attribute.jl:442
unknown function (ip: 0x7e80f3e21d73)
overload_autodiff at /home/ssanche1/.julia/packages/Reactant/mOTWj/src/Interpreter.jl:315
#autodiff at /home/ssanche1/.julia/packages/Reactant/mOTWj/src/Overlay.jl:31
unknown function (ip: 0x7e80f4362fde)
autodiff at /home/ssanche1/.julia/packages/Enzyme/R6sE8/src/Enzyme.jl:524 [inlined]
macro expansion at /home/ssanche1/.julia/packages/Enzyme/R6sE8/src/sugar.jl:275 [inlined]
gradient at /home/ssanche1/.julia/packages/Enzyme/R6sE8/src/sugar.jl:263 [inlined]
#1 at ./REPL[9]:2 [inlined]
opaque closure at ./<missing>:0
unknown function (ip: 0x7e80f43186e9)
Const at /home/ssanche1/.julia/packages/EnzymeCore/15Zff/src/EnzymeCore.jl:30 [inlined]
#1 at ./REPL[9]:2 [inlined]
call_with_reactant at /home/ssanche1/.julia/packages/Reactant/mOTWj/src/utils.jl:0
jl_apply at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/julia.h:2157 [inlined]
do_apply at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/builtins.c:831
#make_mlir_fn#1 at /home/ssanche1/.julia/packages/Reactant/mOTWj/src/TracedUtils.jl:191
make_mlir_fn at /home/ssanche1/.julia/packages/Reactant/mOTWj/src/TracedUtils.jl:104 [inlined]
#compile_mlir!#9 at /home/ssanche1/.julia/packages/Reactant/mOTWj/src/Compiler.jl:420
compile_mlir! at /home/ssanche1/.julia/packages/Reactant/mOTWj/src/Compiler.jl:411 [inlined]
#compile_xla#30 at /home/ssanche1/.julia/packages/Reactant/mOTWj/src/Compiler.jl:949
compile_xla at /home/ssanche1/.julia/packages/Reactant/mOTWj/src/Compiler.jl:939 [inlined]
#compile#33 at /home/ssanche1/.julia/packages/Reactant/mOTWj/src/Compiler.jl:977
compile at /home/ssanche1/.julia/packages/Reactant/mOTWj/src/Compiler.jl:976
unknown function (ip: 0x7e811b7b58a6)
jl_apply at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/julia.h:2157 [inlined]
do_call at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/interpreter.c:126
eval_value at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/interpreter.c:223
eval_stmt_value at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/interpreter.c:174 [inlined]
eval_body at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/interpreter.c:663
jl_interpret_toplevel_thunk at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/interpreter.c:821
jl_toplevel_eval_flex at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/toplevel.c:943
jl_toplevel_eval_flex at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/toplevel.c:886
ijl_toplevel_eval_in at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/toplevel.c:994
eval at ./boot.jl:430 [inlined]
eval_user_input at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:245
repl_backend_loop at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:342
#start_repl_backend#59 at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:327
start_repl_backend at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:324
#run_repl#72 at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:483
run_repl at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:469
jfptr_run_repl_10104.1 at /home/ssanche1/.julia/juliaup/julia-1.11.2+0.x64.linux.gnu/share/julia/compiled/v1.11/REPL/u0gqU_4x0TT.so (unknown line)
#1150 at ./client.jl:446
jfptr_YY.1150_14803.1 at /home/ssanche1/.julia/juliaup/julia-1.11.2+0.x64.linux.gnu/share/julia/compiled/v1.11/REPL/u0gqU_4x0TT.so (unknown line)
jl_apply at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/julia.h:2157 [inlined]
jl_f__call_latest at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/builtins.c:875
#invokelatest#2 at ./essentials.jl:1055 [inlined]
invokelatest at ./essentials.jl:1052 [inlined]
run_main_repl at ./client.jl:430
repl_main at ./client.jl:567 [inlined]
_start at ./client.jl:541
jfptr__start_73406.1 at /home/ssanche1/.julia/juliaup/julia-1.11.2+0.x64.linux.gnu/lib/julia/sys.so (unknown line)
jl_apply at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/julia.h:2157 [inlined]
true_main at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/jlapi.c:900
jl_repl_entrypoint at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/src/jlapi.c:1059
main at /cache/build/tester-amdci5-12/julialang/julia-release-1-dot-11/cli/loader_exe.c:58
unknown function (ip: 0x7e811d029d8f)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x4010b8)
Allocations: 128192792 (Pool: 128184284; Big: 8508); GC: 48
Segmentation fault (core dumped)

@wsmoses any idea of what might be going wrong? compilation is going very slow too because i haven't update traced_type yet to traced_type_internal, and i think it's probably not taking my make_tracer specializations because it haven't yet added the new traced_number arg. could those things affect Enzyme?

@mofeing mofeing added the help wanted Extra attention is needed label Jan 21, 2025
@Pangoraw
Copy link
Collaborator

Maybe, we need the same workaround as #245 here:

attr = fill(MLIR.IR.Attribute(unwrapped_eltype(a)(1)), Ops.mlir_type(a))

mofeing added a commit that referenced this issue Jan 24, 2025
wsmoses pushed a commit that referenced this issue Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants