Skip to content

Commit 43ec214

Browse files
committed
Cut CI burden and retry things on 1.10
1 parent d917aa4 commit 43ec214

5 files changed

Lines changed: 185 additions & 188 deletions

File tree

‎test/enzyme-vi-to/add.jl‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,46 @@ using TensorKit, Enzyme, EnzymeTestUtils
33
using TensorOperations
44
using Random
55

6-
#spacelist = ad_spacelist(fast_tests)
7-
spacelist = [ad_spacelist(fast_tests)[1]]
6+
spacelist = ad_spacelist(fast_tests)
87
eltypes = (Float64, ComplexF64)
98

9+
is_ci = get(ENV, "CI", "false") == "true"
10+
11+
rTαs = is_ci ? (Active,) : (Active, Const)
12+
rTβs = is_ci ? (Active,) : (Active, Const)
13+
fTαs = is_ci ? (Duplicated,) : (Duplicated, Const)
14+
fTβs = is_ci ? (Duplicated,) : (Duplicated, Const)
15+
1016
@testset "Enzyme - VectorInterface (add!) $(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes
1117
atol = default_tol(T)
1218
rtol = default_tol(T)
1319

1420
α = randn(T)
1521
β = randn(T)
1622

17-
# see https://github.com/QuantumKitHub/TensorKit.jl/issues/457
18-
if VERSION < v"1.11.0-rc" && sectortype(eltype(V)) == Trivial
19-
CV = V[1] ⊗ V[2] ← V[4] ⊗ V[5]
20-
else
21-
CV = V[1] ⊗ V[2] ← V[3] ⊗ V[4] ⊗ V[5]
22-
end
23+
CV = V[1] ⊗ V[2] ← V[3] ⊗ V[4] ⊗ V[5]
2324
C = randn(T, CV)
2425
A = randn(T, CV)
2526
for TC in (Duplicated,), TA in (Duplicated,)
2627
C = randn(T, CV)
2728
A = randn(T, CV)
2829
EnzymeTestUtils.test_reverse(add!, TC, (C, TC), (A, TA); atol, rtol, testset_name = "add! reverse TC $TC TA $TA no α no β")
2930
EnzymeTestUtils.test_forward(add!, TC, (C, TC), (A, TA); atol, rtol, testset_name = "add! forward TC $TC TA $TA no α no β")
30-
for Tα in (Active, Const)
31+
for Tα in rTαs
3132
C = randn(T, CV)
3233
A = randn(T, CV)
3334
EnzymeTestUtils.test_reverse(add!, TC, (C, TC), (A, TA), (α, Tα); atol, rtol, testset_name = "add! reverse TC $TC TA $TA Tα $Tα no β")
34-
for Tβ in (Active, Const)
35+
for Tβ in rTβs
3536
C = randn(T, CV)
3637
A = randn(T, CV)
3738
EnzymeTestUtils.test_reverse(add!, TC, (C, TC), (A, TA), (α, Tα), (β, Tβ); atol, rtol, testset_name = "add! reverse TC $TC TA $TA Tα $Tα Tβ $Tβ")
3839
end
3940
end
40-
for Tα in (Duplicated, Const)
41+
for Tα in fTαs
4142
C = randn(T, CV)
4243
A = randn(T, CV)
4344
EnzymeTestUtils.test_forward(add!, TC, (C, TC), (A, TA), (α, Tα); atol, rtol, testset_name = "add! forward TC $TC TA $TA Tα $Tα no β")
44-
for Tβ in (Duplicated, Const)
45+
for Tβ in fTβs
4546
C = randn(T, CV)
4647
A = randn(T, CV)
4748
EnzymeTestUtils.test_forward(add!, TC, (C, TC), (A, TA), (α, Tα), (β, Tβ); atol, rtol, testset_name = "add! forward TC $TC TA $TA Tα $Tα Tβ $Tβ")

‎test/enzyme-vi-to/contract.jl‎

Lines changed: 120 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -9,131 +9,129 @@ is_ci = get(ENV, "CI", "false") == "true"
99
spacelist = ad_spacelist(fast_tests)
1010
eltypes = (Float64, ComplexF64)
1111

12-
if !(is_ci && Sys.iswindows() && VERSION < v"1.11.0-rc")
13-
@timedtestset "Enzyme - TensorOperations" begin
14-
@timedtestset verbose = true "$(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes
15-
atol = default_tol(T)
16-
rtol = default_tol(T)
17-
symmetricbraiding = BraidingStyle(sectortype(eltype(V))) isa SymmetricBraiding
18-
symmetricbraiding && @timedtestset "tensorcontract!" begin
19-
d = 0
20-
local V1, V2, V3
21-
# retry a couple times to make sure there are at least some nonzero elements
22-
for _ in 1:10
23-
k1 = rand(0:3)
24-
k2 = rand(0:2)
25-
k3 = rand(0:2)
26-
V1 = prod(v -> rand(Bool) ? v' : v, rand(V, k1); init = one(V[1]))
27-
V2 = prod(v -> rand(Bool) ? v' : v, rand(V, k2); init = one(V[1]))
28-
V3 = prod(v -> rand(Bool) ? v' : v, rand(V, k3); init = one(V[1]))
29-
d = min(dim(V1 ← V2), dim(V1' ← V2), dim(V2 ← V3), dim(V2' ← V3))
30-
d > 0 && break
31-
end
32-
ipA = randindextuple(length(V1) + length(V2))
33-
pA = _repartition(invperm(linearize(ipA)), length(V1))
34-
ipB = randindextuple(length(V2) + length(V3))
35-
pB = _repartition(invperm(linearize(ipB)), length(V2))
36-
pAB = randindextuple(length(V1) + length(V3))
12+
@timedtestset "Enzyme - TensorOperations" begin
13+
@timedtestset verbose = true "$(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes
14+
atol = default_tol(T)
15+
rtol = default_tol(T)
16+
symmetricbraiding = BraidingStyle(sectortype(eltype(V))) isa SymmetricBraiding
17+
symmetricbraiding && @timedtestset "tensorcontract!" begin
18+
d = 0
19+
local V1, V2, V3
20+
# retry a couple times to make sure there are at least some nonzero elements
21+
for _ in 1:10
22+
k1 = rand(0:3)
23+
k2 = rand(0:2)
24+
k3 = rand(0:2)
25+
V1 = prod(v -> rand(Bool) ? v' : v, rand(V, k1); init = one(V[1]))
26+
V2 = prod(v -> rand(Bool) ? v' : v, rand(V, k2); init = one(V[1]))
27+
V3 = prod(v -> rand(Bool) ? v' : v, rand(V, k3); init = one(V[1]))
28+
d = min(dim(V1 ← V2), dim(V1' ← V2), dim(V2 ← V3), dim(V2' ← V3))
29+
d > 0 && break
30+
end
31+
ipA = randindextuple(length(V1) + length(V2))
32+
pA = _repartition(invperm(linearize(ipA)), length(V1))
33+
ipB = randindextuple(length(V2) + length(V3))
34+
pB = _repartition(invperm(linearize(ipB)), length(V2))
35+
pAB = randindextuple(length(V1) + length(V3))
3736

38-
α = randn(T)
39-
β = randn(T)
40-
V2_conj = prod(conj, V2; init = one(V[1]))
41-
A = randn(T, permute(V1 ← V2, ipA))
42-
B = randn(T, permute(V2 ← V3, ipB))
43-
C = randn!(
44-
TensorOperations.tensoralloc_contract(
45-
T, A, pA, false, B, pB, false, pAB, Val(false)
46-
)
37+
α = randn(T)
38+
β = randn(T)
39+
V2_conj = prod(conj, V2; init = one(V[1]))
40+
A = randn(T, permute(V1 ← V2, ipA))
41+
B = randn(T, permute(V2 ← V3, ipB))
42+
C = randn!(
43+
TensorOperations.tensoralloc_contract(
44+
T, A, pA, false, B, pB, false, pAB, Val(false)
4745
)
46+
)
4847

49-
αβs = is_ci ? (((α, Active), (β, Active)),) : Iterators.product(((One(), Const), (α, Const), (α, Active)), ((Zero(), Const), (β, Const), (β, Active)))
50-
for (α_, β_) in αβs
51-
EnzymeTestUtils.test_reverse(
52-
TensorKit.blas_contract!, Duplicated,
53-
(copy(C), Duplicated), (A, Duplicated), (pA, Const),
54-
(B, Duplicated), (pB, Const), (pAB, Const),
55-
α_, β_,
56-
(TensorOperations.DefaultBackend(), Const),
57-
(TensorOperations.DefaultAllocator(), Const);
58-
atol, rtol,
59-
testset_name = "blas_contract! reverse α $α_ β $β_",
60-
)
61-
end
62-
αβs = is_ci ? (((α, Duplicated), (β, Duplicated)),) : Iterators.product(((One(), Const), (α, Const), (α, Duplicated)), ((Zero(), Const), (β, Const), (β, Duplicated)))
63-
for (α_, β_) in αβs
64-
EnzymeTestUtils.test_forward(
65-
TensorKit.blas_contract!, Duplicated,
66-
(copy(C), Duplicated), (A, Duplicated), (pA, Const),
67-
(B, Duplicated), (pB, Const), (pAB, Const),
68-
α_, β_,
69-
(TensorOperations.DefaultBackend(), Const),
70-
(TensorOperations.DefaultAllocator(), Const);
71-
atol, rtol,
72-
testset_name = "blas_contract! forward α $α_ β $β_",
73-
)
74-
end
75-
if !(T <: Real) && !is_ci
76-
EnzymeTestUtils.test_reverse(
77-
TensorKit.blas_contract!, Duplicated,
78-
(copy(C), Duplicated), (A, Duplicated), (pA, Const),
79-
(B, Duplicated), (pB, Const), (pAB, Const),
80-
(real(α), Active), (real(β), Active),
81-
(TensorOperations.DefaultBackend(), Const),
82-
(TensorOperations.DefaultAllocator(), Const);
83-
atol, rtol,
84-
testset_name = "blas_contract! reverse real(α) real(β)",
85-
)
86-
EnzymeTestUtils.test_reverse(
87-
TensorKit.blas_contract!, Duplicated,
88-
(copy(C), Duplicated), (real(A), Duplicated), (pA, Const),
89-
(B, Duplicated), (pB, Const), (pAB, Const),
90-
(real(α), Active), (real(β), Active),
91-
(TensorOperations.DefaultBackend(), Const),
92-
(TensorOperations.DefaultAllocator(), Const);
93-
atol, rtol,
94-
testset_name = "blas_contract! reverse real(A) real(α) real(β)",
95-
)
96-
EnzymeTestUtils.test_reverse(
97-
TensorKit.blas_contract!, Duplicated,
98-
(copy(C), Duplicated), (A, Duplicated), (pA, Const),
99-
(real(B), Duplicated), (pB, Const), (pAB, Const),
100-
(real(α), Active), (real(β), Active),
101-
(TensorOperations.DefaultBackend(), Const),
102-
(TensorOperations.DefaultAllocator(), Const);
103-
atol, rtol,
104-
testset_name = "blas_contract! reverse real(B) real(α) real(β)",
105-
)
106-
EnzymeTestUtils.test_forward(
107-
TensorKit.blas_contract!, Duplicated,
108-
(copy(C), Duplicated), (A, Duplicated), (pA, Const),
109-
(B, Duplicated), (pB, Const), (pAB, Const),
110-
(real(α), Active), (real(β), Active),
111-
(TensorOperations.DefaultBackend(), Const),
112-
(TensorOperations.DefaultAllocator(), Const);
113-
atol, rtol,
114-
testset_name = "blas_contract! forward real(α) real(β)",
115-
)
116-
EnzymeTestUtils.test_forward(
117-
TensorKit.blas_contract!, Duplicated,
118-
(copy(C), Duplicated), (real(A), Duplicated), (pA, Const),
119-
(B, Duplicated), (pB, Const), (pAB, Const),
120-
(real(α), Active), (real(β), Active),
121-
(TensorOperations.DefaultBackend(), Const),
122-
(TensorOperations.DefaultAllocator(), Const);
123-
atol, rtol,
124-
testset_name = "blas_contract! forward real(A) real(α) real(β)",
125-
)
126-
EnzymeTestUtils.test_forward(
127-
TensorKit.blas_contract!, Duplicated,
128-
(copy(C), Duplicated), (A, Duplicated), (pA, Const),
129-
(real(B), Duplicated), (pB, Const), (pAB, Const),
130-
(real(α), Active), (real(β), Active),
131-
(TensorOperations.DefaultBackend(), Const),
132-
(TensorOperations.DefaultAllocator(), Const);
133-
atol, rtol,
134-
testset_name = "blas_contract! forward real(B) real(α) real(β)",
135-
)
136-
end
48+
αβs = is_ci ? (((α, Active), (β, Active)),) : Iterators.product(((One(), Const), (α, Const), (α, Active)), ((Zero(), Const), (β, Const), (β, Active)))
49+
for (α_, β_) in αβs
50+
EnzymeTestUtils.test_reverse(
51+
TensorKit.blas_contract!, Duplicated,
52+
(copy(C), Duplicated), (A, Duplicated), (pA, Const),
53+
(B, Duplicated), (pB, Const), (pAB, Const),
54+
α_, β_,
55+
(TensorOperations.DefaultBackend(), Const),
56+
(TensorOperations.DefaultAllocator(), Const);
57+
atol, rtol,
58+
testset_name = "blas_contract! reverse α $α_ β $β_",
59+
)
60+
end
61+
αβs = is_ci ? (((α, Duplicated), (β, Duplicated)),) : Iterators.product(((One(), Const), (α, Const), (α, Duplicated)), ((Zero(), Const), (β, Const), (β, Duplicated)))
62+
for (α_, β_) in αβs
63+
EnzymeTestUtils.test_forward(
64+
TensorKit.blas_contract!, Duplicated,
65+
(copy(C), Duplicated), (A, Duplicated), (pA, Const),
66+
(B, Duplicated), (pB, Const), (pAB, Const),
67+
α_, β_,
68+
(TensorOperations.DefaultBackend(), Const),
69+
(TensorOperations.DefaultAllocator(), Const);
70+
atol, rtol,
71+
testset_name = "blas_contract! forward α $α_ β $β_",
72+
)
73+
end
74+
if !(T <: Real) && !is_ci
75+
EnzymeTestUtils.test_reverse(
76+
TensorKit.blas_contract!, Duplicated,
77+
(copy(C), Duplicated), (A, Duplicated), (pA, Const),
78+
(B, Duplicated), (pB, Const), (pAB, Const),
79+
(real(α), Active), (real(β), Active),
80+
(TensorOperations.DefaultBackend(), Const),
81+
(TensorOperations.DefaultAllocator(), Const);
82+
atol, rtol,
83+
testset_name = "blas_contract! reverse real(α) real(β)",
84+
)
85+
EnzymeTestUtils.test_reverse(
86+
TensorKit.blas_contract!, Duplicated,
87+
(copy(C), Duplicated), (real(A), Duplicated), (pA, Const),
88+
(B, Duplicated), (pB, Const), (pAB, Const),
89+
(real(α), Active), (real(β), Active),
90+
(TensorOperations.DefaultBackend(), Const),
91+
(TensorOperations.DefaultAllocator(), Const);
92+
atol, rtol,
93+
testset_name = "blas_contract! reverse real(A) real(α) real(β)",
94+
)
95+
EnzymeTestUtils.test_reverse(
96+
TensorKit.blas_contract!, Duplicated,
97+
(copy(C), Duplicated), (A, Duplicated), (pA, Const),
98+
(real(B), Duplicated), (pB, Const), (pAB, Const),
99+
(real(α), Active), (real(β), Active),
100+
(TensorOperations.DefaultBackend(), Const),
101+
(TensorOperations.DefaultAllocator(), Const);
102+
atol, rtol,
103+
testset_name = "blas_contract! reverse real(B) real(α) real(β)",
104+
)
105+
EnzymeTestUtils.test_forward(
106+
TensorKit.blas_contract!, Duplicated,
107+
(copy(C), Duplicated), (A, Duplicated), (pA, Const),
108+
(B, Duplicated), (pB, Const), (pAB, Const),
109+
(real(α), Active), (real(β), Active),
110+
(TensorOperations.DefaultBackend(), Const),
111+
(TensorOperations.DefaultAllocator(), Const);
112+
atol, rtol,
113+
testset_name = "blas_contract! forward real(α) real(β)",
114+
)
115+
EnzymeTestUtils.test_forward(
116+
TensorKit.blas_contract!, Duplicated,
117+
(copy(C), Duplicated), (real(A), Duplicated), (pA, Const),
118+
(B, Duplicated), (pB, Const), (pAB, Const),
119+
(real(α), Active), (real(β), Active),
120+
(TensorOperations.DefaultBackend(), Const),
121+
(TensorOperations.DefaultAllocator(), Const);
122+
atol, rtol,
123+
testset_name = "blas_contract! forward real(A) real(α) real(β)",
124+
)
125+
EnzymeTestUtils.test_forward(
126+
TensorKit.blas_contract!, Duplicated,
127+
(copy(C), Duplicated), (A, Duplicated), (pA, Const),
128+
(real(B), Duplicated), (pB, Const), (pAB, Const),
129+
(real(α), Active), (real(β), Active),
130+
(TensorOperations.DefaultBackend(), Const),
131+
(TensorOperations.DefaultAllocator(), Const);
132+
atol, rtol,
133+
testset_name = "blas_contract! forward real(B) real(α) real(β)",
134+
)
137135
end
138136
end
139137
end

‎test/enzyme-vi-to/inner.jl‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ using Random, FiniteDifferences
77
spacelist = ad_spacelist(fast_tests)
88
eltypes = (Float64, ComplexF64)
99

10+
is_ci = get(ENV, "CI", "false") == "true"
11+
12+
rTs = is_ci ? (Active,) : (Active, Const)
13+
fTs = is_ci ? (Duplicated,) : (Duplicated, Const)
14+
1015
@testset "Enzyme - VectorInterface" begin
1116
@timedtestset "$(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes
1217
@testset for TC in (Duplicated,), TA in (Duplicated,), f in (identity, adjoint)
1318
atol = default_tol(T)
1419
rtol = default_tol(T)
15-
# see https://github.com/QuantumKitHub/TensorKit.jl/issues/457
16-
if VERSION < v"1.11.0-rc" && sectortype(eltype(V)) == Trivial
17-
CV = V[1] ⊗ V[2] ← V[4] ⊗ V[5]
18-
else
19-
CV = V[1] ⊗ V[2] ← V[3] ⊗ V[4] ⊗ V[5]
20-
end
20+
CV = V[1] ⊗ V[2] ← V[3] ⊗ V[4] ⊗ V[5]
2121
C = randn(T, CV)
2222
A = randn(T, CV)
23-
for RT in (Active, Const)
23+
for RT in rTs
2424
EnzymeTestUtils.test_reverse(inner, RT, (f(C), TC), (f(A), TA); atol, rtol)
2525
end
26-
for RT in (Duplicated, Const)
26+
for RT in fTs
2727
EnzymeTestUtils.test_forward(inner, RT, (f(C), TC), (f(A), TA); atol, rtol)
2828
end
2929
end

‎test/enzyme-vi-to/scale.jl‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ using Random
77
spacelist = ad_spacelist(fast_tests)
88
eltypes = (Float64, ComplexF64)
99

10+
is_ci = get(ENV, "CI", "false") == "true"
11+
12+
rTαs = is_ci ? (Active,) : (Active, Const)
13+
fTαs = is_ci ? (Duplicated,) : (Duplicated, Const)
14+
1015
@testset "Enzyme - VectorInterface (scale!)" begin
1116
@timedtestset "$(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes
1217
atol = default_tol(T)
1318
rtol = default_tol(T)
1419
α = randn(T)
15-
# see https://github.com/QuantumKitHub/TensorKit.jl/issues/457
16-
if VERSION < v"1.11.0-rc" && sectortype(eltype(V)) == Trivial
17-
CV = V[1] ⊗ V[2] ← V[4] ⊗ V[5]
18-
else
19-
CV = V[1] ⊗ V[2] ← V[3] ⊗ V[4] ⊗ V[5]
20-
end
20+
CV = V[1] ⊗ V[2] ← V[3] ⊗ V[4] ⊗ V[5]
2121
@testset for TC in (Duplicated,)
22-
for Tα in (Active, Const)
22+
for Tα in rTαs
2323
C = randn(T, CV)
2424
EnzymeTestUtils.test_reverse(scale!, TC, (C, TC), (α, Tα); atol, rtol)
2525
C = randn(T, CV)
@@ -30,7 +30,7 @@ eltypes = (Float64, ComplexF64)
3030
EnzymeTestUtils.test_reverse(scale!, TC, (fc(C), TC), (fa(A), TA), (α, Tα); atol, rtol)
3131
end
3232
end
33-
for Tα in (Duplicated, Const)
33+
for Tα in fTαs
3434
C = randn(T, CV)
3535
EnzymeTestUtils.test_forward(scale!, TC, (C, TC), (α, Tα); atol, rtol)
3636
C = randn(T, CV)

0 commit comments

Comments
 (0)