From 2037a9bf103cdda3e2f6b235fee38d68b4fda73b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jinguo=20Liu=20=28=E5=88=98=E9=87=91=E5=9B=BD=29?= Date: Fri, 29 Sep 2023 00:16:53 +0800 Subject: [PATCH] updagrad CUDA.jl to 5.0 (#83) --- Project.toml | 12 ++---------- src/CuYao.jl | 5 ++--- test/CUDApatch.jl | 2 +- test/instructs.jl | 15 ++++++++++++++- test/register.jl | 4 ++-- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Project.toml b/Project.toml index 8bdddcc..931ff40 100644 --- a/Project.toml +++ b/Project.toml @@ -1,26 +1,18 @@ name = "CuYao" uuid = "b48ca7a8-dd42-11e8-2b8e-1b7706800275" -version = "0.3.8" +version = "0.3.9" [deps] -BitBasis = "50ba71b6-fa0f-514d-ae9a-0916efc90dcf" CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -LuxurySparse = "d05aeea4-b7d4-55ac-b691-9e7fabb07ba2" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" -StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" -StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" TupleTools = "9d95972d-f1c8-5527-a6e0-b4b365fa01f6" Yao = "5872b779-8223-5990-8dd0-5abbb0748c8c" [compat] -BitBasis = "0.8" -CUDA = "4" -LuxurySparse = "0.7" +CUDA = "4, 5" Reexport = "0.2, 1" -StaticArrays = "0.12, 1" -StatsBase = "0.33-0.34" TupleTools = "1" Yao = "0.8" julia = "1" diff --git a/src/CuYao.jl b/src/CuYao.jl index bd86e5b..b086a1a 100644 --- a/src/CuYao.jl +++ b/src/CuYao.jl @@ -1,7 +1,6 @@ module CuYao -using LuxurySparse, StaticArrays, LinearAlgebra, Base.Cartesian -using StatsBase -using BitBasis +using Yao.YaoArrayRegister.LuxurySparse, Yao.YaoArrayRegister.StaticArrays, LinearAlgebra, Base.Cartesian +using Yao.YaoArrayRegister.StatsBase, Yao.YaoArrayRegister.BitBasis using Reexport import TupleTools using Random diff --git a/test/CUDApatch.jl b/test/CUDApatch.jl index 93e69c7..b00adb9 100644 --- a/test/CUDApatch.jl +++ b/test/CUDApatch.jl @@ -1,7 +1,7 @@ using CuYao using CUDA using Test -using YaoBlocks +using Yao.YaoBlocks @testset "isapprox-complex" begin ca = CuArray(randn(ComplexF64,3,3)) diff --git a/test/instructs.jl b/test/instructs.jl index 9ba99ee..300e779 100644 --- a/test/instructs.jl +++ b/test/instructs.jl @@ -1,7 +1,7 @@ using LinearAlgebra, Yao.ConstGate using Test, Random using CuYao -using StaticArrays +using Yao.YaoArrayRegister.StaticArrays using Yao.ConstGate: SWAPGate using CUDA @@ -120,3 +120,16 @@ end reg = rand_state(10) @test apply!(copy(reg), g) ≈ apply!(reg |> cu, g) |> cpu end + +# fix: https://github.com/QuantumBFS/CuYao.jl/issues/81 +@testset "generic sparse (pqc circuit)" begin + # kron of Rx + pqc_circuit = subroutine(10, kron(Rx(0.4), Rx(0.5), Rx(0.6), Rx(0.8)), (1, 2, 6, 5)) + proxy_reg = zero_state(10) + @test apply!(proxy_reg |> cu, pqc_circuit) |> cpu ≈ apply(proxy_reg, pqc_circuit) + + # kron of Rz + pqc_circuit = subroutine(10, kron(Rz(0.4), Rz(0.5), Rz(0.6), Rz(0.8)), (1, 2, 6, 5)) + proxy_reg = zero_state(10) + @test apply!(proxy_reg |> cu, pqc_circuit) |> cpu ≈ apply(proxy_reg, pqc_circuit) +end \ No newline at end of file diff --git a/test/register.jl b/test/register.jl index 18f1a0a..8c9551c 100644 --- a/test/register.jl +++ b/test/register.jl @@ -2,9 +2,9 @@ using Test using CuYao using CuYao: tri2ij using LinearAlgebra -using BitBasis +using Yao.YaoArrayRegister.BitBasis using Statistics: mean -using StaticArrays +using Yao.YaoArrayRegister.StaticArrays using CUDA using Yao.YaoArrayRegister: batched_kron, batched_kron!, batch_normalize! CUDA.allowscalar(false)