Skip to content

Reduce cache footprint by decoupling degeneracy-dependent data#387

Open
lkdvos wants to merge 12 commits intomainfrom
ld-caching
Open

Reduce cache footprint by decoupling degeneracy-dependent data#387
lkdvos wants to merge 12 commits intomainfrom
ld-caching

Conversation

@lkdvos
Copy link
Member

@lkdvos lkdvos commented Mar 23, 2026

Refactors the internal block structure representation for TensorMap by splitting FusionBlockStructure into two separately-cached structs:

  • SectorStructure (cached by sector structure, shared across spaces with the same sectors): coupled sectors and valid fusion tree pairs as Dictionaries.Indices.
  • DegeneracyStructure (cached per HomSpace): total dimension, block sizes/ranges, and sub-block strides as plain Vectors.

The public blockstructure(W) and subblockstructure(W) combine these on the fly into a Dictionary.

Previously, FusionBlockStructure stored a fusiontreelist, a fusiontreeindices lookup dict, and a fusiontreestructure vector — the tree pairs were stored twice and lookup required manual indirection. Dictionaries.jl handles this naturally via its token system.

A secondary benefit: DegeneracyStructure{N} is parameterized only by the number of indices N, not the sector type. Kernels that only need sizes/strides/offsets can therefore be compiled once and reused across different symmetry groups — a potential route to much faster precompilation.

Also moves the tensor structure computation out of homspace.jl into a new tensorstructure.jl.


Open questions:

  • Should we replace all remaining internal dicts with Dictionaries.jl types to avoid maintaining two APIs?
  • Are there other places that would benefit from a similar sector/degeneracy split?

@lkdvos lkdvos linked an issue Mar 23, 2026 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 96.31579% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/tensors/tensorstructure.jl 96.45% 5 Missing ⚠️
src/tensors/braidingtensor.jl 0.00% 2 Missing ⚠️
Files with missing lines Coverage Δ
ext/TensorKitMooncakeExt/utility.jl 85.71% <ø> (ø)
src/TensorKit.jl 14.28% <ø> (+0.64%) ⬆️
src/auxiliary/dicts.jl 47.80% <100.00%> (-3.62%) ⬇️
src/spaces/homspace.jl 90.19% <100.00%> (-4.71%) ⬇️
src/tensors/abstracttensor.jl 47.16% <100.00%> (-7.72%) ⬇️
src/tensors/tensor.jl 78.61% <100.00%> (-6.79%) ⬇️
src/tensors/tensoroperations.jl 93.78% <100.00%> (-3.65%) ⬇️
src/tensors/treetransformers.jl 96.29% <100.00%> (+0.06%) ⬆️
src/tensors/braidingtensor.jl 0.00% <0.00%> (-68.30%) ⬇️
src/tensors/tensorstructure.jl 96.45% <96.45%> (ø)

... and 20 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fusionblockstructure should reuse data that is degeneracy-independent

1 participant