Repository navigation
Rewind the allocator after the temporaries of blas_contract! and planarcontract! - #628
Merged
Merged
Conversation
kshyatt
reviewed
Nov 19, 2026
lkdvos
approved these changes
Nov 19, 2026
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
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.
blas_contract!takes the permuted copies ofA,BandCfrom the allocator and frees them withtensorfree!, but never resets the allocator. For aBufferAllocator,tensorfree!does nothing, sooutside
@tensor(whose own checkpoint covers this) every contraction with symmetric tensors leaves itscopies claimed in the buffer. That includes every pullback of the
tensorcontract!rrule, which passesthe allocator on. Once the offset passes the buffer length, every later temporary becomes an ordinary
allocation, and the buffer is never empty again to be resized.
This puts an
allocator_checkpoint!/allocator_reset!pair around the temporaries, asadd_transform_kernel!and TensorOperations' ownblas_contract!already do.planarcontract!and itstwo
BraidingTensormethods had the same gap; they only leak when called directly, outside@planar.Found in QuantumKitHub/PEPSKit.jl#482, where one PEPS gradient with U(1) tensors at D = 3 left an offset of 7.2 MB in
a 143 KB buffer.
Reproducer
main:This PR: