Skip to content

Commit 518af61

Browse files
kshyattlkdvosKatharine Hyatt
authored
Bump minimum version of CUDA and cuTENSOR (#404)
* Bump minimum version of CUDA and cuTENSOR * Some import fixes * Sources for Projects * Fix rand/randn * Cleanup * Update Project.toml * Fix import * Another module path --------- Co-authored-by: lkdvos <ldevos98@gmail.com> Co-authored-by: Katharine Hyatt <katharine.s.hyatt@gmail.com>
1 parent 9d8ea0f commit 518af61

6 files changed

Lines changed: 103 additions & 105 deletions

File tree

.buildkite/pipeline.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ steps:
1414
agents:
1515
queue: "juliagpu"
1616
cuda: "*"
17-
commands: |
18-
unset LD_LIBRARY_PATH
1917
if: build.message !~ /\[skip tests\]/
2018
timeout_in_minutes: 90
2119
matrix:

Project.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ projects = ["test", "docs"]
4141
[compat]
4242
Adapt = "4"
4343
AMDGPU = "2"
44-
CUDA = "5.9"
44+
CUDA = "6"
4545
ChainRulesCore = "1"
4646
Dictionaries = "0.4"
4747
FiniteDifferences = "0.12"
4848
LRUCache = "1.0.2"
4949
LinearAlgebra = "1"
50-
MatrixAlgebraKit = "0.6.5"
51-
Mooncake = "0.5"
50+
MatrixAlgebraKit = "0.6.6"
51+
Mooncake = "0.5.27"
5252
OhMyThreads = "0.8.0"
5353
Printf = "1"
5454
Random = "1"
@@ -58,5 +58,5 @@ TensorKitSectors = "0.3.7"
5858
TensorOperations = "5.1"
5959
TupleTools = "1.5"
6060
VectorInterface = "0.4.8, 0.5"
61-
cuTENSOR = "2"
61+
cuTENSOR = "6"
6262
julia = "1.10"

ext/TensorKitCUDAExt/TensorKitCUDAExt.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module TensorKitCUDAExt
22

3-
using CUDA, CUDA.CUBLAS, CUDA.CUSOLVER, LinearAlgebra
3+
using CUDA, CUDA.cuBLAS, CUDA.cuSOLVER, CUDA.cuRAND, LinearAlgebra
44
using CUDA: @allowscalar
55
using cuTENSOR: cuTENSOR
6+
import CUDA.cuRAND: rand as curand, rand! as curand!, randn as curandn, randn! as curandn!
67
using Strided: StridedViews
7-
import CUDA: rand as curand, rand! as curand!, randn as curandn, randn! as curandn!
8-
using CUDA.KernelAbstractions: @kernel, @index, get_backend
8+
using CUDA.CUDACore.KernelAbstractions: @kernel, @index, get_backend
99

1010
using TensorKit
1111
using TensorKit.Factorizations

ext/TensorKitCUDAExt/cutensormap.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,5 @@ for f in (:sqrt, :log, :asin, :acos, :acosh, :atanh, :acoth)
170170
end
171171

172172
function TensorKit._add_transform_multi!(tdst::CuTensorMap, tsrc, p, (U, structs_dst, structs_src)::Tuple{<:Array, TD, TS}, buffers, alpha, beta, backend...) where {TD, TS}
173-
return TensorKit._add_transform_multi!(tdst, tsrc, p, (CUDA.Adapt.adapt(CuArray, U), structs_dst, structs_src), buffers, alpha, beta, backend...)
173+
return TensorKit._add_transform_multi!(tdst, tsrc, p, (CUDA.CUDACore.Adapt.adapt(CuArray, U), structs_dst, structs_src), buffers, alpha, beta, backend...)
174174
end

test/cuda/factorizations.jl

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Adapt, CUDA, cuTENSOR
1+
using Adapt, CUDA, CUDA.cuRAND, cuTENSOR
22
using Test, TestExtras
33
using TensorKit
44
using LinearAlgebra: LinearAlgebra
@@ -25,10 +25,10 @@ for V in spacelist
2525
@testset "QR decomposition" begin
2626
for T in eltypes,
2727
t in (
28-
CUDA.rand(T, W, W), CUDA.rand(T, W, W)',
29-
CUDA.rand(T, (V1 V2 V3), (V4 V5)'), CUDA.rand(T, (V1 V2 V3), (V4 V5)')',
30-
CUDA.rand(T, (V1 V2)', (V3 V4 V5)), CUDA.rand(T, (V1 V2)', (V3 V4 V5))',
31-
DiagonalTensorMap(CUDA.rand(T, reduceddim(V1)), V1),
28+
cuRAND.rand(T, W, W), cuRAND.rand(T, W, W)',
29+
cuRAND.rand(T, (V1 V2 V3), (V4 V5)'), cuRAND.rand(T, (V1 V2 V3), (V4 V5)')',
30+
cuRAND.rand(T, (V1 V2)', (V3 V4 V5)), cuRAND.rand(T, (V1 V2)', (V3 V4 V5))',
31+
DiagonalTensorMap(cuRAND.rand(T, reduceddim(V1)), V1),
3232
)
3333

3434
Q, R = @constinferred qr_full(t)
@@ -54,7 +54,7 @@ for V in spacelist
5454

5555
# empty tensor
5656
for T in eltypes
57-
t = CUDA.rand(T, V1 V2, zerospace(V1))
57+
t = cuRAND.rand(T, V1 V2, zerospace(V1))
5858

5959
Q, R = @constinferred qr_full(t)
6060
@test Q * R t
@@ -80,10 +80,10 @@ for V in spacelist
8080
@testset "LQ decomposition" begin
8181
for T in eltypes,
8282
t in (
83-
CUDA.rand(T, W, W), CUDA.rand(T, W, W)',
84-
CUDA.rand(T, (V1 V2), (V3 V4 V5)'), CUDA.rand(T, (V1 V2), (V3 V4 V5)')',
85-
CUDA.rand(T, (V1 V2 V3)', (V4 V5)), CUDA.rand(T, (V1 V2 V3)', (V4 V5))',
86-
DiagonalTensorMap(CUDA.rand(T, reduceddim(V1)), V1),
83+
cuRAND.rand(T, W, W), cuRAND.rand(T, W, W)',
84+
cuRAND.rand(T, (V1 V2), (V3 V4 V5)'), cuRAND.rand(T, (V1 V2), (V3 V4 V5)')',
85+
cuRAND.rand(T, (V1 V2 V3)', (V4 V5)), cuRAND.rand(T, (V1 V2 V3)', (V4 V5))',
86+
DiagonalTensorMap(cuRAND.rand(T, reduceddim(V1)), V1),
8787
)
8888

8989
L, Q = @constinferred lq_full(t)
@@ -105,7 +105,7 @@ for V in spacelist
105105

106106
for T in eltypes
107107
# empty tensor
108-
t = CUDA.rand(T, zerospace(V1), V1 V2)
108+
t = cuRAND.rand(T, zerospace(V1), V1 V2)
109109

110110
L, Q = @constinferred lq_full(t)
111111
@test L * Q t
@@ -131,10 +131,10 @@ for V in spacelist
131131
@testset "Polar decomposition" begin
132132
@testset for T in eltypes,
133133
t in (
134-
CUDA.rand(T, W, W),
135-
CUDA.rand(T, (V1 V2 V3), (V4 V5)'),
136-
CUDA.rand(T, (V1 V2)', (V3 V4 V5))',
137-
DiagonalTensorMap(CUDA.rand(T, reduceddim(V1)), V1),
134+
cuRAND.rand(T, W, W),
135+
cuRAND.rand(T, (V1 V2 V3), (V4 V5)'),
136+
cuRAND.rand(T, (V1 V2)', (V3 V4 V5))',
137+
DiagonalTensorMap(cuRAND.rand(T, reduceddim(V1)), V1),
138138
)
139139

140140
@assert domain(t) codomain(t)
@@ -150,10 +150,10 @@ for V in spacelist
150150

151151
@testset for T in eltypes,
152152
t in (
153-
CUDA.rand(T, W, W),
154-
CUDA.rand(T, (V1 V2), (V3 V4 V5)'),
155-
CUDA.rand(T, (V1 V2 V3)', (V4 V5))',
156-
DiagonalTensorMap(CUDA.rand(T, reduceddim(V1)), V1),
153+
cuRAND.rand(T, W, W),
154+
cuRAND.rand(T, (V1 V2), (V3 V4 V5)'),
155+
cuRAND.rand(T, (V1 V2 V3)', (V4 V5))',
156+
DiagonalTensorMap(cuRAND.rand(T, reduceddim(V1)), V1),
157157
)
158158

159159
@assert codomain(t) domain(t)
@@ -171,10 +171,10 @@ for V in spacelist
171171
@testset "SVD" begin
172172
for T in eltypes,
173173
t in (
174-
CUDA.rand(T, W, W), CUDA.rand(T, W, W)',
175-
CUDA.rand(T, (V1 V2 V3), (V4 V5)'), CUDA.rand(T, (V1 V2)', (V3 V4 V5))',
176-
CUDA.rand(T, (V1 V2), (V3 V4 V5)'), CUDA.rand(T, (V1 V2 V3)', (V4 V5))',
177-
DiagonalTensorMap(CUDA.rand(T, reduceddim(V1)), V1),
174+
cuRAND.rand(T, W, W), cuRAND.rand(T, W, W)',
175+
cuRAND.rand(T, (V1 V2 V3), (V4 V5)'), cuRAND.rand(T, (V1 V2)', (V3 V4 V5))',
176+
cuRAND.rand(T, (V1 V2), (V3 V4 V5)'), cuRAND.rand(T, (V1 V2 V3)', (V4 V5))',
177+
DiagonalTensorMap(cuRAND.rand(T, reduceddim(V1)), V1),
178178
)
179179

180180
u, s, vᴴ = @constinferred svd_full(t)
@@ -222,8 +222,8 @@ for V in spacelist
222222

223223
# empty tensor
224224
for T in eltypes, t in (
225-
CUDA.rand(T, W, zerospace(V1)),
226-
CUDA.rand(T, zerospace(V1), W),
225+
cuRAND.rand(T, W, zerospace(V1)),
226+
cuRAND.rand(T, zerospace(V1), W),
227227
)
228228
U, S, Vᴴ = @constinferred svd_full(t)
229229
@test U * S * Vᴴ t
@@ -239,10 +239,10 @@ for V in spacelist
239239
@testset "truncated SVD" begin
240240
for T in eltypes,
241241
t in (
242-
CUDA.randn(T, W, W), CUDA.randn(T, W, W)',
243-
CUDA.randn(T, (V1 V2 V3), (V4 V5)'), CUDA.randn(T, (V1 V2)', (V3 V4 V5))',
244-
CUDA.randn(T, (V1 V2), (V3 V4 V5)'), CUDA.randn(T, (V1 V2 V3)', (V4 V5))',
245-
DiagonalTensorMap(CUDA.randn(T, reduceddim(V1)), V1),
242+
cuRAND.randn(T, W, W), cuRAND.randn(T, W, W)',
243+
cuRAND.randn(T, (V1 V2 V3), (V4 V5)'), cuRAND.randn(T, (V1 V2)', (V3 V4 V5))',
244+
cuRAND.randn(T, (V1 V2), (V3 V4 V5)'), cuRAND.randn(T, (V1 V2 V3)', (V4 V5))',
245+
DiagonalTensorMap(cuRAND.randn(T, reduceddim(V1)), V1),
246246
)
247247

248248
@constinferred normalize!(t)
@@ -307,10 +307,10 @@ for V in spacelist
307307
@testset "Eigenvalue decomposition" begin
308308
for T in eltypes,
309309
t in (
310-
CUDA.rand(T, V1, V1),
311-
CUDA.rand(T, W, W),
312-
CUDA.rand(T, W, W)',
313-
# DiagonalTensorMap(CUDA.rand(T, reduceddim(V1)), V1),
310+
cuRAND.rand(T, V1, V1),
311+
cuRAND.rand(T, W, W),
312+
cuRAND.rand(T, W, W)',
313+
# DiagonalTensorMap(cuRAND.rand(T, reduceddim(V1)), V1),
314314
)
315315

316316
d, v = @constinferred eig_full(t)
@@ -367,15 +367,15 @@ for V in spacelist
367367
@testset "Condition number and rank" begin
368368
for T in eltypes,
369369
t in (
370-
CUDA.rand(T, W, W), CUDA.rand(T, W, W)',
371-
CUDA.rand(T, (V1 V2 V3), (V4 V5)'), CUDA.rand(T, (V1 V2)', (V3 V4 V5))',
372-
CUDA.rand(T, (V1 V2), (V3 V4 V5)'), CUDA.rand(T, (V1 V2 V3)', (V4 V5))',
373-
DiagonalTensorMap(CUDA.rand(T, reduceddim(V1)), V1),
370+
cuRAND.rand(T, W, W), cuRAND.rand(T, W, W)',
371+
cuRAND.rand(T, (V1 V2 V3), (V4 V5)'), cuRAND.rand(T, (V1 V2)', (V3 V4 V5))',
372+
cuRAND.rand(T, (V1 V2), (V3 V4 V5)'), cuRAND.rand(T, (V1 V2 V3)', (V4 V5))',
373+
DiagonalTensorMap(cuRAND.rand(T, reduceddim(V1)), V1),
374374
)
375375

376376
d1, d2 = dim(codomain(t)), dim(domain(t))
377377
r = rank(t)
378-
@test r == min(d1, d2)
378+
@test r min(d1, d2)
379379
@test typeof(r) == typeof(d1)
380380
M = left_null(t)
381381
@test @constinferred(rank(M)) + r d1
@@ -387,15 +387,15 @@ for V in spacelist
387387
@test @constinferred(cond(u)) one(real(T))
388388
@test @constinferred(rank(u)) == dim(V1 V2)
389389

390-
t = CUDA.rand(T, zerospace(V1), W)
390+
t = cuRAND.rand(T, zerospace(V1), W)
391391
@test rank(t) == 0
392-
t2 = CUDA.rand(T, zerospace(V1) * zerospace(V2), zerospace(V1) * zerospace(V2))
392+
t2 = cuRAND.rand(T, zerospace(V1) * zerospace(V2), zerospace(V1) * zerospace(V2))
393393
@test rank(t2) == 0
394394
@test cond(t2) == 0.0
395395
end
396396
for T in eltypes, t in (
397-
CUDA.rand(T, W, W),
398-
CUDA.rand(T, W, W)',
397+
cuRAND.rand(T, W, W),
398+
cuRAND.rand(T, W, W)',
399399
)
400400
project_hermitian!(t)
401401
vals = @constinferred LinearAlgebra.eigvals(t)
@@ -408,10 +408,10 @@ for V in spacelist
408408
@testset "Hermitian projections" begin
409409
for T in eltypes,
410410
t in (
411-
CUDA.rand(T, V1, V1),
412-
CUDA.rand(T, W, W),
413-
CUDA.rand(T, W, W)',
414-
DiagonalTensorMap(CUDA.rand(T, reduceddim(V1)), V1),
411+
cuRAND.rand(T, V1, V1),
412+
cuRAND.rand(T, W, W),
413+
cuRAND.rand(T, W, W)',
414+
DiagonalTensorMap(cuRAND.rand(T, reduceddim(V1)), V1),
415415
)
416416
normalize!(t)
417417
noisefactor = eps(real(T))^(3 / 4)
@@ -441,10 +441,10 @@ for V in spacelist
441441
@testset "Isometric projections" begin
442442
for T in eltypes,
443443
t in (
444-
CUDA.randn(T, W, W),
445-
CUDA.randn(T, W, W)',
446-
CUDA.randn(T, (V1 V2 V3), (V4 V5)'),
447-
CUDA.randn(T, (V1 V2)', (V3 V4 V5))',
444+
cuRAND.randn(T, W, W),
445+
cuRAND.randn(T, W, W)',
446+
cuRAND.randn(T, (V1 V2 V3), (V4 V5)'),
447+
cuRAND.randn(T, (V1 V2)', (V3 V4 V5))',
448448
)
449449
t2 = project_isometric(t)
450450
@test isisometric(t2)
@@ -459,7 +459,7 @@ for V in spacelist
459459

460460
# test that t2 is closer to A then any other isometry
461461
for k in 1:10
462-
δt = CUDA.randn!(similar(t))
462+
δt = cuRAND.randn!(similar(t))
463463
t3 = project_isometric(t + δt / 100)
464464
@test norm(t - t3) > norm(t - t2)
465465
end

0 commit comments

Comments
 (0)