Skip to content

Commit 9bd7c1f

Browse files
mtfishmanclaude
andcommitted
Fix @test_broken tests that now pass on Julia v1.12.6
Julia v1.12.6 fixed type inference for abstract array dispatch (JuliaLang/julia#57582), which makes JLArray-backed BlockSparseMatrix operations (eig, svd, qr, iszero on views) work correctly. Use `broken = gpu_broken` with a VERSION check so tests remain broken on older Julia versions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b89c568 commit 9bd7c1f

3 files changed

Lines changed: 23 additions & 43 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "BlockSparseArrays"
22
uuid = "2c9a651f-6452-4ace-a6ac-809f4280fbb4"
3-
version = "0.10.35"
3+
version = "0.10.36"
44
authors = ["ITensor developers <support@itensor.org> and contributors"]
55

66
[workspace]

test/test_abstract_blocktype.jl

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ using MatrixAlgebraKit: eig_full, eig_trunc, eig_vals, eigh_full, eigh_trunc, ei
77
isisometric, left_orth, left_polar, lq_compact, lq_full, qr_compact, qr_full,
88
right_orth, right_polar, svd_compact, svd_full, svd_trunc
99
using SparseArraysBase: storedlength
10-
using Test: @test, @test_broken, @testset
10+
using Test: @test, @testset
1111

1212
elts = (Float32, Float64, ComplexF32)
1313
arrayts = (Array, JLArray)
1414
@testset "Abstract block type (arraytype=$arrayt, eltype=$elt)" for arrayt in arrayts,
1515
elt in elts
1616

1717
dev = adapt(arrayt)
18+
gpu_broken = arrayt Array && VERSION < v"1.12.6"
1819

1920
a = BlockSparseMatrix{elt, AbstractMatrix{elt}}(undef, [2, 3], [2, 3])
2021
@test sprint(show, MIME"text/plain"(), a) isa String
@@ -56,65 +57,45 @@ arrayts = (Array, JLArray)
5657
a = BlockSparseMatrix{elt, AbstractMatrix{elt}}(undef, [2, 3], [2, 3])
5758
a[Block(1, 1)] = dev(randn(elt, 2, 2))
5859
for f in (eig_full, eig_trunc)
59-
if arrayt === Array
60+
@test begin
6061
d, v = f(a)
61-
@test a * v v * d
62-
else
63-
@test_broken f(a)
64-
end
62+
a * v v * d
63+
end broken = gpu_broken
6564
end
66-
if arrayt === Array
65+
@test begin
6766
d = eig_vals(a)
68-
@test sort(Vector(d); by = abs) sort(eig_vals(Matrix(a)); by = abs)
69-
else
70-
@test_broken eig_vals(a)
71-
end
67+
sort(Vector(d); by = abs) sort(eig_vals(Matrix(a)); by = abs)
68+
end broken = gpu_broken
7269

7370
a = BlockSparseMatrix{elt, AbstractMatrix{elt}}(undef, [2, 3], [2, 3])
7471
a[Block(1, 1)] = dev(parent(hermitianpart(randn(elt, 2, 2))))
7572
for f in (eigh_full, eigh_trunc)
76-
if arrayt === Array
73+
@test begin
7774
d, v = f(a)
78-
@test a * v v * d
79-
else
80-
@test_broken f(a)
81-
end
75+
a * v v * d
76+
end broken = gpu_broken
8277
end
83-
if arrayt === Array
78+
@test begin
8479
d = eigh_vals(a)
85-
@test sort(Vector(d); by = abs) sort(eig_vals(Matrix(a)); by = abs)
86-
else
87-
@test_broken eigh_vals(a)
88-
end
80+
sort(Vector(d); by = abs) sort(eig_vals(Matrix(a)); by = abs)
81+
end broken = gpu_broken
8982

9083
a = BlockSparseMatrix{elt, AbstractMatrix{elt}}(undef, [2, 3], [2, 3])
9184
a[Block(1, 1)] = dev(randn(elt, 2, 2))
9285
for f in (left_orth, left_polar, qr_compact, qr_full)
9386
u, c = f(a)
9487
@test u * c a
95-
if arrayt Array
96-
@test isisometric(u; side = :left)
97-
else
98-
# TODO: Fix comparison with UniformScaling on GPU.
99-
@test_broken isisometric(u; side = :left)
100-
end
88+
@test isisometric(u; side = :left) broken = gpu_broken
10189
end
10290
for f in (right_orth, right_polar, lq_compact, lq_full)
10391
c, u = f(a)
10492
@test c * u a
105-
if arrayt Array
106-
@test isisometric(u; side = :right)
107-
else
108-
# TODO: Fix comparison with UniformScaling on GPU.
109-
@test_broken isisometric(u; side = :right)
110-
end
93+
@test isisometric(u; side = :right) broken = gpu_broken
11194
end
11295
for f in (svd_compact, svd_full, svd_trunc)
113-
if arrayt Array && (f svd_full || f svd_trunc)
114-
@test_broken f(a)
115-
else
96+
@test begin
11697
u, s, v = f(a)
117-
@test u * s * v a
118-
end
98+
u * s * v a
99+
end broken = gpu_broken && (f svd_full || f svd_trunc)
119100
end
120101
end

test/test_map.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ arrayts = (Array, JLArray)
1515
elt in elts
1616

1717
dev = adapt(arrayt)
18+
gpu_broken = arrayt Array && VERSION < v"1.12.6"
1819

1920
a = dev(BlockSparseArray{elt}(undef, ([2, 3], [3, 4])))
2021
@views for b in [Block(1, 2), Block(2, 1)]
@@ -98,16 +99,14 @@ arrayts = (Array, JLArray)
9899
@test iszero(storedlength(a))
99100
@test iszero(b)
100101
@test iszero(storedlength(b))
101-
# TODO: Broken on GPU.
102-
@test iszero(c) broken = arrayt Array
102+
@test iszero(c) broken = gpu_broken
103103
@test iszero(storedlength(c))
104104
@allowscalar a[5, 7] = 1
105105
@test !iszero(a)
106106
@test storedlength(a) == 3 * 4
107107
@test !iszero(b)
108108
@test storedlength(b) == 3 * 4
109-
# TODO: Broken on GPU.
110-
@test !iszero(c) broken = arrayt Array
109+
@test !iszero(c) broken = gpu_broken
111110
@test storedlength(c) == 3 * 4
112111
d = @view a[1:4, 1:6]
113112
@test iszero(d)

0 commit comments

Comments
 (0)