Skip to content

Static size for unbounded dimensions in the Manhattan indexing - #117

Merged
leburgel merged 3 commits into
mainfrom
lb/unbounded_manhattan_sizes
Oct 22, 2026
Merged

leburgel merged 3 commits into
mainfrom
lb/unbounded_manhattan_sizes

Conversation

@leburgel

Copy link
Copy Markdown
Member

Following this suggestion: infinite sector types now have the size Unbounded() instead of typemax(Int) in the Manhattan indexing, so that the inclusion-exclusion of #115 leaves out their bounds at compile time. Finite products get faster too; that comes from building the tuple of bounded sizes, but I haven't tracked down why.

findindex before after getindex before after
U1Irrep ⊠ SU2Irrep 7.6 ns 6.3 ns 190 ns 180 ns
FermionParity ⊠ U1Irrep ⊠ SU2Irrep ⊠ U1Irrep 65 ns 13 ns 830 ns 230 ns
Z4Irrep ⊠ Z4Irrep ⊠ Z4Irrep 29 ns 17 ns 310 ns 220 ns
Z3Irrep ⊠ IsingAnyon ⊠ FibonacciAnyon 31 ns 19 ns 270 ns 205 ns

With SUNRepresentations passing Unbounded() as well (which would replace QuantumKitHub/SUNRepresentations.jl#60), findindex for SU(4) / SU(5) goes from 26 / 65 to 7 / 11 ns, and getindex from 310 / 420 to 175 ns.

Reproducer
using TensorKitSectors, BenchmarkTools
fi(s) = TensorKitSectors.findindex(values(typeof(s)), s)
gi(I, i) = values(I)[i]
for s in (U1Irrep(7) ⊠ SU2Irrep(3), FermionParity(1) ⊠ U1Irrep(-3) ⊠ SU2Irrep(5 // 2) ⊠ U1Irrep(4),
          Z4Irrep(3) ⊠ Z4Irrep(2) ⊠ Z4Irrep(1), Z3Irrep(2) ⊠ IsingAnyon(:σ) ⊠ FibonacciAnyon(:τ))
    @btime fi($s)
    @btime gi($(typeof(s)), $(fi(s)))
end

🤖 Generated with Claude Code

The values of an infinite sector type now have size `Unbounded()` instead of
`typemax(Int)`, so that the inclusion-exclusion over the bounds leaves out the
unbounded dimensions at compile time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/auxiliary.jl 99.07% <100.00%> (+4.12%) ⬆️
src/product.jl 93.60% <100.00%> (-0.89%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

leburgel and others added 2 commits October 21, 2026 18:56
…sizes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leburgel
leburgel merged commit 2d68f05 into main Oct 22, 2026
12 checks passed
@leburgel
leburgel deleted the lb/unbounded_manhattan_sizes branch October 22, 2026 06:34
@leburgel leburgel mentioned this pull request Oct 22, 2026
leburgel added a commit to QuantumKitHub/SUNRepresentations.jl that referenced this pull request Oct 22, 2026
Uses `TensorKitSectors.Unbounded` (QuantumKitHub/TensorKitSectors.jl#117), which also
speeds up `getindex`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants