From f4187be2fa26c8d429a70ec3476e4e5b51a6732b Mon Sep 17 00:00:00 2001 From: Yi-Te Huang Date: Mon, 4 Nov 2024 15:13:21 +0900 Subject: [PATCH 1/4] optimize precompilation during runtests --- .buildkite/pipeline.yml | 2 +- Project.toml | 6 +++++- test/ext-test/gpu/Project.toml | 6 ++++++ test/ext-test/{ => gpu}/cuda_ext.jl | 0 test/runtests.jl | 8 ++++---- 5 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 test/ext-test/gpu/Project.toml rename test/ext-test/{ => gpu}/cuda_ext.jl (100%) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 83595dff4..58abe6921 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -9,7 +9,7 @@ steps: - "src/**" - "ext/QuantumToolboxCUDAExt.jl" - "test/runtests.jl" - - "test/ext-test/cuda_ext.jl" + - "test/ext-test/gpu/**" - "Project.toml" target: ".buildkite/CUDA_Ext.yml" agents: diff --git a/Project.toml b/Project.toml index 8921bce98..22b034219 100644 --- a/Project.toml +++ b/Project.toml @@ -33,6 +33,7 @@ CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" QuantumToolboxCUDAExt = "CUDA" [compat] +Aqua = "0.8" ArrayInterface = "6, 7" CUDA = "5" DiffEqBase = "6" @@ -42,6 +43,7 @@ Distributed = "1" FFTW = "1.5" Graphs = "1.7" IncompleteLU = "0.2" +JET = "0.9" LinearAlgebra = "1" LinearSolve = "2" OrdinaryDiffEqCore = "1" @@ -59,8 +61,10 @@ Test = "1" julia = "1.10" [extras] +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" +JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Test"] +test = ["Aqua", "JET", "Test"] diff --git a/test/ext-test/gpu/Project.toml b/test/ext-test/gpu/Project.toml new file mode 100644 index 000000000..63ad2aa77 --- /dev/null +++ b/test/ext-test/gpu/Project.toml @@ -0,0 +1,6 @@ +[deps] +CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" +QuantumToolbox = "6c2fb7c5-b903-41d2-bc5e-5a7c320b9fab" + +[compat] +CUDA = "5" \ No newline at end of file diff --git a/test/ext-test/cuda_ext.jl b/test/ext-test/gpu/cuda_ext.jl similarity index 100% rename from test/ext-test/cuda_ext.jl rename to test/ext-test/gpu/cuda_ext.jl diff --git a/test/runtests.jl b/test/runtests.jl index e188cd8a5..72ec00b89 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -4,7 +4,6 @@ using QuantumToolbox using QuantumToolbox: position, momentum using Random using SciMLOperators -import SciMLOperators: ScaledOperator const GROUP = get(ENV, "GROUP", "All") @@ -32,7 +31,6 @@ core_tests = [ ] if (GROUP == "All") || (GROUP == "Code-Quality") - Pkg.add(["Aqua", "JET"]) include(joinpath(testdir, "core-test", "code_quality.jl")) end @@ -45,6 +43,8 @@ if (GROUP == "All") || (GROUP == "Core") end if (GROUP == "CUDA_Ext")# || (GROUP == "All") - Pkg.add("CUDA") - include(joinpath(testdir, "ext-test", "cuda_ext.jl")) + Pkg.activate("gpu") + Pkg.develop(PackageSpec(path = dirname(@__DIR__))) + Pkg.instantiate() + include(joinpath(testdir, "ext-test", "gpu", "cuda_ext.jl")) end From 3ce7483248265565466ae0e5e4f6bf3c0e9cc711 Mon Sep 17 00:00:00 2001 From: Yi-Te Huang Date: Mon, 4 Nov 2024 15:27:10 +0900 Subject: [PATCH 2/4] fix `CUDA` tests --- Project.toml | 1 - test/runtests.jl | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 22b034219..35b9ff0f1 100644 --- a/Project.toml +++ b/Project.toml @@ -62,7 +62,6 @@ julia = "1.10" [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" -CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/test/runtests.jl b/test/runtests.jl index 72ec00b89..8d1979d17 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -43,7 +43,7 @@ if (GROUP == "All") || (GROUP == "Core") end if (GROUP == "CUDA_Ext")# || (GROUP == "All") - Pkg.activate("gpu") + Pkg.activate("ext-test/gpu") Pkg.develop(PackageSpec(path = dirname(@__DIR__))) Pkg.instantiate() include(joinpath(testdir, "ext-test", "gpu", "cuda_ext.jl")) From 4c6ad99a34397aeb25303b781307779bf1b2424f Mon Sep 17 00:00:00 2001 From: Yi-Te Huang Date: Mon, 4 Nov 2024 15:44:15 +0900 Subject: [PATCH 3/4] move imports into `if`-condition in tests --- test/core-test/code_quality.jl | 2 -- test/ext-test/gpu/cuda_ext.jl | 7 ------- test/runtests.jl | 21 +++++++++++++++++---- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/test/core-test/code_quality.jl b/test/core-test/code_quality.jl index 724639a31..5effb97d1 100644 --- a/test/core-test/code_quality.jl +++ b/test/core-test/code_quality.jl @@ -1,5 +1,3 @@ -using Aqua, JET - @testset "Code quality" verbose = true begin @testset "Aqua.jl" begin Aqua.test_all(QuantumToolbox; ambiguities = false, unbound_args = false) diff --git a/test/ext-test/gpu/cuda_ext.jl b/test/ext-test/gpu/cuda_ext.jl index f8c7f1f8d..20219b424 100644 --- a/test/ext-test/gpu/cuda_ext.jl +++ b/test/ext-test/gpu/cuda_ext.jl @@ -1,10 +1,3 @@ -using CUDA -using CUDA.CUSPARSE -CUDA.allowscalar(false) # Avoid unexpected scalar indexing - -QuantumToolbox.about() -CUDA.versioninfo() - @testset "CUDA Extension" verbose = true begin ψdi = Qobj(Int64[1, 0]) ψdf = Qobj(Float64[1, 0]) diff --git a/test/runtests.jl b/test/runtests.jl index 8d1979d17..f737ad6ad 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,9 +1,5 @@ using Test using Pkg -using QuantumToolbox -using QuantumToolbox: position, momentum -using Random -using SciMLOperators const GROUP = get(ENV, "GROUP", "All") @@ -31,10 +27,18 @@ core_tests = [ ] if (GROUP == "All") || (GROUP == "Code-Quality") + using QuantumToolbox + using Aqua, JET + include(joinpath(testdir, "core-test", "code_quality.jl")) end if (GROUP == "All") || (GROUP == "Core") + using QuantumToolbox + import QuantumToolbox: position, momentum + import Random + import SciMLOperators: MatrixOperator + QuantumToolbox.about() for test in core_tests @@ -46,5 +50,14 @@ if (GROUP == "CUDA_Ext")# || (GROUP == "All") Pkg.activate("ext-test/gpu") Pkg.develop(PackageSpec(path = dirname(@__DIR__))) Pkg.instantiate() + + using QuantumToolbox + using CUDA + using CUDA.CUSPARSE + CUDA.allowscalar(false) # Avoid unexpected scalar indexing + + QuantumToolbox.about() + CUDA.versioninfo() + include(joinpath(testdir, "ext-test", "gpu", "cuda_ext.jl")) end From 00c6a921a2fb0d90b8abb673f55a52c53f1172ff Mon Sep 17 00:00:00 2001 From: Yi-Te Huang Date: Mon, 4 Nov 2024 15:58:17 +0900 Subject: [PATCH 4/4] add missing imports --- test/runtests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index f737ad6ad..20f72b057 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -36,7 +36,7 @@ end if (GROUP == "All") || (GROUP == "Core") using QuantumToolbox import QuantumToolbox: position, momentum - import Random + import Random: MersenneTwister import SciMLOperators: MatrixOperator QuantumToolbox.about()