Skip to content

Commit 4f37082

Browse files
lkdvosclaude
andcommitted
Fix inference of nested product manipulations on Julia 1.10, and mark product_transform inactive for Enzyme
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 65a061c commit 4f37082

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎ext/TensorKitEnzymeExt/utility.jl‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ end
147147
@inline EnzymeRules.inactive(::typeof(TensorKit.artin_braid), ::Any, ::Any) = nothing
148148
@inline EnzymeRules.inactive(::typeof(TensorKit.fstranspose), ::Any) = nothing
149149
@inline EnzymeRules.inactive(::typeof(TensorKit.fstranspose), ::Any, ::Any) = nothing
150+
@inline EnzymeRules.inactive(::typeof(TensorKit.product_transform), ::Any...) = nothing
150151
@inline EnzymeRules.inactive(::typeof(TensorKit.treetransposer), ::Any...) = nothing
151152
@inline EnzymeRules.inactive(::typeof(TensorKit.treebraider), ::Any...) = nothing
152153
@inline EnzymeRules.inactive(::typeof(TensorKit.insertleftunit), ::HomSpace, ::Any) = nothing

‎src/fusiontrees/braiding_manipulations.jl‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,10 @@ function braid(src::Union{FusionTreePair, FusionTreeBlock}, p::Index2Tuple, leve
288288
end
289289
function braid(src::ProductSectorBlock, p::Index2Tuple, levels::Index2Tuple)
290290
isempty(src) && return fsbraid((src, p, levels))
291+
# the return type is asserted since inference gives up on the recursion on older Julia versions
291292
return product_transform(sectorscalartype(sectortype(src)), src) do x
292293
return braid(x, p, levels)
293-
end
294+
end::_fsdicttype(typeof((src, p, levels)))
294295
end
295296

296297
const FSPBraidKey{I, N₁, N₂} = Tuple{FusionTreePair{I}, Index2Tuple{N₁, N₂}, Index2Tuple}

‎src/fusiontrees/duality_manipulations.jl‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,9 +528,10 @@ function Base.transpose(src::Union{FusionTreePair, FusionTreeBlock}, p::Index2Tu
528528
end
529529
function Base.transpose(src::ProductSectorBlock, p::Index2Tuple)
530530
isempty(src) && return fstranspose((src, p))
531+
# the return type is asserted since inference gives up on the recursion on older Julia versions
531532
return product_transform(fusionscalartype(sectortype(src)), src) do x
532533
return transpose(x, p)
533-
end
534+
end::_fsdicttype(typeof((src, p)))
534535
end
535536

536537
const FSPTransposeKey{I, N₁, N₂} = Tuple{FusionTreePair{I}, Index2Tuple{N₁, N₂}}

0 commit comments

Comments
 (0)