Skip to content

Static unbounded sizes in the SU(N) Manhattan indexing - #60

Merged
lkdvos merged 3 commits into
mainfrom
lb/sun_findindex
Oct 22, 2026
Merged

lkdvos merged 3 commits into
mainfrom
lb/sun_findindex

Conversation

@leburgel

@leburgel leburgel commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

The Dynkin labels are unbounded, so findindex and getindex now pass TensorKitSectors.Unbounded() sizes to the Manhattan indexing (QuantumKitHub/TensorKitSectors.jl#117, in 0.3.11), which leaves out the bound corrections at compile time. Same indices; resolves the TODO in sector.jl.

findindex before after getindex before after
SU(3) 7–8 ns 6 ns 172–177 ns 165–182 ns
SU(4) 26–27 ns 7 ns 303–315 ns 170–178 ns
SU(5) 61–69 ns 11 ns 411–428 ns 170–183 ns
Reproducer
using SUNRepresentations, TensorKitSectors, BenchmarkTools
fi(s) = TensorKitSectors.findindex(values(typeof(s)), s)
gi(I, i) = values(I)[i]
for s in (Irrep[SU₃]((7, 2, 0)), Irrep[SU₄]((6, 4, 3, 0)), Irrep[SU₅]((4, 3, 3, 1, 0)))
    @btime fi($s)
    @btime gi($(typeof(s)), $(fi(s)))
end

🤖 Generated with Claude Code

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/sector.jl 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lkdvos

lkdvos commented Oct 21, 2026

Copy link
Copy Markdown
Member

Is this something we can add to tensorkitsectors such that all infinite combinations immediately get this?

@leburgel

Copy link
Copy Markdown
Member Author

I tried this first, but it didn't seem to work. I didn't check in detail, but I think the conclusion was that the current approach in TensorKitSectors has a loop of fixed length which the compilers makes really fast, while porting this approach there gave an indefinite loop length which actually made it slower.

@lkdvos

lkdvos commented Oct 21, 2026

Copy link
Copy Markdown
Member

I wonder if it is just a matter of replacing the typemax of the integer with something static so the compiler can unroll again. If it doesn't immediately work I'm fine with this here as well, in principle these functions aren't marked public in TKS so not depending on that isn't so bad

Comment thread src/sector.jl
@leburgel

Copy link
Copy Markdown
Member Author

I wonder if it is just a matter of replacing the typemax of the integer with something static so the compiler can unroll again.

Apparently yes, this seems to work perfectly. Even better than the closed form here for some reason. I'll clean up the quick test and file this in TensorKitSectors.

Uses `TensorKitSectors.Unbounded` (QuantumKitHub/TensorKitSectors.jl#117), which also
speeds up `getindex`.

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

Copy link
Copy Markdown
Member Author

Done in QuantumKitHub/TensorKitSectors.jl#117, which also covers getindex. Once that's released, this PR reduces to passing TensorKitSectors.Unbounded() (a local commit replacing the closed form is ready); converted to draft until then.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leburgel leburgel changed the title Closed-form findindex for SU(N) irreps Static unbounded sizes in the SU(N) Manhattan indexing Oct 22, 2026
@leburgel
leburgel marked this pull request as ready for review October 22, 2026 14:19
@leburgel

Copy link
Copy Markdown
Member Author

Updated after QuantumKitHub/TensorKitSectors.jl#117 (released in 0.3.11): the closed form is replaced by passing TensorKitSectors.Unbounded() sizes, which also speeds up getindex. Ready for review.

@leburgel
leburgel requested a review from lkdvos October 22, 2026 14:31
@lkdvos
lkdvos merged commit 0013387 into main Oct 22, 2026
9 checks passed
@lkdvos
lkdvos deleted the lb/sun_findindex branch October 22, 2026 19:13
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