---
title: Pagh’s Compressed Matrix Multiplication
url: https://www.emergentmind.com/topics/pagh-s-compressed-matrix-multiplication
type: topic
---

# Pagh’s Compressed Matrix Multiplication

Searching arXiv for Pagh's compressed matrix multiplication and closely related follow-up work.
Pagh’s compressed matrix multiplication is a randomized sketch-based method for representing the product \(AB\) of two real \(n\times n\) matrices in compressed form, so that individual entries can be estimated, large entries can be recovered, and sparse outputs can in some regimes be obtained exactly without materializing the full dense product [1108.1320]. In later terminology, especially in the sparse-multiplication literature, this problem is identified with “robust sparse matrix multiplication,” because the target guarantee is not classical Frobenius- or spectral-norm approximation but an entrywise additive guarantee governed by the tail of the output after removing its \(k\) largest entries [2607.01427]. The line of work originates with Rasmus Pagh’s 2011 paper “Compressed Matrix Multiplication” [1108.1320], which compresses the matrix product via hash-and-sign sketches and FFT-based polynomial multiplication, and it has subsequently been reinterpreted as a sparse-recovery problem, engineered with alternative transforms such as the Fast Walsh–Hadamard Transform, and generalized by black-box reductions from exact sparse matrix multiplication [2601.09477].

## 1. Historical position and terminology

Pagh introduced compressed matrix multiplication as a method for approximating and querying matrix products when the output is sparse or compressible in Frobenius mass, with motivating applications including sample covariance matrices and basis transforms that induce sparsity [1108.1320]. The central objective is not generic acceleration of dense exact matrix multiplication, but output-sensitive recovery of significant entries, together with efficient sparse exact multiplication when the true product has few nonzeros [1108.1320].

Subsequent literature has clarified that “compressed matrix multiplication” in Pagh’s sense is distinct from both classical approximate matrix multiplication and exact algebraic compression schemes. Bringmann, Fischer, and Nakos state that the study of the robust problem “was initiated in 2013 by Pagh,” and note that Pagh “referred to the problem as compressed matrix multiplication,” whereas they prefer the term “robust sparse matrix multiplication” to align with sparse-recovery terminology [2607.01427]. This terminological shift matters because the relevant guarantee is the matrix analogue of the \(\ell_\infty/\ell_2\) sparse-recovery guarantee, not the usual projection- or sampling-based approximation guarantee depending on \(\|AB\|_F\) or \(\|A\|_F\|B\|_F\) [2607.01427].

A separate line, “Compressed Modular Matrix Multiplication,” uses deterministic \(Q\)-adic packing of residues modulo a small prime into machine words and is exact rather than randomized [0803.1975]. That work is algebraic digit packing, not Pagh-style sketching. This distinction is essential because both use the phrase “compressed matrix multiplication,” but the underlying models, guarantees, and arithmetic assumptions are entirely different [0803.1975].

## 2. Core sketching construction in Pagh’s algorithm

Pagh’s method starts from the outer-product decomposition
\[
AB=\sum_{k=1}^n a_k b_k,
\]
where \(a_k\) is column \(k\) of \(A\) and \(b_k\) is row \(k\) of \(B\) [1108.1320]. The product is compressed into a polynomial
\[
p(x) = \sum_{k=1}^n \left( \sum_{i=1}^n A_{ik} s_1(i) x^{h_1(i)} \right) \left( \sum_{j=1}^n B_{kj} s_2(j) x^{h_2(j)} \right),
\]
using random bucket hash functions \(h_1,h_2:[n]\to[b]\) and random sign functions \(s_1,s_2:[n]\to\{-1,+1\}\) [1108.1320]. Expanding the polynomial yields
\[
p(x)= \sum_{i,j} (AB)_{ij}\, s_1(i)s_2(j)\, x^{h_1(i)+h_2(j)},
\]
so the coefficients aggregate signed contributions of product entries that collide under the pair hash
\[
h(i,j)=h_1(i)+h_2(j)\bmod b,
\qquad
s(i,j)=s_1(i)s_2(j).
\]
After reduction modulo \(b\), the bucket coefficients are
\[
c_t=\sum_{(i,j):\, h(i,j)=t} s(i,j)(AB)_{ij},
\]
and the estimator for an entry is
\[
C_{ij} = s_1(i)s_2(j)c_{(h_1(i)+h_2(j)) \bmod b}.
\]
This is a CountSketch-style estimator over index pairs \((i,j)\), with random signs canceling collision noise in expectation [1108.1320].

The method is computationally viable because the sketch of each outer product is a convolution of two length-\(b\) vectors, so FFT computes it in near-linear time. Pagh’s dense-case running time is \(\tilde O(n^2+nb)\), and for sparse inputs with \(N\) total nonzeros the bound is \(O(N+nb\log b)\) [1108.1320]. This suggests that the essential abstraction is not explicit formation of \(AB\), but direct computation of a compressed representation from the factors.

## 3. Statistical guarantees and sparse-output exactness

The basic estimator is unbiased:
\[
\mathbb E[C_{ij}] = (AB)_{ij},
\]
and has variance bounded by
\[
\operatorname{Var}[C_{ij}] \le \frac{\|AB\|_F^2}{b}.
\]
These guarantees arise because the target contribution is always present with squared sign \(1\), while off-target collisions have mean zero under the random signs and occur with probability about \(1/b\) under the hash family [1108.1320].

Pagh also gives a stronger skew-aware entrywise guarantee in terms of the tail energy after removing large entries. Using \(\operatorname{Err}_F^k(M)\) for the squared Frobenius norm after zeroing the \(k\) largest-magnitude entries, the median estimator over \(d\ge 6\log n\) repetitions satisfies
\[
|C_{ij}-(AB)_{ij}| < 12\sqrt{\operatorname{Err}_F^{\,b/20}(AB)/b}
\]
with probability \(1-o(n^{-2})\) [1108.1320]. This is the direct precursor of later robust sparse matrix multiplication guarantees phrased as \(\ell_\infty/\ell_2\)-type tail bounds.

The algorithm also admits exact recovery in sufficiently sparse regimes. If \(AB\) has at most \(b/8\) nonzero entries and \(d\ge 6\log n\), median decoding returns every entry exactly with probability \(1-o(1)\) [1108.1320]. More strongly, if \(A\) and \(B\) have at most \(N\) nonzero entries total and \(AB\) has at most \(b\) nonzero entries, then a sparse representation of \(AB\) can be computed with high probability in time \(\tilde O(N+nb)\) [1108.1320]. This exact sparse-output theorem is the point at which compressed matrix multiplication already overlaps with output-sensitive sparse matrix multiplication, rather than merely approximate estimation.

## 4. Recovery of heavy entries and the robust interpretation

A defining feature of Pagh’s framework is that it targets recovery of significant entries rather than low-rank or norm-relative approximation of the full dense product [1108.1320]. To identify large entries without scanning all \(n^2\) positions, the algorithm augments sketching with error-correcting codes. Code bits are used to create masked sketches whose bucket behavior reveals the row and column indices of isolated heavy entries; decoding yields a candidate set of \(O(b)\) positions containing the large-magnitude entries above an appropriate threshold [1108.1320].

Bringmann, Fischer, and Nakos place this guarantee in sparse-recovery language. For sparse inputs \(A,B\in\mathbb R^{n\times n}\) with \(m_{in}=\mathrm{nnz}(A)+\mathrm{nnz}(B)\) and parameter \(k\), they define robust sparse matrix multiplication by the requirement
\[
\|AB-C\|_\infty \le \frac{1}{\sqrt{k}}\|(AB)_{-k}\|_F,
\]
where \((AB)_{-k}\) is obtained by zeroing out the \(k\) largest entries of \(AB\) in absolute value [2607.01427]. They state explicitly that Pagh’s “compressed matrix multiplication” is this robust problem under a later name, and that among known sparse matrix multiplication algorithms, Pagh’s algorithm with running time \(\widetilde O(m_{in}+nk)\) had been the only one known to be robust in this sense [2607.01427].

This interpretation resolves a common misconception. Pagh’s method is not merely an approximate matrix multiplication algorithm in the classical projection or sampling sense. Its central guarantee depends only on the tail of the output, not on the full Frobenius norm of the product, which is substantially stronger when the product is “spiky” and dominated by a small number of large entries [2607.01427].

## 5. Black-box robustification and the modern structural view

The principal modern development is the reduction of robust sparse matrix multiplication to exact sparse matrix multiplication. Bringmann, Fischer, and Nakos prove that if sparse matrix multiplication with \(m_{in}\) nonzero inputs and \(m_{out}\) nonzero outputs runs in time \(T(n,m_{in},m_{out})\), then robust sparse matrix multiplication runs in time
\[
O\!\bigl(n\log^4 n+\log^3 n\cdot T(n,m_{in},k)\bigr)
=
\widetilde O(T(n,m_{in},k)),
\]
with high probability [2607.01427]. Their central message is that Pagh’s guarantee is not a specialized consequence of his FFT-based polynomial encoding, but a black-box consequence of exact sparse multiplication up to polylogarithmic overhead.

The reduction is built around a query model for an unknown matrix \(X\), instantiated later with \(X=AB\). One can query compressed products \(LXR\), where \(L\) has column sparsity \(1\) and \(R\) has row sparsity \(1\); in the multiplication setting, such a query is answered by computing \(LA\), \(BR\), and then \((LA)(BR)\) [2607.01427]. Sparse-recovery sketches are then applied to recover heavy entries from a small number of such compressed products. The technical toolkit includes an \(\ell_2\)-tail estimator, a fast heavy-hitter recovery sketch, and a budget-allocation mechanism that assigns per-column recovery budgets \(t_j\) satisfying
\[
\frac{\|(Xe_j)_{-t_j}\|_2^2}{t_j+1} \le \frac{\|X_{-k}\|_F^2}{k+1}
\quad\text{for all }j,
\qquad
\sum_j t_j = O(k),
\]
with high probability [2607.01427].

A notable element is a minimum-cost multiple-choice knapsack formulation used to estimate the global tail and derive feasible column budgets from sketch data [2607.01427]. This suggests a reinterpretation of Pagh’s original problem: the difficult part is not polynomial compression per se, but allocation of sparse-recovery effort across a highly unbalanced matrix product. In this view, Pagh’s algorithm is the first concrete realization of a broader robustification principle.

## 6. Complexity improvements and implementation refinements

Instantiating the black-box reduction with the state-of-the-art sparse matrix multiplication algorithm of Abboud, Bringmann, Fischer, and Künnemann yields
\[
\widetilde O((m_{in}+k)^{1.346})
\]
for robust sparse matrix multiplication [2607.01427]. In the regime \(k \ge m_{in}^{1.762}\), the same reduction gives
\[
O(k^{1+\epsilon})
\]
for any \(\epsilon>0\), with high probability [2607.01427]. Since \(\Omega(k)\) time is necessary merely to write down \(k\) significant outputs, this is essentially optimal in that regime [2607.01427]. Historically, this both subsumes and improves Pagh’s \(\widetilde O(m_{in}+nk)\) bound.

On the implementation side, recent work has revisited Pagh’s original transform step. “Engineering Compressed Matrix Multiplication with the Fast Walsh-Hadamard Transform” replaces the FFT-based cyclic convolution by Walsh–Hadamard-based XOR convolution, using the pair hash
\[
h(i,j)=h_1(i)\oplus h_2(j)
\]
instead of \(h_1(i)+h_2(j)\bmod b\), while preserving unbiasedness and variance guarantees [2601.09477]. The paper states that all relevant correctness results from Pagh carry over to the FWHT variant, because the analysis depends on pairwise-independent bucket assignment and random signed collisions rather than specifically on cyclic convolution [2601.09477].

Empirically, this engineering study reports that the FWHT variant is up to \(4\times\) faster than the FFT-based version, and under favorable sparsity and magnitude patterns in the product matrix can achieve a speedup of up to \(40\) over Intel MKL’s DGEMM, while retaining low failure probability in the estimates [2601.09477]. The implementation targets dense double-precision matrices on 64-core CPU nodes and provides NumPy-compatible Python bindings [2601.09477]. These results do not alter the algorithmic essence of Pagh’s estimator, but they demonstrate that the sketch-based approach can be practical when the output is sparse or dominated by a few heavy entries.

## 7. Relation to neighboring compressed-multiplication paradigms

Pagh’s compressed matrix multiplication belongs to a broad family of compressed-output methods, but it occupies a specific niche. It differs from classical approximate matrix multiplication in the Cohen–Lewis, Drineas–Kannan–Mahoney, and Sarlós traditions because those methods typically target Frobenius- or spectral-norm approximation of the whole product, whereas Pagh’s method targets entrywise additive recovery of heavy entries and exact sparse-output recovery when possible [1108.1320; 2607.01427]. It also differs from exact deterministic packing methods such as \(Q\)-adic compressed modular multiplication, which encode several residues into one machine word and remain exact provided explicit arithmetic inequalities hold [0803.1975].

It is also distinct from recent compressed-sensing formulations of output-sparse multiplication over arbitrary rings. “Output-Sparse Matrix Multiplication Using Compressed Sensing” gives deterministic and randomized algorithms that compute \(AB\) exactly under a sparsity promise \(\|AB\|_0\le O(n^\delta)\), using explicit compressed sensing and matrix-multiplication verification rather than Pagh’s hash-and-sign polynomial sketch [2508.10250]. That work is conceptually allied to the “compress first, recover later” paradigm, but technically different: it uses deterministic sparse-recovery matrices over arbitrary rings and exact recovery, whereas Pagh’s original framework is randomized, real-valued, and organized around CountSketch-style bucket collisions [2508.10250].

At a broader methodological distance are matrix-compression schemes that support direct exact multiplication in a structured compressed representation, such as grammar-compressed matrix–vector multiplication or adaptive multiplication of \(\mathcal H^2\)-matrices [2203.14540; 2309.09061]. Those lines of work treat “compressed matrix multiplication” as arithmetic directly on compressed operands rather than sketch-based recovery of an implicitly compressed output. The comparison helps isolate what is specific about Pagh’s contribution: not compression of stored matrices, but compressed sensing of the product itself without first forming the product.

In contemporary perspective, Pagh’s compressed matrix multiplication is best understood as the foundational sketch-based formulation of robust sparse matrix multiplication: a method that compresses the product \(AB\) into a small randomized summary, supports unbiased entry queries with variance \(\|AB\|_F^2/b\), recovers heavy entries through coding-based decoding, yields exact multiplication in sparse-output regimes, and—through later work—admits a black-box equivalence to exact sparse matrix multiplication up to polylogarithmic overhead [1108.1320; 2607.01427].

Source: https://www.emergentmind.com/topics/pagh-s-compressed-matrix-multiplication