Skip to content

Commit 7690941

Browse files
committed
Try using truncation on CUDA
1 parent fc83d58 commit 7690941

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

Project.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,7 @@ cuTENSOR = "011b41b2-24ef-40a8-b3eb-fa098493e9e1"
7777

7878
[targets]
7979
test = ["ArgParse", "Adapt", "Aqua", "Combinatorics", "CUDA", "cuTENSOR", "GPUArrays", "LinearAlgebra", "SafeTestsets", "TensorOperations", "Test", "TestExtras", "ChainRulesCore", "ChainRulesTestUtils", "FiniteDifferences", "Zygote"]
80+
81+
[sources]
82+
GPUArrays = {rev = "master", url = "https://github.com/JuliaGPU/GPUArrays.jl"}
83+
MatrixAlgebraKit = {rev = "main", url = "https://github.com/QuantumKitHub/MatrixAlgebraKit.jl"}

test/cuda/factorizations.jl

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Adapt, CUDA, cuTENSOR
1+
using Adapt, GPUArrays, CUDA, cuTENSOR
22
using Test, TestExtras
33
using TensorKit
44
using LinearAlgebra: LinearAlgebra
@@ -229,17 +229,17 @@ for V in spacelist
229229
@test isisometric(N)
230230
@test norm(N' * t) 0 atol = 100 * eps(norm(t))
231231

232-
#N = @constinferred left_null(t; trunc = (; atol = 100 * eps(norm(t))))
233-
#@test isisometric(N)
234-
#@test norm(N' * t) ≈ 0 atol = 100 * eps(norm(t))
232+
#=N = @constinferred left_null(t; trunc = (; atol = 100 * eps(norm(t))))
233+
@test isisometric(N)
234+
@test norm(N' * t) ≈ 0 atol = 100 * eps(norm(t))=#
235235

236236
Nᴴ = @constinferred right_null(t; alg = :svd)
237237
@test isisometric(Nᴴ; side = :right)
238238
@test norm(t * Nᴴ') 0 atol = 100 * eps(norm(t))
239239

240-
#Nᴴ = @constinferred right_null(t; trunc = (; atol = 100 * eps(norm(t))))
241-
#@test isisometric(Nᴴ; side = :right)
242-
#@test norm(t * Nᴴ') ≈ 0 atol = 100 * eps(norm(t))
240+
#=Nᴴ = @constinferred right_null(t; trunc = (; atol = 100 * eps(norm(t))))
241+
@test isisometric(Nᴴ; side = :right)
242+
@test norm(t * Nᴴ') ≈ 0 atol = 100 * eps(norm(t))=#
243243
end
244244

245245
# empty tensor
@@ -262,11 +262,11 @@ for V in spacelist
262262
for T in eltypes,
263263
t in (
264264
CUDA.randn(T, W, W),
265-
#CUDA.randn(T, W, W)',
265+
CUDA.randn(T, W, W)',
266266
CUDA.randn(T, W, V4),
267267
CUDA.randn(T, V4, W),
268-
#CUDA.randn(T, W, V4)',
269-
#CUDA.randn(T, V4, W)',
268+
CUDA.randn(T, W, V4)',
269+
CUDA.randn(T, V4, W)',
270270
DiagonalTensorMap(CUDA.randn(T, reduceddim(V1)), V1),
271271
)
272272
@@ -327,7 +327,7 @@ for V in spacelist
327327
@test minimum(diagview(S5)) >= λ
328328
@test dim(domain(S5)) ≤ nvals
329329
end
330-
end=# # TODO
330+
end=#
331331

332332
@testset "Eigenvalue decomposition" begin
333333
for T in eltypes,
@@ -349,10 +349,10 @@ for V in spacelist
349349
@test @constinferred isposdef(vdv)
350350
t isa DiagonalTensorMap || @test !isposdef(t) # unlikely for non-hermitian map
351351

352-
#=nvals = round(Int, dim(domain(t)) / 2)
352+
nvals = round(Int, dim(domain(t)) / 2)
353353
d, v = @constinferred eig_trunc(t; trunc = truncrank(nvals))
354354
@test t * v v * d
355-
@test dim(domain(d)) ≤ nvals=#
355+
@test dim(domain(d)) nvals
356356

357357
t2 = @constinferred project_hermitian(t)
358358
D, V = eigen(t2)
@@ -380,10 +380,9 @@ for V in spacelist
380380
@test isposdef(t2 - λ * one(t) + 0.1 * one(t2))
381381
@test !isposdef(t2 - λ * one(t) - 0.1 * one(t2))
382382

383-
# TODO
384-
#=d, v = @constinferred eigh_trunc(t2; trunc = truncrank(nvals))
383+
d, v = @constinferred eigh_trunc(t2; trunc = truncrank(nvals))
385384
@test t2 * v v * d
386-
@test dim(domain(d)) ≤ nvals=#
385+
@test dim(domain(d)) nvals
387386
end
388387
end
389388

0 commit comments

Comments
 (0)