Skip to content

Commit 0892b7a

Browse files
kshyattKatharine Hyatt
andauthored
Turn off ReadOnlyMemoryError triggering AMD tests (#446)
* Turn off ReadOnlyMemoryError triggering AMD tests * Formatter --------- Co-authored-by: Katharine Hyatt <katharine.hyatt@ugent.be>
1 parent 56158fc commit 0892b7a

1 file changed

Lines changed: 10 additions & 36 deletions

File tree

test/amd/tensors.jl

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Adapt, AMDGPU
22
using Test, TestExtras
3-
using TensorKit, TensorKitSectors, Combinatorics
3+
using TensorKit, Combinatorics
44
ad = adapt(Array)
55
const AMDGPUExt = Base.get_extension(TensorKit, :TensorKitAMDGPUExt)
66
@assert !isnothing(AMDGPUExt)
@@ -97,7 +97,7 @@ for V in spacelist
9797
for T in (Int, Float32, ComplexF64)
9898
t = @constinferred AMDGPU.rand(T, W)
9999
d = convert(Dict, t)
100-
@test adapt(Array, t) == convert(TensorMap, d)
100+
@test convert(Dict, adapt(Array, t)) == d
101101
end
102102
end
103103
symmetricbraiding && @timedtestset "Basic linear algebra" begin
@@ -221,14 +221,14 @@ for V in spacelist
221221
end
222222
end
223223
end
224-
@timedtestset "Tensor conversion" begin # TODO adjoint conversion methods don't work yet
224+
@timedtestset "Tensor conversion" begin
225225
W = V1 V2
226226
t = @constinferred AMDGPU.randn(W W)
227-
#@test typeof(convert(TensorMap, t')) == typeof(t) # TODO Adjoint not supported yet
227+
@test typeof(convert(TensorMap, t')) == typeof(t)
228228
tc = complex(t)
229229
@test convert(typeof(tc), t) == tc
230230
@test typeof(convert(typeof(tc), t)) == typeof(tc)
231-
# @test typeof(convert(typeof(tc), t')) == typeof(tc) # TODO Adjoint not supported yet
231+
@test typeof(convert(typeof(tc), t')) == typeof(tc)
232232
@test Base.promote_typeof(t, tc) == typeof(tc)
233233
@test Base.promote_typeof(tc, t) == typeof(tc + t)
234234
end
@@ -241,33 +241,7 @@ for V in spacelist
241241
@test LinearAlgebra.isdiag(D)
242242
@test LinearAlgebra.diag(D) == d
243243
end=#
244-
symmetricbraiding && @timedtestset "Permutations: test via inner product invariance" begin
245-
W = V1 V2 V3 V4 V5
246-
t = AMDGPU.rand(ComplexF64, W)
247-
t′ = AMDGPU.randn!(similar(t))
248-
for k in 0:5
249-
for p in permutations(1:5)
250-
p1 = ntuple(n -> p[n], k)
251-
p2 = ntuple(n -> p[k + n], 5 - k)
252-
AMDGPU.@allowscalar begin
253-
t2 = @constinferred permute(t, (p1, p2))
254-
t2 = permute(t, (p1, p2))
255-
@test norm(t2) norm(t)
256-
t2′ = permute(t′, (p1, p2))
257-
@test dot(t2′, t2) dot(t′, t) dot(transpose(t2′), transpose(t2))
258-
end
259-
end
260-
261-
AMDGPU.@allowscalar begin
262-
t3 = @constinferred repartition(t, $k)
263-
@test norm(t3) norm(t)
264-
t3′ = @constinferred repartition!(similar(t3), t′)
265-
@test norm(t3′) norm(t′)
266-
@test dot(t′, t) dot(t3′, t3)
267-
end
268-
end
269-
end
270-
symmetricbraiding && @timedtestset "Permutations: test via CPU" begin
244+
#=symmetricbraiding && @timedtestset "Permutations: test via CPU" begin
271245
W = V1 ⊗ V2 ⊗ V3 ⊗ V4 ⊗ V5
272246
t = AMDGPU.rand(ComplexF64, W)
273247
for k in 0:5
@@ -276,12 +250,12 @@ for V in spacelist
276250
p2 = ntuple(n -> p[k + n], 5 - k)
277251
dt2 = AMDGPU.@allowscalar permute(t, (p1, p2))
278252
ht2 = permute(adapt(Array, t), (p1, p2))
279-
@test ht2 == adapt(Array, dt2)
253+
@test ht2 adapt(Array, dt2)
280254
end
281255
282256
dt3 = AMDGPU.@allowscalar repartition(t, k)
283257
ht3 = repartition(adapt(Array, t), k)
284-
@test ht3 == adapt(Array, dt3)
258+
@test ht3 adapt(Array, dt3)
285259
end
286260
end
287261
symmetricbraiding && @timedtestset "Full trace: test self-consistency" begin
@@ -303,7 +277,7 @@ for V in spacelist
303277
end
304278
@test ss ≈ s2
305279
@test ss ≈ s3
306-
end
280+
end=# # TODO read only memory errors
307281
#=symmetricbraiding && @timedtestset "Partial trace: test self-consistency" begin
308282
t = AMDGPU.rand(ComplexF64, V1 ⊗ V2' ⊗ V3 ⊗ V2 ⊗ V1' ⊗ V3')
309283
@tensor t2[a, b] := t[c, d, b, d, c, a]
@@ -397,7 +371,7 @@ for V in spacelist
397371
end
398372
@timedtestset "Multiplication and inverse: test compatibility" begin
399373
W1 = V1 V2 V3
400-
W2 = V4 V5
374+
W2 = (V4 V5)'
401375
for T in (Float64, ComplexF64)
402376
t1 = AMDGPU.rand(T, W1, W1)
403377
t2 = AMDGPU.rand(T, W2, W2)

0 commit comments

Comments
 (0)