QuantumBFS / Yao.jl

Extensible, Efficient Quantum Algorithm Design for Humans.
https://yaoquantum.org
Other
934 stars 123 forks source link

Precompiling CuYao Error in Julia 1.10.4 #520

Closed zipeilee closed 3 months ago

zipeilee commented 3 months ago

When I update my Julia to 1.10.4 and just us

using Yao, CUDA

my REPL report the error as follow:

Precompiling CuYao
        Info Given CuYao was explicitly requested, output will be shown live 
ERROR: LoadError: UndefVarError: `compatible_multiplicative_operand` not defined
Stacktrace:
  [1] getproperty(x::Module, f::Symbol)
    @ Base ./Base.jl:31
  [2] top-level scope
    @ ~/.julia/packages/Yao/C3lZp/ext/CuYao/src/CUDApatch.jl:63
  [3] include(mod::Module, _path::String)
    @ Base ./Base.jl:495
  [4] include(x::String)
    @ CuYao ~/.julia/packages/Yao/C3lZp/ext/CuYao.jl:1
  [5] top-level scope
    @ ~/.julia/packages/Yao/C3lZp/ext/CuYao/src/CuYao.jl:31
  [6] include(mod::Module, _path::String)
    @ Base ./Base.jl:495
  [7] include(x::String)
    @ CuYao ~/.julia/packages/Yao/C3lZp/ext/CuYao.jl:1
  [8] top-level scope
    @ ~/.julia/packages/Yao/C3lZp/ext/CuYao.jl:2
  [9] include
    @ ./Base.jl:495 [inlined]
 [10] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
    @ Base ./loading.jl:2222
 [11] top-level scope
    @ stdin:3
in expression starting at /home/xin/.julia/packages/Yao/C3lZp/ext/CuYao/src/CUDApatch.jl:63
in expression starting at /home/xin/.julia/packages/Yao/C3lZp/ext/CuYao/src/CuYao.jl:31
in expression starting at /home/xin/.julia/packages/Yao/C3lZp/ext/CuYao.jl:1
in expression starting at stdin:3
  ✗ Yao → CuYao
  0 dependencies successfully precompiled in 4 seconds. 194 already precompiled.
[ Info: Precompiling CuYao [c78a625a-4caa-5412-8a7b-b69064260436]
ERROR: LoadError: UndefVarError: `compatible_multiplicative_operand` not defined
Stacktrace:
  [1] getproperty(x::Module, f::Symbol)
    @ Base ./Base.jl:31
  [2] top-level scope
    @ ~/.julia/packages/Yao/C3lZp/ext/CuYao/src/CUDApatch.jl:63
  [3] include(mod::Module, _path::String)
    @ Base ./Base.jl:495
  [4] include(x::String)
    @ CuYao ~/.julia/packages/Yao/C3lZp/ext/CuYao.jl:1
  [5] top-level scope
    @ ~/.julia/packages/Yao/C3lZp/ext/CuYao/src/CuYao.jl:31
  [6] include(mod::Module, _path::String)
    @ Base ./Base.jl:495
  [7] include(x::String)
    @ CuYao ~/.julia/packages/Yao/C3lZp/ext/CuYao.jl:1
  [8] top-level scope
    @ ~/.julia/packages/Yao/C3lZp/ext/CuYao.jl:2
  [9] include
    @ ./Base.jl:495 [inlined]
 [10] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
    @ Base ./loading.jl:2222
 [11] top-level scope
    @ stdin:3
in expression starting at /home/xin/.julia/packages/Yao/C3lZp/ext/CuYao/src/CUDApatch.jl:63
in expression starting at /home/xin/.julia/packages/Yao/C3lZp/ext/CuYao/src/CuYao.jl:31
in expression starting at /home/xin/.julia/packages/Yao/C3lZp/ext/CuYao.jl:1
in expression starting at stdin:3
┌ Error: Error during loading of extension CuYao of Yao, use `Base.retry_load_extensions()` to retry.
│   exception =
│    1-element ExceptionStack:
│    Failed to precompile CuYao [c78a625a-4caa-5412-8a7b-b69064260436] to "/home/xin/.julia/compiled/v1.10/CuYao/jl_JXknaf".
│    Stacktrace:
│      [1] error(s::String)
│        @ Base ./error.jl:35
│      [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
│        @ Base ./loading.jl:2468
│      [3] compilecache
│        @ ./loading.jl:2340 [inlined]
│      [4] (::Base.var"#968#969"{Base.PkgId})()
│        @ Base ./loading.jl:1974
│      [5] mkpidlock(f::Base.var"#968#969"{Base.PkgId}, at::String, pid::Int32; kwopts::@Kwargs{stale_age::Int64, wait::Bool})
│        @ FileWatching.Pidfile ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:93
│      [6] #mkpidlock#6
│        @ ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:88 [inlined]
│      [7] trymkpidlock(::Function, ::Vararg{Any}; kwargs::@Kwargs{stale_age::Int64})
│        @ FileWatching.Pidfile ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:111
│      [8] #invokelatest#2
│        @ ./essentials.jl:894 [inlined]
│      [9] invokelatest
│        @ ./essentials.jl:889 [inlined]
│     [10] maybe_cachefile_lock(f::Base.var"#968#969"{Base.PkgId}, pkg::Base.PkgId, srcpath::String; stale_age::Int64)
│        @ Base ./loading.jl:2983
│     [11] maybe_cachefile_lock
│        @ ./loading.jl:2980 [inlined]
│     [12] _require(pkg::Base.PkgId, env::Nothing)
│        @ Base ./loading.jl:1970
│     [13] __require_prelocked(uuidkey::Base.PkgId, env::Nothing)
│        @ Base ./loading.jl:1812
│     [14] #invoke_in_world#3
│        @ ./essentials.jl:926 [inlined]
│     [15] invoke_in_world
│        @ ./essentials.jl:923 [inlined]
│     [16] _require_prelocked
│        @ ./loading.jl:1803 [inlined]
│     [17] _require_prelocked
│        @ ./loading.jl:1802 [inlined]
│     [18] run_extension_callbacks(extid::Base.ExtensionId)
│        @ Base ./loading.jl:1295
│     [19] run_extension_callbacks(pkgid::Base.PkgId)
│        @ Base ./loading.jl:1330
│     [20] run_package_callbacks(modkey::Base.PkgId)
│        @ Base ./loading.jl:1164
│     [21] __require_prelocked(uuidkey::Base.PkgId, env::String)
│        @ Base ./loading.jl:1819
│     [22] #invoke_in_world#3
│        @ ./essentials.jl:926 [inlined]
│     [23] invoke_in_world
│        @ ./essentials.jl:923 [inlined]
│     [24] _require_prelocked(uuidkey::Base.PkgId, env::String)
│        @ Base ./loading.jl:1803
│     [25] macro expansion
│        @ ./loading.jl:1790 [inlined]
│     [26] macro expansion
│        @ ./lock.jl:267 [inlined]
│     [27] __require(into::Module, mod::Symbol)
│        @ Base ./loading.jl:1753
│     [28] #invoke_in_world#3
│        @ ./essentials.jl:926 [inlined]
│     [29] invoke_in_world
│        @ ./essentials.jl:923 [inlined]
│     [30] require(into::Module, mod::Symbol)
│        @ Base ./loading.jl:1746
│     [31] eval
│        @ ./boot.jl:385 [inlined]
│     [32] eval_user_input(ast::Any, backend::REPL.REPLBackend, mod::Module)
│        @ REPL ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:150
│     [33] repl_backend_loop(backend::REPL.REPLBackend, get_module::Function)
│        @ REPL ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:246
│     [34] start_repl_backend(backend::REPL.REPLBackend, consumer::Any; get_module::Function)
│        @ REPL ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:231
│     [35] run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool, backend::Any)
│        @ REPL ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:389
│     [36] run_repl(repl::REPL.AbstractREPL, consumer::Any)
│        @ REPL ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:375
│     [37] (::Base.var"#1013#1015"{Bool, Bool, Bool})(REPL::Module)
│        @ Base ./client.jl:432
│     [38] #invokelatest#2
│        @ ./essentials.jl:892 [inlined]
│     [39] invokelatest
│        @ ./essentials.jl:889 [inlined]
│     [40] run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool)
│        @ Base ./client.jl:416
│     [41] exec_options(opts::Base.JLOptions)
│        @ Base ./client.jl:333
│     [42] _start()
│        @ Base ./client.jl:552
└ @ Base loading.jl:1301

my package version: Julia 1.10.4 CUDA v5.4.3 Yao v0.9.0

GiggleLiu commented 3 months ago
(base) ➜  Yao git:(master) ✗ ag compatible_multiplicative_operand
lib/YaoBlocks/src/primitive/time_evolution.jl
90:compatible_multiplicative_operand(::AbstractArray, source::AbstractArray) = source
94:        # `compatible_multiplicative_operand` is used to ensure GPU compatibility.
95:        reg.state .*= exp.((-im * te.dt) .* compatible_multiplicative_operand(reg.state, diag(mat(T, te.H))))

ext/CuYao/src/CUDApatch.jl
63:YaoBlocks.compatible_multiplicative_operand(::CuArray, source::AbstractArray) = CuArray(source)
64:YaoBlocks.compatible_multiplicative_operand(::CuArray, source::CuArray) = source

It is very likely that your YaoBlocks version is not up to date.