Repository navigation
Avoid boxing the views captured by the threaded BLAS multiplication - #94
Merged
Merged
Conversation
`Chead`, `Ahead` and `Bhead` are assigned in both branches of `_threaded_blas_mul!` and captured by the closure of `Threads.@spawn`, which makes Julia box them. These boxes are allocated whenever the function is called, also when it takes the single-threaded path. Interpolating the variables into `Threads.@spawn` avoids capturing them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 13, 2026
Merged
Member
Author
|
Test failures are just the inference checks that have now been resolved through StridedViews 0.5.5, I can rerun them but don't want to overburden the queueueueue |
Jutho
approved these changes
Oct 14, 2026
Member
|
Is it worth (if feasible) adding an allocation test? |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lkdvos
referenced
this pull request
Oct 15, 2026
* Extend GPUArrays compat to 12 and JLArrays compat to 0.4 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Compare device math approximately in single-element GPU tests `abs` and `abs2` of complex numbers may round differently on the device (e.g. AMDGPU's `hypot`), so compare those reductions with `≈`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Chead,AheadandBheadare assigned in both branches of_threaded_blas_mul!and captured by theThreads.@spawnclosure, so Julia boxes them. The boxes (3 × 16 B) are allocated on every call, including the single-threaded path taken by small multiplications. Interpolating them intoThreads.@spawnavoids the capture.This is one of the two sources of the allocation reported in QuantumKitHub/TensorOperations.jl#273. With this change (and the corresponding TensorOperations fix), the
StridedBLAScontraction from that issue no longer allocates.The blas multiplication tests pass with 4 threads, both single-threaded, multi-threaded, and with
enable_threaded_mul().🤖 Generated with Claude Code