Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions test/ext-test/cpu/arbitrary_precision/arbitrary_precision.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
setprecision(128) # Instead of 256. This speeds up the tests.

using QuantumToolbox
using LinearAlgebra
using SparseArrays
using Sparspak
using GenericSchur

QuantumToolbox.about()

@testset "Arbitrary Precision" verbose = true begin
N = 20
Δ = 1.0
Expand Down
9 changes: 9 additions & 0 deletions test/ext-test/cpu/autodiff/autodiff.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
using QuantumToolbox
using ForwardDiff
using Enzyme
using Mooncake
using SciMLSensitivity
using SciMLSensitivity: MooncakeVJP

QuantumToolbox.about()

# ---- SESOLVE ----
const ψ0_sesolve = fock(2, 1)
t_max = 10
Expand Down
5 changes: 5 additions & 0 deletions test/ext-test/cpu/makie/makie_ext.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
using QuantumToolbox
# CarioMakie is imported in the following script

QuantumToolbox.about()

@testset "Makie Extension" verbose = true begin
ψ = normalize(coherent(50, 5.0) + coherent(50, -5.0))
xvec = yvec = -15.0:0.1:15.0
Expand Down
11 changes: 11 additions & 0 deletions test/ext-test/gpu/cuda_ext.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
using QuantumToolbox
import LinearAlgebra: Diagonal
import SparseArrays: SparseMatrixCSC
using CUDA
using CUDA.CUSPARSE
using CUDSS
using LinearSolve

QuantumToolbox.about()
CUDA.versioninfo()

@testset "CUDA Extension" verbose = true begin
# Test that scalar indexing is disallowed
@test_throws ErrorException CUDA.rand(1)[1]
Expand Down
121 changes: 47 additions & 74 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,38 @@ using Test
using TestItemRunner
using Pkg

const GROUP_LIST = String["All", "Core", "Code-Quality", "AutoDiff_Ext", "Makie_Ext", "CUDA_Ext", "Arbitrary-Precision"]
const testdir = dirname(@__FILE__)

# Define the paths to the extension tests
const EXTENSION_PATHS = Dict(
"AutoDiff_Ext" => joinpath(testdir, "ext-test", "cpu", "autodiff"),
"Makie_Ext" => joinpath(testdir, "ext-test", "cpu", "makie"),
"CUDA_Ext" => joinpath(testdir, "ext-test", "gpu"),
"Arbitrary-Precision" => joinpath(testdir, "ext-test", "cpu", "arbitrary_precision"),
)
const EXTENSION_LIST = collect(keys(EXTENSION_PATHS))

# Handle the GROUP environment variable to determine which tests to run
const GROUP = get(ENV, "GROUP", "All")
const GROUP_LIST = String[
"All",
"Core",
"Code-Quality",
EXTENSION_LIST...,
]
(GROUP in GROUP_LIST) || throw(ArgumentError("Unknown GROUP = $GROUP\nThe allowed groups are: $GROUP_LIST\n"))

# Core tests
# function to set up the environment for subtests
function setup_subtest_env(path::String)
Pkg.activate(path)
Pkg.develop(PackageSpec(path = dirname(@__DIR__)))
Pkg.update()
return nothing
end

######################################
# Core tests (use TestItemRunner.jl) #
######################################
if (GROUP == "All") || (GROUP == "Core")
import QuantumToolbox

Expand All @@ -21,85 +47,32 @@ end
# Use traditional Test.jl instead of TestItemRunner.jl for other tests #
########################################################################

const testdir = dirname(@__FILE__)

# Code Quality tests
if (GROUP == "All") || (GROUP == "Code-Quality")
Pkg.activate("core-test/code-quality")
Pkg.develop(PackageSpec(path = dirname(@__DIR__)))
Pkg.update()
path = joinpath(testdir, "core-test", "code-quality")
setup_subtest_env(path)

using QuantumToolbox
using Aqua, JET

(GROUP == "Code-Quality") && QuantumToolbox.about() # print version info. for code quality CI in GitHub

include(joinpath(testdir, "core-test", "code-quality", "code_quality.jl"))
include(joinpath(path, "code_quality.jl"))
end

if (GROUP == "AutoDiff_Ext")
Pkg.activate("ext-test/cpu/autodiff")
Pkg.develop(PackageSpec(path = dirname(@__DIR__)))
Pkg.update()

println(Pkg.status())

using QuantumToolbox
using ForwardDiff
using Enzyme
using Mooncake
using SciMLSensitivity
using SciMLSensitivity: MooncakeVJP

QuantumToolbox.about()

include(joinpath(testdir, "ext-test", "cpu", "autodiff", "autodiff.jl"))
end

if (GROUP == "Makie_Ext")
Pkg.activate("ext-test/cpu/makie")
Pkg.develop(PackageSpec(path = dirname(@__DIR__)))
Pkg.update()

using QuantumToolbox
QuantumToolbox.about()

# CarioMakie is imported in the following script
include(joinpath(testdir, "ext-test", "cpu", "makie", "makie_ext.jl"))
end

if (GROUP == "CUDA_Ext")
Pkg.activate("ext-test/gpu")
Pkg.develop(PackageSpec(path = dirname(@__DIR__)))
Pkg.update()

using QuantumToolbox
import LinearAlgebra: Diagonal
import SparseArrays: SparseMatrixCSC
using CUDA
using CUDA.CUSPARSE
using CUDSS
using LinearSolve

QuantumToolbox.about()
CUDA.versioninfo()

include(joinpath(testdir, "ext-test", "gpu", "cuda_ext.jl"))
end

if (GROUP == "Arbitrary-Precision")
Pkg.activate("ext-test/cpu/arbitrary_precision")
Pkg.develop(PackageSpec(path = dirname(@__DIR__)))
Pkg.update()

setprecision(128) # Instead of 256. This speeds up the tests.

using QuantumToolbox
using LinearAlgebra
using SparseArrays
using Sparspak
using GenericSchur

QuantumToolbox.about()

include(joinpath(testdir, "ext-test", "cpu", "arbitrary_precision", "arbitrary_precision.jl"))
# Extension tests
if GROUP ∈ EXTENSION_LIST
path = EXTENSION_PATHS[GROUP]
setup_subtest_env(path)

if GROUP == "AutoDiff_Ext"
println(Pkg.status())
include(joinpath(path, "autodiff.jl"))
elseif GROUP == "Makie_Ext"
include(joinpath(path, "makie_ext.jl"))
elseif GROUP == "CUDA_Ext"
include(joinpath(path, "cuda_ext.jl"))
elseif GROUP == "Arbitrary-Precision"
include(joinpath(path, "arbitrary_precision.jl"))
end
end
Loading