Skip to content

Commit 54aad07

Browse files
authored
Skeletal tests for CuArray-backed MPSKit (#388)
1 parent 9eb78ef commit 54aad07

3 files changed

Lines changed: 71 additions & 0 deletions

File tree

.buildkite/pipeline.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
env:
2+
SECRET_CODECOV_TOKEN: ""
3+
4+
steps:
5+
- label: "Julia v1 -- CUDA"
6+
plugins:
7+
- JuliaCI/julia#v1:
8+
version: "1"
9+
- JuliaCI/julia-test#v1: ~
10+
- JuliaCI/julia-coverage#v1:
11+
dirs:
12+
- src
13+
- ext
14+
agents:
15+
queue: "juliagpu"
16+
cuda: "*"
17+
if: build.message !~ /\[skip tests\]/
18+
timeout_in_minutes: 30
19+
20+
- label: "Julia LTS -- CUDA"
21+
plugins:
22+
- JuliaCI/julia#v1:
23+
version: "1.10" # "lts" isn't valid
24+
- JuliaCI/julia-test#v1: ~
25+
- JuliaCI/julia-coverage#v1:
26+
dirs:
27+
- src
28+
- ext
29+
agents:
30+
queue: "juliagpu"
31+
cuda: "*"
32+
if: build.message !~ /\[skip tests\]/
33+
timeout_in_minutes: 30

test/cuda/cu_adapt.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Test
2+
using MPSKit
3+
using TensorKit
4+
using CUDA, cuTENSOR, Adapt
5+
6+
@testset "Adapting to CuArray" begin
7+
# start from random operators
8+
L = 4
9+
T = ComplexF64
10+
11+
for V in (ℂ^2, U1Space(0 => 1, 1 => 1))
12+
O₁ = rand(T, V^L, V^L)
13+
O₂ = rand(T, space(O₁))
14+
O₃ = rand(real(T), space(O₁))
15+
16+
# create MPO and convert it back to see if it is the same
17+
mpo₁ = adapt(CuArray, FiniteMPO(O₁))
18+
mpo₂ = adapt(CuArray, FiniteMPO(O₂))
19+
mpo₃ = adapt(CuArray, FiniteMPO(O₃))
20+
21+
@test isfinite(mpo₁)
22+
@test isfinite(typeof(mpo₁))
23+
@test GeometryStyle(typeof(mpo₁)) == FiniteChainStyle()
24+
@test GeometryStyle(mpo₁) == FiniteChainStyle()
25+
@test OperatorStyle(typeof(mpo₁)) == MPOStyle()
26+
@test TensorKit.storagetype(mpo₁) == CuVector{T, 1, CUDA.DeviceMemory}
27+
@test TensorKit.storagetype(mpo₂) == CuVector{T, 1, CUDA.DeviceMemory}
28+
@test TensorKit.storagetype(mpo₃) == CuVector{T, 1, CUDA.DeviceMemory}
29+
end
30+
end

test/runtests.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,12 @@ init_code = quote
1212
end
1313

1414
args = parse_args(ARGS)
15+
is_buildkite = get(ENV, "BUILDKITE", "false") == "true"
16+
if is_buildkite
17+
empty!(testsuite)
18+
gpu_testsuite = find_tests(joinpath(@__DIR__, "cuda"))
19+
append!(testsuite, gpu_testsuite)
20+
else
21+
filter!(!(startswith("cuda") first), testsuite)
22+
end
1523
runtests(MPSKit, args; testsuite, init_code)

0 commit comments

Comments
 (0)