From 7bae23ee56d576ebc92500813227c40019798109 Mon Sep 17 00:00:00 2001 From: Katharine Hyatt Date: Wed, 29 Jul 2026 15:40:16 +0200 Subject: [PATCH 1/2] Consolidate some of the indexmanip tests --- .../braid.jl | 0 .../flip.jl | 0 .../permute.jl | 0 .../transpose.jl | 0 .../twist.jl | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename test/{enzyme-indexmanipulations-transform => enzyme-indexmanipulations-flip-twist-transform}/braid.jl (100%) rename test/{enzyme-indexmanipulations-flip-twist => enzyme-indexmanipulations-flip-twist-transform}/flip.jl (100%) rename test/{enzyme-indexmanipulations-transform => enzyme-indexmanipulations-flip-twist-transform}/permute.jl (100%) rename test/{enzyme-indexmanipulations-transform => enzyme-indexmanipulations-flip-twist-transform}/transpose.jl (100%) rename test/{enzyme-indexmanipulations-flip-twist => enzyme-indexmanipulations-flip-twist-transform}/twist.jl (100%) diff --git a/test/enzyme-indexmanipulations-transform/braid.jl b/test/enzyme-indexmanipulations-flip-twist-transform/braid.jl similarity index 100% rename from test/enzyme-indexmanipulations-transform/braid.jl rename to test/enzyme-indexmanipulations-flip-twist-transform/braid.jl diff --git a/test/enzyme-indexmanipulations-flip-twist/flip.jl b/test/enzyme-indexmanipulations-flip-twist-transform/flip.jl similarity index 100% rename from test/enzyme-indexmanipulations-flip-twist/flip.jl rename to test/enzyme-indexmanipulations-flip-twist-transform/flip.jl diff --git a/test/enzyme-indexmanipulations-transform/permute.jl b/test/enzyme-indexmanipulations-flip-twist-transform/permute.jl similarity index 100% rename from test/enzyme-indexmanipulations-transform/permute.jl rename to test/enzyme-indexmanipulations-flip-twist-transform/permute.jl diff --git a/test/enzyme-indexmanipulations-transform/transpose.jl b/test/enzyme-indexmanipulations-flip-twist-transform/transpose.jl similarity index 100% rename from test/enzyme-indexmanipulations-transform/transpose.jl rename to test/enzyme-indexmanipulations-flip-twist-transform/transpose.jl diff --git a/test/enzyme-indexmanipulations-flip-twist/twist.jl b/test/enzyme-indexmanipulations-flip-twist-transform/twist.jl similarity index 100% rename from test/enzyme-indexmanipulations-flip-twist/twist.jl rename to test/enzyme-indexmanipulations-flip-twist-transform/twist.jl From 68015d1346cd81178d9b66f2bb21ef79c1a5e90e Mon Sep 17 00:00:00 2001 From: Katharine Hyatt Date: Wed, 29 Jul 2026 15:41:30 +0200 Subject: [PATCH 2/2] Try running again on Windows and/or 1.10 --- .../braid.jl | 36 +++++++++---------- .../permute.jl | 26 +++++++------- .../transpose.jl | 34 +++++++++--------- .../twist.jl | 32 ++++++++--------- 4 files changed, 60 insertions(+), 68 deletions(-) diff --git a/test/enzyme-indexmanipulations-flip-twist-transform/braid.jl b/test/enzyme-indexmanipulations-flip-twist-transform/braid.jl index 0d4099d13..c845a6e65 100644 --- a/test/enzyme-indexmanipulations-flip-twist-transform/braid.jl +++ b/test/enzyme-indexmanipulations-flip-twist-transform/braid.jl @@ -11,25 +11,23 @@ is_ci = get(ENV, "CI", "false") == "true" Tαs = is_ci ? (Active,) : (Active, Const) Tβs = is_ci ? (Active,) : (Active, Const) -if !Sys.iswindows() && VERSION > v"1.11.0-rc" - @timedtestset "Enzyme - Index Manipulations (braid!) $(TensorKit.type_repr(sectortype(eltype(V)))) ($T) Tα $Tα Tβ $Tβ" for V in spacelist, T in eltypes, Tα in Tαs, Tβ in Tβs - atol = default_tol(T) - rtol = default_tol(T) - Vstr = TensorKit.type_repr(sectortype(eltype(V))) - has_braiding = BraidingStyle(sectortype(eltype(V))) isa HasBraiding - if has_braiding - A = randn(T, V[1] ⊗ V[2] ← (V[3] ⊗ V[4] ⊗ V[5])') - α = randn(T) - β = randn(T) - p = randcircshift(numout(A), numin(A)) - levels = Tuple(randperm(numind(A))) - C = randn!(transpose(A, p)) - EnzymeTestUtils.test_reverse(TensorKit.braid!, Duplicated, (C, Duplicated), (A, Duplicated), (p, Const), (levels, Const), (α, Tα), (β, Tβ); atol, rtol, testset_name = "braid! V $Vstr Tα $Tα Tβ $Tβ") - if !(T <: Real) && !is_ci - EnzymeTestUtils.test_reverse(TensorKit.braid!, Duplicated, (C, Duplicated), (real(A), Duplicated), (p, Const), (levels, Const), (α, Tα), (β, Tβ); atol, rtol, testset_name = "braid! V $Vstr Tα $Tα Tβ $Tβ") - EnzymeTestUtils.test_reverse(TensorKit.braid!, Duplicated, (C, Duplicated), (A, Duplicated), (p, Const), (levels, Const), (real(α), Tα), (β, Tβ); atol, rtol, testset_name = "braid! V $Vstr Tα $Tα Tβ $Tβ") - EnzymeTestUtils.test_reverse(TensorKit.braid!, Duplicated, (C, Duplicated), (A, Duplicated), (p, Const), (levels, Const), (real(α), Tα), (real(β), Tβ); atol, rtol, testset_name = "braid! V $Vstr Tα $Tα Tβ $Tβ") - end +@timedtestset "Enzyme - Index Manipulations (braid!) $(TensorKit.type_repr(sectortype(eltype(V)))) ($T) Tα $Tα Tβ $Tβ" for V in spacelist, T in eltypes, Tα in Tαs, Tβ in Tβs + atol = default_tol(T) + rtol = default_tol(T) + Vstr = TensorKit.type_repr(sectortype(eltype(V))) + has_braiding = BraidingStyle(sectortype(eltype(V))) isa HasBraiding + if has_braiding + A = randn(T, V[1] ⊗ V[2] ← (V[3] ⊗ V[4] ⊗ V[5])') + α = randn(T) + β = randn(T) + p = randcircshift(numout(A), numin(A)) + levels = Tuple(randperm(numind(A))) + C = randn!(transpose(A, p)) + EnzymeTestUtils.test_reverse(TensorKit.braid!, Duplicated, (C, Duplicated), (A, Duplicated), (p, Const), (levels, Const), (α, Tα), (β, Tβ); atol, rtol, testset_name = "braid! V $Vstr Tα $Tα Tβ $Tβ") + if !(T <: Real) && !is_ci + EnzymeTestUtils.test_reverse(TensorKit.braid!, Duplicated, (C, Duplicated), (real(A), Duplicated), (p, Const), (levels, Const), (α, Tα), (β, Tβ); atol, rtol, testset_name = "braid! V $Vstr Tα $Tα Tβ $Tβ") + EnzymeTestUtils.test_reverse(TensorKit.braid!, Duplicated, (C, Duplicated), (A, Duplicated), (p, Const), (levels, Const), (real(α), Tα), (β, Tβ); atol, rtol, testset_name = "braid! V $Vstr Tα $Tα Tβ $Tβ") + EnzymeTestUtils.test_reverse(TensorKit.braid!, Duplicated, (C, Duplicated), (A, Duplicated), (p, Const), (levels, Const), (real(α), Tα), (real(β), Tβ); atol, rtol, testset_name = "braid! V $Vstr Tα $Tα Tβ $Tβ") end end end diff --git a/test/enzyme-indexmanipulations-flip-twist-transform/permute.jl b/test/enzyme-indexmanipulations-flip-twist-transform/permute.jl index d78ec1e41..28102a3b1 100644 --- a/test/enzyme-indexmanipulations-flip-twist-transform/permute.jl +++ b/test/enzyme-indexmanipulations-flip-twist-transform/permute.jl @@ -11,20 +11,18 @@ is_ci = get(ENV, "CI", "false") == "true" Tαs = is_ci ? (Active,) : (Active, Const) Tβs = is_ci ? (Active,) : (Active, Const) -if VERSION >= v"1.11.0-rc" # segfault issues on 1.10 - @timedtestset "Enzyme - Index Manipulations (permute!): $(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes - println(TensorKit.type_repr(sectortype(eltype(V)))) - atol = default_tol(T) - rtol = default_tol(T) - symmetricbraiding = BraidingStyle(sectortype(eltype(V))) isa SymmetricBraiding +@timedtestset "Enzyme - Index Manipulations (permute!): $(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes + println(TensorKit.type_repr(sectortype(eltype(V)))) + atol = default_tol(T) + rtol = default_tol(T) + symmetricbraiding = BraidingStyle(sectortype(eltype(V))) isa SymmetricBraiding - symmetricbraiding && @timedtestset "permute! Tα $Tα, Tβ $Tβ" for Tα in Tαs, Tβ in Tβs - A = randn(T, V[1] ⊗ V[2] ← (V[3] ⊗ V[4] ⊗ V[5])') - α = randn(T) - β = randn(T) - p = randindextuple(numind(A)) - C = randn!(permute(A, p)) - EnzymeTestUtils.test_reverse(TensorKit.permute!, Duplicated, (C, Duplicated), (A, Duplicated), (p, Const), (α, Tα), (β, Tβ); atol, rtol) - end + symmetricbraiding && @timedtestset "permute! Tα $Tα, Tβ $Tβ" for Tα in Tαs, Tβ in Tβs + A = randn(T, V[1] ⊗ V[2] ← (V[3] ⊗ V[4] ⊗ V[5])') + α = randn(T) + β = randn(T) + p = randindextuple(numind(A)) + C = randn!(permute(A, p)) + EnzymeTestUtils.test_reverse(TensorKit.permute!, Duplicated, (C, Duplicated), (A, Duplicated), (p, Const), (α, Tα), (β, Tβ); atol, rtol) end end diff --git a/test/enzyme-indexmanipulations-flip-twist-transform/transpose.jl b/test/enzyme-indexmanipulations-flip-twist-transform/transpose.jl index 7ba3e2d42..9e6703eb1 100644 --- a/test/enzyme-indexmanipulations-flip-twist-transform/transpose.jl +++ b/test/enzyme-indexmanipulations-flip-twist-transform/transpose.jl @@ -13,25 +13,23 @@ is_ci = get(ENV, "CI", "false") == "true" Tαs = is_ci ? (Active,) : (Active, Const) Tβs = is_ci ? (Active,) : (Active, Const) -if VERSION > v"1.11.0-rc" # https://github.com/QuantumKitHub/TensorKit.jl/issues/457 - @timedtestset "Enzyme - Index Manipulations (transpose!) $(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes - atol = default_tol(T) - rtol = default_tol(T) - A = randn(T, V[1] ⊗ V[2] ← (V[3] ⊗ V[4] ⊗ V[5])') - α = randn(T) - β = randn(T) +@timedtestset "Enzyme - Index Manipulations (transpose!) $(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes + atol = default_tol(T) + rtol = default_tol(T) + A = randn(T, V[1] ⊗ V[2] ← (V[3] ⊗ V[4] ⊗ V[5])') + α = randn(T) + β = randn(T) - # repeat a couple times to get some distribution of arrows - p = randcircshift(numout(A), numin(A)) - C = randn!(transpose(A, p)) - !is_ci && EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (copy(C), Duplicated), (A, Duplicated), (p, Const), (One(), Const), (Zero(), Const); atol, rtol) - @testset for Tα in Tαs, Tβ in Tβs - EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (copy(C), Duplicated), (A, Duplicated), (p, Const), (α, Tα), (β, Tβ); atol, rtol) - if !(T <: Real) && !is_ci - EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (copy(C), Duplicated), (real(A), Duplicated), (p, Const), (α, Tα), (β, Tβ); atol, rtol) - EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (copy(C), Duplicated), (A, Duplicated), (p, Const), (real(α), Tα), (β, Tβ); atol, rtol) - EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (copy(C), Duplicated), (real(A), Duplicated), (p, Const), (real(α), Tα), (β, Tβ); atol, rtol) - end + # repeat a couple times to get some distribution of arrows + p = randcircshift(numout(A), numin(A)) + C = randn!(transpose(A, p)) + !is_ci && EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (copy(C), Duplicated), (A, Duplicated), (p, Const), (One(), Const), (Zero(), Const); atol, rtol) + @testset for Tα in Tαs, Tβ in Tβs + EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (copy(C), Duplicated), (A, Duplicated), (p, Const), (α, Tα), (β, Tβ); atol, rtol) + if !(T <: Real) && !is_ci + EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (copy(C), Duplicated), (real(A), Duplicated), (p, Const), (α, Tα), (β, Tβ); atol, rtol) + EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (copy(C), Duplicated), (A, Duplicated), (p, Const), (real(α), Tα), (β, Tβ); atol, rtol) + EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (copy(C), Duplicated), (real(A), Duplicated), (p, Const), (real(α), Tα), (β, Tβ); atol, rtol) end end end diff --git a/test/enzyme-indexmanipulations-flip-twist-transform/twist.jl b/test/enzyme-indexmanipulations-flip-twist-transform/twist.jl index 594b579be..2cacc2b3d 100644 --- a/test/enzyme-indexmanipulations-flip-twist-transform/twist.jl +++ b/test/enzyme-indexmanipulations-flip-twist-transform/twist.jl @@ -8,23 +8,21 @@ using Random spacelist = ad_spacelist(fast_tests) eltypes = (Float64, ComplexF64) -if !Sys.iswindows() && VERSION > v"1.11.0-rc" - @timedtestset "Enzyme - Index Manipulations (twist):" begin - @timedtestset "$(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes, TA in (Duplicated,) - atol = default_tol(T) - rtol = default_tol(T) - A = randn(T, V[1] ⊗ V[2] ← (V[3] ⊗ V[4] ⊗ V[5])') - has_braiding = BraidingStyle(sectortype(eltype(V))) isa HasBraiding - if has_braiding && !(T <: Real && !(sectorscalartype(sectortype(A)) <: Real)) - EnzymeTestUtils.test_reverse(twist!, TA, (copy(A), TA), (1, Const); atol, rtol, fkwargs = (inv = false,)) - EnzymeTestUtils.test_reverse(twist!, TA, (copy(A), TA), ([1, 3], Const); atol, rtol, fkwargs = (inv = true,)) - EnzymeTestUtils.test_reverse(twist!, TA, (copy(A), TA), (1, Const); atol, rtol) - EnzymeTestUtils.test_reverse(twist!, TA, (copy(A), TA), ([1, 3], Const); atol, rtol) - EnzymeTestUtils.test_forward(twist!, TA, (copy(A), TA), (1, Const); atol, rtol, fkwargs = (inv = false,)) - EnzymeTestUtils.test_forward(twist!, TA, (copy(A), TA), ([1, 3], Const); atol, rtol, fkwargs = (inv = true,)) - EnzymeTestUtils.test_forward(twist!, TA, (copy(A), TA), (1, Const); atol, rtol) - EnzymeTestUtils.test_forward(twist!, TA, (copy(A), TA), ([1, 3], Const); atol, rtol) - end +@timedtestset "Enzyme - Index Manipulations (twist):" begin + @timedtestset "$(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes, TA in (Duplicated,) + atol = default_tol(T) + rtol = default_tol(T) + A = randn(T, V[1] ⊗ V[2] ← (V[3] ⊗ V[4] ⊗ V[5])') + has_braiding = BraidingStyle(sectortype(eltype(V))) isa HasBraiding + if has_braiding && !(T <: Real && !(sectorscalartype(sectortype(A)) <: Real)) + EnzymeTestUtils.test_reverse(twist!, TA, (copy(A), TA), (1, Const); atol, rtol, fkwargs = (inv = false,)) + EnzymeTestUtils.test_reverse(twist!, TA, (copy(A), TA), ([1, 3], Const); atol, rtol, fkwargs = (inv = true,)) + EnzymeTestUtils.test_reverse(twist!, TA, (copy(A), TA), (1, Const); atol, rtol) + EnzymeTestUtils.test_reverse(twist!, TA, (copy(A), TA), ([1, 3], Const); atol, rtol) + EnzymeTestUtils.test_forward(twist!, TA, (copy(A), TA), (1, Const); atol, rtol, fkwargs = (inv = false,)) + EnzymeTestUtils.test_forward(twist!, TA, (copy(A), TA), ([1, 3], Const); atol, rtol, fkwargs = (inv = true,)) + EnzymeTestUtils.test_forward(twist!, TA, (copy(A), TA), (1, Const); atol, rtol) + EnzymeTestUtils.test_forward(twist!, TA, (copy(A), TA), ([1, 3], Const); atol, rtol) end end end