Use the sparse kernels in mul! of two sparse matrices into a caller-supplied dense matrix - #868
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #868 +/- ##
==========================================
+ Coverage 92.97% 93.01% +0.03%
==========================================
Files 12 12
Lines 9072 9076 +4
==========================================
+ Hits 8435 8442 +7
+ Misses 637 634 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
AbstractVecOrMat right factor in sparse mul! kernelsAbstractVecOrMat dense-side factor in sparse mul! kernels
… sparse kernels Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
ViralBShah
force-pushed
the
vs/mul-abstractvecormat
branch
from
September 20, 2026 12:19
4384a70 to
f4740f8
Compare
AbstractVecOrMat dense-side factor in sparse mul! kernelsmul! destination with the sparse kernels
mul! destination with the sparse kernelsmul! of two sparse matrices into a caller-supplied dense matrix
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.
Rebased on #865, which merged the rest of what this PR first proposed for #35 (any
AbstractVecOrMatdense factor on either side, and no moregeneric_matmatmul_wrapper!methods). What is left is the case #865 kept on the generic product: both factors sparse, destination dense. This is only aboutmul!into a dense matrix the caller supplies;A * Bof two sparse matrices is untouched and still returns a sparse matrix.mul!(C::StridedMatrix, tA, tB, A::sparse, B::sparse, α, β)calledLinearAlgebra._generic_matmatmul!, which reads both factors elementwise; with a transposed left factor that is a sparsegetindexper entry of an n × n sweep. It now callsspdensemul!, which walks the stored columns of the left factor and only indexes the right one. Two cases keep a cheaper route:A' * B'/transpose(A) * transpose(B)run as(B * A)'into the wrapped destination (real and complex eltypes only, since that needs commutativity), and symmetric/Hermitian × symmetric/Hermitian stays on the generic product, which measured faster. Results now follow the sparse kernels' convention of skipping structural zeros of the left factor, as sparse × dense already does. No new methods, so dispatch is unchanged;detect_ambiguitiesagainst LinearAlgebra and Base reports none.mul!(C, fA, fB, 2.0, 0.5), n = 500, 5 nonzeros per column, nightly, ms main → PR, 0 allocations throughout:BB'Symmetric(B)view(B, :, 1:n)AA'Symmetric(A)The benchmark tables of #865, #866 and #867 (n = 3000 sparse-dense products,
doton column views, dense × sparse triangular) rerun on main and on this branch agree within run-to-run noise, with identical allocations.Tests extend the #865 testset: each sparse factor times
S'into a dense destination, real and complex, and two stored-zero proofs that fail on main. FullPkg.test()andtest/ambiguous.jlpass on nightly.Left out: a kernel that walks both patterns, which would avoid the remaining sparse
getindexper stored entry of the left factor and output column;Symmetric(A) * SparseVectorstill reaches the generic fallback.Written by Claude Code (Claude Fable 5.1).
🤖 Generated with Claude Code