Skip to content

Commit ed76496

Browse files
leburgelclaude
andcommitted
Test the subblock groups with several transformer tasks
The test suite runs with one transformer task, so the path that splits the groups over tasks by destination offset was not covered. Compare `permute` and `permute!` with β ≠ 0 using three tasks against the serial result, for a fermionic U(1) tensor (unique fusion) and an SU(2) tensor with subblocks on both sides of the group threshold (generic fusion, accumulating groups). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 9464cd0 commit ed76496

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎test/tensors/indexmanipulations.jl‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,3 +246,26 @@ end
246246
@test convert(Array, permute(t, p)) ≈ permutedims(a, (p[1]..., p[2]...))
247247
end
248248
end
249+
250+
@timedtestset "Permutations with several transformer tasks" begin
251+
# the tasks split the subblock groups by destination offset; they also run on a single thread,
252+
# so the number is set directly rather than through `set_num_transformer_threads`, which caps it
253+
V1 = Vect[FermionParity ⊠ U1Irrep]((p, q) => 3 for p in 0:1 for q in -2:2)
254+
V2 = Vect[SU2Irrep](0 => 8, 1 // 2 => 8, 1 => 1)
255+
ntasks = TensorKit.TRANSFORMER_THREADS[]
256+
for V in (V1, V2)
257+
t = rand(ComplexF64, V ⊗ V ⊗ V ← V)
258+
@test dim(t) > TensorKit.Strided.MINTHREADLENGTH # below, a single task is used
259+
for p in (((1, 4), (2, 3)), ((3, 1, 4), (2,)))
260+
tdst = rand(ComplexF64, permute(space(t), p))
261+
refs = (permute(t, p), permute!(copy(tdst), t, p, 0.7, 0.3))
262+
try
263+
TensorKit.TRANSFORMER_THREADS[] = 3
264+
@test permute(t, p) ≈ refs[1]
265+
@test permute!(copy(tdst), t, p, 0.7, 0.3) ≈ refs[2]
266+
finally
267+
TensorKit.TRANSFORMER_THREADS[] = ntasks
268+
end
269+
end
270+
end
271+
end

0 commit comments

Comments
 (0)