Repository navigation
blockwise _transpose! - #95
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
lkdvos
approved these changes
Nov 27, 2026
lkdvos
enabled auto-merge (squash)
November 27, 2026 17:06
borisdevos
referenced
this pull request
Nov 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #94. I got lazy writing PR descriptions so I asked 🤖 to summarise for me.
BlockTensorKit overloaded the public
transpose!directly, which covers every route except a destination wrapped asAdjointTensorMap(D): none of the overloads accept it, so TensorKit unwraps it and calls its generic_transpose!on the block tensor. For a sparseDthat's wrong (the same missing-block issue as in #94), for a dense one it's correct but slow (6–50×).This PR replaces the
transpose!overloads by blockwiseTK._transpose!methods, like_braid!and_twist!, with two small additions to keep everything else as fast as on main:transpose!has no twist mask, so destination blocks that areAdjointTensorMaps (e.g. writing intot') can be unwrapped as well. Without this, those were 2–5× slower than on main.@inboundsinside the_addblock!closure of the sparse loop, since it doesn't reach into the closure. Without this, every block got an extra space check, making sparse transposes of small blocks ~5–10% slower. There's no benefit for doing the same for the sparse loops of_braid!and_twist!(tested locally).Against main, all other cases run at the same speed with identical allocations.
I added a test for
permute!,braid!andtranspose!into anAdjointTensorMapdestination, which currently fails on main fortranspose!with a sparse destination.