Skip to content

perf: fix performance regression for non-abelian index manipulations - #521

Open
lkdvos wants to merge 3 commits into
mainfrom
ld-indexmanipulation
Open

perf: fix performance regression for non-abelian index manipulations#521
lkdvos wants to merge 3 commits into
mainfrom
ld-indexmanipulation

Conversation

@lkdvos

@lkdvos lkdvos commented Aug 30, 2026

Copy link
Copy Markdown
Member

This refactors some of the process for handling the allocators for the implementation of the GenericTreeTransformer, which should restore the performance from v0.16.5 by no longer having to allocate buffers for each separate block. Along the way I also added taskforeach since that pattern kept showing up and the version with resources is hard to express with OhMyThreads.jl, so in some follow-up PRs I might actually switch more things to that as well.

This fixes #517.

@lkdvos

lkdvos commented Aug 30, 2026

Copy link
Copy Markdown
Member Author

Some benchmark results to show that this resolves #517, using the reproduction script from that issue (single-threaded, Julia 1.12.6; different machine than the issue's numbers, so compare ratios rather than absolute times). Minimum times, allocations per call in parentheses:

permute(t, p):

sector type v0.16.5 v0.17.1 (main) this PR PR / main PR / v0.16.5
fℤ₂ 0.0915 ms (65) 0.0835 ms (63) 0.0555 ms (73) 0.66× 0.61×
fℤ₂ ⊠ U(1) 0.0327 ms (317) 0.0423 ms (315) 0.0374 ms (325) 0.88× 1.15×
SU(2) 0.1558 ms (1841) 0.3155 ms (2845) 0.1955 ms (1932) 0.62× 1.25×
fℤ₂ ⊠ U(1) ⊠ SU(3) 0.0253 ms (470) 0.0427 ms (649) 0.0263 ms (491) 0.62× 1.04×

braid(t, p, levels):

sector type v0.16.5 v0.17.1 (main) this PR PR / main PR / v0.16.5
fℤ₂ 0.0933 ms 0.0627 ms 0.0552 ms 0.88× 0.59×
fℤ₂ ⊠ U(1) 0.0312 ms 0.0424 ms 0.0374 ms 0.88× 1.20×
SU(2) 0.1570 ms 0.3163 ms 0.1793 ms 0.57× 1.14×
fℤ₂ ⊠ U(1) ⊠ SU(3) 0.0255 ms 0.0427 ms 0.0267 ms 0.63× 1.05×

The 1.7–1.9× regression relative to v0.16.5 that the issue reported is gone for the non-abelian cases, and the allocation counts are back at v0.16.5 levels (SU(2): 2845 → 1932 vs 1841 on v0.16.5).

A few additional observations:

  • The issue's tensors are quite small. On larger tensors (4-leg permutes of SU2Space(0 => 12, 1/2 => 10, 1 => 6, 3/2 => 4)), this branch measures at parity with v0.16.5 single-threaded (0.80 ms vs 0.84 ms median) and ahead of it with set_num_transformer_threads(4) (0.38 ms vs 0.44 ms median), since the calling thread now participates as a worker.
  • For the very small non-abelian tensors of the issue there is a small residual gap vs v0.16.5 (SU(2) ~1.2×) that is per-call overhead rather than the buffer strategy; this will be investigated in a follow-up (e.g. normalizing levels in the treebraider cache key for symmetric braidings).

@lkdvos
lkdvos marked this pull request as ready for review August 30, 2026 09:16
@codecov

codecov Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.11765% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/auxiliary/auxiliary.jl 82.75% 5 Missing ⚠️
src/tensors/treetransformers.jl 94.44% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/tensors/indexmanipulations.jl 90.43% <100.00%> (+2.08%) ⬆️
src/tensors/treetransformers.jl 95.78% <94.44%> (+13.26%) ⬆️
src/auxiliary/auxiliary.jl 90.47% <82.75%> (-4.07%) ⬇️
🚀 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.

Regression on main: permute/braid ~1.7–1.9× slower than v0.16.5 for non-Abelian sectors

1 participant