Repository navigation
Treat PtrArray as CPU storage - #629
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
kshyatt
approved these changes
Nov 19, 2026
Jutho
reviewed
Nov 20, 2026
|
|
||
| using Dictionaries: Dictionaries, Dictionary, Indices, gettoken, gettokenvalue | ||
| using OhMyThreads | ||
| using PtrArrays: PtrArray |
Member
There was a problem hiding this comment.
Could we not have used
using TensorOperations.PtrArrays: PtrArray
in order not to have to have PtrArrays as explicit dependency and maintain its compat bounds. Or is this a bad coding pattern?
Member
There was a problem hiding this comment.
I do think that is not the best code pattern, although I do think we have done this in other parts of our codebase as well. Ultimately dependabot will handle the compat entries so it might be fine for now
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.
Temporaries from TensorOperations'
ManualAllocatorarePtrArrays, which are not inCPUStorage = Union{Array, Memory}. Their recoupling workspace in fusion-tree transformations with real coefficients and complex data (e.g. SU(2),ComplexF64) therefore misses theBLAS.gemm!method of_recouple!, andmul!on the reshaped view of the reinterpreted buffer falls back toLinearAlgebra._generic_matmatmul!.This adds
PtrArraytoCPUStorage. Its only use onmainis that_recouple!method, whose body only reinterprets the buffer and passes pointers to BLAS. PtrArrays.jl becomes a direct dependency, with the compat bound of TensorOperations, which already depends on it. The grouped subblock kernel of #597 dispatches on the sameCPUStorage, so once rebased it also applies toPtrArray-backed tensors. Measured on #597's head withPtrArrayadded there (an SU(2) PEPS CTMRG corner contraction, D = 7, χ = 49):ManualAllocator0.085 s → 0.043 s with the_recouple!method alone, 0.010 s with both, against 0.012 s for aBufferAllocator.Found in QuantumKitHub/PEPSKit.jl#482, where using a
ManualAllocatorgave a significant slowdown due to theBLAS.gemm!miss in the recouplings.Reproducer
main:This PR:
Julia 1.12.7, TensorOperations 5.8.4, 1 Julia thread, 8 BLAS threads; the first call includes compilation.
🤖 Generated with Claude Code