Skip to content

fix: blockwise planartrace! for non-bosonic sectors - #96

Merged
lkdvos merged 1 commit into
mainfrom
bd/planartrace
Nov 28, 2026
Merged

lkdvos merged 1 commit into
mainfrom
bd/planartrace

Conversation

@borisdevos

Copy link
Copy Markdown
Member

Was looking into a ton of kernels so I asked 🤖 to test if there were similar bugs to #94 when it comes to sparse destinations. planartrace! was such a case, only going to the overloaded trace_permute! for bosonic sectors, so it's otherwise quite slow going through the generic kernel in TK, but also incorrect in the exact same way as in #94, dropping blocks a sparse destination didn't already have. So I added a blockwise planartrace!, mimicking the trace_permute! overload. Some timings where it was correct but going through the fallback:

sector source D = 8 D = 32 D = 128
U1 (bosonic) dense / sparse 1.0× 1.0× 1.0×
FermionParity dense 10× 11× 10×
FermionParity sparse 19× 22× 20×
Fibonacci dense 10× 11× 9×
Fibonacci sparse 14× 14× 15×

Speedup = main / this PR (minimum times), for @planar C[a; b] += B[a c; b c] with B :: V ⊗ W ← V ⊗ W, V = SumSpace(sector(D), sector(D/2)) and a 4-block W, into a dense C, on TK 0.17.4, Julia 1.12, 1 thread. Allocations drop from ~900–1300 to ~15–25 per call.

I added a fermionic planartrace! test with dense/sparse source and destination, which currently fails on main for a sparse destination.

I think after this we can patch release to fix the tests failing in MPSKit, unless there's something else worth looking into?

@codecov

codecov Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/tensors/tensoroperations.jl 95.55% <100.00%> (+0.51%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lkdvos lkdvos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patch release sounds good!

@lkdvos
lkdvos merged commit a8eb8fb into main Nov 28, 2026
28 checks passed
@lkdvos
lkdvos deleted the bd/planartrace branch November 28, 2026 14:57
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