Skip to content

Conversation

@rileyjmurray
Copy link
Contributor

@rileyjmurray rileyjmurray commented Oct 10, 2025

Everything in the plan below is implemented and tested.

Plan

  • make sparse matrix arguments const unless mutation is clearly necessary.
    • sketching functions
    • spmm dispatch functions
    • coo spmm kernel (rather, dispatcher to CSC kernels).
    • coo_to_cs[r/c] conversion functions.
  • dispatch efficient matrix-multiply for sparse sketching with row-major data (will resolve Sparse sketching on row-major data dispatches inefficient kernel #131).
  • Allocation of COO sparse matrix data should zero-initialize all arrays. (resolves reserve_coo should zero-initialize all memory #125)
  • utility function for applying a symmetric permutation to a COOMatrix.
  • add deepcopy() instance methods and free functions.
    • CSCMatrix
    • CSRMatrix
    • COOMatrix
  • transpose instance methods for sparse matrix classes.
    • CSCMatrix
    • CSRMatrix
    • COOMatrix
  • eliminate allocation of temporary vals arrays in spmm kernels when alpha != 0.
  • format conversion instance methods
    • COO --> CSC or CSR.
    • CSR --> COO
    • CSC --> COO
  • COOMatrix instance method for sorting

other changes

  • SparseDist and DenseDist
    • have constructors that accept any ordinals for dimensional arguments, rather than only int64_t. We round down floats as needed.
    • add sample(RNGState &seed_state) instance functions.

rileyjmurray and others added 7 commits October 13, 2025 08:13
…. Tweak implementation of safe_scal for improved efficiency.
…coo_to_csr and coo_to_csc so that the COOMatrix argument is const.
Merge branch 'main' into sparse-api-improvements
Merge branch 'sparse-api-improvements' of https://github.com/BallisticLA/RandBLAS into sparse-api-improvements
…copy instance methods to COOMatrix, CSRMatrix, CSCMatrix. Remove COOMatrix copy constructor. Add transpose() instance methods to CSCMatrix, CSRMatrix, COOMatrix. Rename transpose(COOMatrix&) to transpose_as_coo(const COOMatrix&); this doesn't break our API since the former function never appeared in our web docs. Streamline transpose handling in left_spmm dispatch function using the new transpose() instance methods.
@rileyjmurray
Copy link
Contributor Author

rileyjmurray commented Oct 30, 2025

EDIT: the issue below has been resolved.


There's web doc example text that includes the following lines

SkDist D1( d,     m, arg3, Axis::Short );
SkDist D(  d, m + k, arg3, Axis::Short );
// Since d < m and we're short-axis major, the columns of matrices sampled from
// D1 or D1 will be sampled i.i.d. from some distribution on R^d.
using SkOp = typename SkDist::distribution_t;
SkOp S1( D1,  seed_state ); // seed_state is some RNGState.
SkOp  S(  D,  seed_state );
// With these definitions, S1 is *always* equal to the first m columns of S.
// We recover S2 by working implicitly with the trailing k columns of S.

The typedef of SkOp is going backward. Right now we can't programmatically get a handle on the SketchingOperator class associated to a SketchingDistribution.

@rileyjmurray rileyjmurray merged commit 9204a6a into main Oct 31, 2025
5 checks passed
@rileyjmurray rileyjmurray deleted the sparse-api-improvements branch October 31, 2025 20:08
@rileyjmurray rileyjmurray changed the title WIP: Improvements to API for sparse matrices Improvements to API for sparse matrices Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sparse sketching on row-major data dispatches inefficient kernel reserve_coo should zero-initialize all memory

2 participants