Matrix Product Sketching via Coordinated Sampling
Majid Daliri, Juliana Freire, Danrong Li, Christopher Musco
TL;DR
This work addresses the problem of approximating the matrix product $\boldsymbol{A}^T\boldsymbol{B}$ from small sketches that are computed independently with a shared random seed. It introduces coordinated sampling via priority sampling to estimate $\boldsymbol{A}^T\boldsymbol{B}$ from row-subsets of $\boldsymbol{A}$ and $\boldsymbol{B}$, providing an unbiased estimator with a Frobenius error bound that matches the best linear-sketch guarantees in the worst case but improves substantially for sparse matrices. The main theoretical result shows a fixed sketch size $k = \frac{2}{\delta\varepsilon^2} + 1$ yielding $\|\mathbf{W}-\boldsymbol{A}^T\boldsymbol{B}\|_F \leq \varepsilon \|oldsymbol{A}\|_F \|oldsymbol{B}\|_F$ with probability $1-\delta$, while being computable entirely independently by the two parties. The authors demonstrate practical benefits in distributed linear regression and attention-matrix approximation for transformers, achieving orders-of-magnitude improvements in space and communication compared with traditional Johnson–Lindenstrauss-style sketches, especially when the input matrices are sparse. Overall, the work offers a scalable, independent-sketch paradigm that preserves accuracy while enabling efficient cross-machine matrix products and related regression tasks.
Abstract
We revisit the well-studied problem of approximating a matrix product, $\mathbf{A}^T\mathbf{B}$, based on small space sketches $\mathcal{S}(\mathbf{A})$ and $\mathcal{S}(\mathbf{B})$ of $\mathbf{A} \in \R^{n \times d}$ and $\mathbf{B}\in \R^{n \times m}$. We are interested in the setting where the sketches must be computed independently of each other, except for the use of a shared random seed. We prove that, when $\mathbf{A}$ and $\mathbf{B}$ are sparse, methods based on \emph{coordinated random sampling} can outperform classical linear sketching approaches, like Johnson-Lindenstrauss Projection or CountSketch. For example, to obtain Frobenius norm error $ε\|\mathbf{A}\|_F\|\mathbf{B}\|_F$, coordinated sampling requires sketches of size $O(s/ε^2)$ when $\mathbf{A}$ and $\mathbf{B}$ have at most $s \leq d,m$ non-zeros per row. In contrast, linear sketching leads to sketches of size $O(d/ε^2)$ and $O(m/ε^2)$ for $\mathbf{A}$ and $\mathbf{B}$. We empirically evaluate our approach on two applications: 1) distributed linear regression in databases, a problem motivated by tasks like dataset discovery and augmentation, and 2) approximating attention matrices in transformer-based language models. In both cases, our sampling algorithms yield an order of magnitude improvement over linear sketching.
