Skip to content

Commit c8d380b

Browse files
committed
Forgot about cuTENSOR whoops
1 parent 0e93996 commit c8d380b

2 files changed

Lines changed: 24 additions & 29 deletions

File tree

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,4 @@ test = ["Aqua", "Adapt", "CUDA", "cuTENSOR", "Pkg", "Test", "TestExtras", "Plots
7979

8080
[sources]
8181
TensorKit = {url="https://github.com/QuantumKitHub/TensorKit.jl", rev="ksh/cuda_tweaks"}
82+
TensorOperations = {path="/home/kshyatt/.julia/dev/TensorOperations"}

test/cuda/operators.jl

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using MPSKit
44
using MPSKit: GeometryStyle, FiniteChainStyle, InfiniteChainStyle, OperatorStyle, MPOStyle
55
using TensorKit
66
using TensorKit:
7-
using Adapt, CUDA
7+
using Adapt, CUDA, cuTENSOR
88

99
@testset "CuFiniteMPO" begin
1010
# start from random operators
@@ -34,51 +34,45 @@ using Adapt, CUDA
3434
@test Vright[i] == right_virtualspace(mpo₁, i)
3535
end
3636

37-
# needs tensoradd support for CuStridedView
38-
#=@test convert(TensorMap, mpo₁) ≈ O₁
37+
@test convert(TensorMap, mpo₁) O₁
3938
@test convert(TensorMap, -mpo₂) -O₂
40-
@test convert(TensorMap, @constinferred complex(mpo₃)) ≈ complex(O₃)=#
39+
@test convert(TensorMap, @constinferred complex(mpo₃)) complex(O₃)
4140

4241
# test scalar multiplication
4342
α = rand(T)
44-
# needs tensoradd support for CuStridedView
45-
#@test convert(TensorMap, α * mpo₁) ≈ α * O₁
46-
#@test convert(TensorMap, mpo₁ * α) ≈ O₁ * α
47-
#@test α * mpo₃ ≈ α * complex(mpo₃) atol = 1.0e-6
43+
@test convert(TensorMap, α * mpo₁) α * O₁
44+
@test convert(TensorMap, mpo₁ * α) O₁ * α
45+
@test α * mpo₃ α * complex(mpo₃) atol = 1.0e-6
4846

4947
# test addition and multiplication
50-
# needs tensoradd support for CuStridedView
51-
#=@test convert(TensorMap, mpo₁ + mpo₂) ≈ O₁ + O₂
48+
@test convert(TensorMap, mpo₁ + mpo₂) O₁ + O₂
5249
@test convert(TensorMap, mpo₁ + mpo₃) O₁ + O₃
5350
@test convert(TensorMap, mpo₁ * mpo₂) O₁ * O₂
54-
@test convert(TensorMap, mpo₁ * mpo₃) ≈ O₁ * O₃=#
51+
@test convert(TensorMap, mpo₁ * mpo₃) O₁ * O₃
5552

5653
# test application to a state
5754
ψ₁ = adapt(CuArray, rand(T, domain(O₁)))
5855
ψ₂ = adapt(CuArray, rand(real(T), domain(O₂)))
59-
#mps₁ = adapt(CuArray, FiniteMPS(ψ₁))
60-
#mps₂ = adapt(CuArray, FiniteMPS(ψ₂))
56+
mps₁ = adapt(CuArray, FiniteMPS(ψ₁))
57+
mps₂ = adapt(CuArray, FiniteMPS(ψ₂))
6158

62-
#@test @constinferred GeometryStyle(mps₁, mpo₁, mps₁) == GeometryStyle(mps₁)
59+
@test @constinferred GeometryStyle(mps₁, mpo₁, mps₁) == GeometryStyle(mps₁)
6360

64-
# needs tensoradd support for CuStridedView
65-
#@test convert(TensorMap, mpo₁ * mps₁) ≈ O₁ * ψ₁
66-
#@test mpo₁ * ψ₁ ≈ O₁ * ψ₁
67-
#@test convert(TensorMap, mpo₃ * mps₁) ≈ O₃ * ψ₁
68-
#@test mpo₃ * ψ₁ ≈ O₃ * ψ₁
69-
#@test convert(TensorMap, mpo₁ * mps₂) ≈ O₁ * ψ₂
70-
#@test mpo₁ * ψ₂ ≈ O₁ * ψ₂
61+
@test convert(TensorMap, mpo₁ * mps₁) O₁ * ψ₁
62+
@test mpo₁ * ψ₁ O₁ * ψ₁
63+
@test convert(TensorMap, mpo₃ * mps₁) O₃ * ψ₁
64+
@test mpo₃ * ψ₁ O₃ * ψ₁
65+
@test convert(TensorMap, mpo₁ * mps₂) O₁ * ψ₂
66+
@test mpo₁ * ψ₂ O₁ * ψ₂
7167

72-
# needs tensoradd support for CuStridedView
73-
#@test dot(mps₁, mpo₁, mps₁) ≈ dot(ψ₁, O₁, ψ₁)
74-
#@test dot(mps₁, mpo₁, mps₁) ≈ dot(mps₁, mpo₁ * mps₁)
68+
@test dot(mps₁, mpo₁, mps₁) dot(ψ₁, O₁, ψ₁)
69+
@test dot(mps₁, mpo₁, mps₁) dot(mps₁, mpo₁ * mps₁)
7570
# test conversion to and from mps
76-
#mpomps₁ = convert(FiniteMPS, mpo₁)
77-
#mpompsmpo₁ = convert(FiniteMPO, mpomps₁)
71+
mpomps₁ = convert(FiniteMPS, mpo₁)
72+
mpompsmpo₁ = convert(FiniteMPO, mpomps₁)
7873

79-
#@test convert(FiniteMPO, mpomps₁) ≈ mpo₁ rtol = 1.0e-6
74+
@test convert(FiniteMPO, mpomps₁) mpo₁ rtol = 1.0e-6
8075

81-
# needs tensoradd support for CuStridedView
82-
#@test dot(mpomps₁, mpomps₁) ≈ dot(mpo₁, mpo₁)
76+
@test dot(mpomps₁, mpomps₁) dot(mpo₁, mpo₁)
8377
end
8478
end

0 commit comments

Comments
 (0)