Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/src/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ When releasing a new version, move the "Unreleased" changes to a new version sec
- `taskforeach` with a single worker is a plain loop without an atomic counter, which lowers the cost per subblock of single-threaded index manipulations and planar traces
- Tree transformers for sectors with multiple fusion channels share equal recoupling matrices, which only depend on the sectors, instead of storing one copy per transformer
- The cached braids and transposes of fusion tree blocks keep their recoupling matrices in the scalar type of the tree transformers that use them, instead of a copy in that type for every transformer
- The fusion tree pairs of a `UniqueTreeTransformer` are transformed on up to `get_num_manipulation_threads()` tasks, as the fusion tree blocks of a `GenericTreeTransformer` already were, which speeds up the construction of the index manipulations of abelian tensors with many fusion tree pairs

## [0.17.3](https://github.com/QuantumKitHub/TensorKit.jl/compare/v0.17.2...v0.17.3) - 2026-10-30

Expand Down
19 changes: 15 additions & 4 deletions src/tensors/treetransformers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ end
# (coefficient, destination position, source position)
const UniqueTransformerData{T} = Tuple{T, Int, Int}

# the minimal number of fusion tree pairs per task of `UniqueTreeTransformer`
const UNIQUE_TRANSFORM_MINPAIRS = 1024

"""
UniqueTreeTransformer{T, N} <: TreeTransformer

Expand Down Expand Up @@ -97,10 +100,18 @@ function UniqueTreeTransformer(::Type{A}, transform, p, Vdst::HomSpace, Vsrc::Ho
T = recoupling_scalartype(A, sectorscalartype(sectortype(Vdst)))
data = Vector{UniqueTransformerData{T}}(undef, length(src_trees))

@timeit_debug GLOBAL_TIMER "symmetry: tree transform" for (isrc, (f₁, f₂)) in enumerate(src_trees)
f_dst, coeff = transform(conjsrc ? (f₂, f₁) : (f₁, f₂))
_, (_, idst) = gettoken(dst_trees, f_dst)
data[isrc] = (convert(T, coeff), idst, isrc)
# the pairs are split into one equal range per task, with enough pairs in every range
ntasks = clamp(length(data) ÷ UNIQUE_TRANSFORM_MINPAIRS, 1, get_num_manipulation_threads())
chunks = Iterators.partition(eachindex(data), max(cld(length(data), ntasks), 1))
@timeit_debug GLOBAL_TIMER "symmetry: tree transform" begin
taskforeach(chunks, ntasks) do isrcs
for isrc in isrcs
f₁, f₂ = gettokenvalue(src_trees, isrc)
f_dst, coeff = transform(conjsrc ? (f₂, f₁) : (f₁, f₂))
_, (_, idst) = gettoken(dst_trees, f_dst)
data[isrc] = (convert(T, coeff), idst, isrc)
end
end
end

structure_dst = degeneracystructure(Vdst).subblockstructure
Expand Down
Loading