---
title: Output-Sparse Matrix Multiplication
url: https://www.emergentmind.com/topics/output-sparse-matrix-multiplication-osmm
type: topic
---

# Output-Sparse Matrix Multiplication

Searching arXiv for recent OSMM papers and exact IDs cited in the article.
Output-Sparse Matrix Multiplication (OSMM) denotes sparse matrix multiplication in regimes where algorithmic cost is intended to reflect not only input sparsity but also the sparsity, restriction, or practical significance of the output. In its most direct form, OSMM asks to compute \(AB\) exactly when two sparse matrices are multiplied and the product itself has only \(m_{out}\) nonzero entries, with running time depending on \(m_{in}\) and \(m_{out}\) rather than on ambient dense dimensions alone [2309.06317]. More broadly, the literature also treats masked products, support-restricted products, and robust top-\(k\) variants as output-sparse or output-aware forms of sparse matrix multiplication, because they compute only a prescribed or significant subset of output entries [2508.04077, 2607.01427].

## 1. Problem definition and scope

In the exact output-sensitive formulation, the input consists of sparse matrices \(A\) and \(B\), represented as lists of nonzero entries, and the key parameters are \(m_{in}\), the total number of nonzeros in the inputs, and \(m_{out}\), the total number of nonzeros in the product \(AB\) [2309.06317]. The goal is to compute \(AB\) with running time depending explicitly on both \(m_{in}\) and \(m_{out}\). This is the sense in which OSMM is “output-sparse”: the output sparsity is part of the problem specification, not merely an observed consequence after computation [2309.06317].

A broader systems and application-level view uses the general sparse matrix product
\[
Y \gets AX,
\]
or, when an output mask is present,
\[
Y \gets M \odot AX.
\]
This perspective places canonical sparse matrix-matrix multiplication (SpGEMM), Masked-SpGEMM, SpMM, SDDMM, and related variants in one algebraic framework [2508.04077]. Within that framework, OSMM is the subset where the result itself is sparse, only a sparse subset of output indices is required, or the multiplication should be organized to avoid materializing dense or unnecessarily large intermediates [2508.04077].

The literature distinguishes exact OSMM from two neighboring notions. The first is masked or support-restricted multiplication, where the output sparsity pattern is known in advance and only entries permitted by a sparse mask are computed:
\[
Y\langle M\rangle \gets AX, \qquad Y \gets M \odot AX.
\]
The second is robust or top-\(k\) output recovery, where one does not compute all nonzeros exactly but instead recovers the significant output entries with error controlled by the small tail of the product [2508.04077, 2607.01427].

## 2. Exact output-sensitive complexity

A central recent complexity result studies sparse matrix multiplication when
\[
m_{out}=\Theta(m_{in}^r),\qquad r\in[0,2],
\]
and defines the sparse multiplication exponent \(\sigma(r)\) as the unique solution of
\[
\omega(\sigma-1,\,2-\sigma,\,1+r-\sigma)=\sigma.
\]
Here \(\omega(a,b,c)\) is the rectangular matrix multiplication exponent for multiplying an \(n^a\times n^b\) matrix by an \(n^b\times n^c\) matrix [2309.06317]. The resulting exact bounds are \(O(m_{in}^{\sigma(r)+\varepsilon})\) for Boolean matrices deterministically and for arbitrary rings randomized, for every \(\varepsilon>0\) [2309.06317].

In the fully sparse regime, where
\[
m=m_{in}+m_{out},
\]
the same work gives
\[
O(m^{1.3459})
\]
using current rectangular matrix multiplication bounds, improving the previous \(O(m^{1.4071})\) benchmark in the Boolean case [2309.06317]. The paper further states that when \(m_{out}\ge \Omega(m_{in}^{1.762})\), the runtime is already near-linear \(m_{in}^{1+o(1)}\), hence almost optimal unconditionally [2309.06317]. This identifies a regime in which exact OSMM becomes essentially output-linear.

The underlying algorithmic strategy has two stages. First, a sparse-output product is reduced to multiplication in a smaller rectangular space whose outer dimensions satisfy roughly \(x'z' \lesssim m_{out}\); second, that reduced problem is solved by a heavy/light decomposition together with dense rectangular multiplication on the heavy part [2309.06317]. A key conceptual consequence is that output sparsity can be converted into dimensional shrinkage, after which fast rectangular matrix multiplication determines the asymptotic frontier [2309.06317].

The same work relates this frontier to all-edge triangle problems. It proves conditional lower bounds matching the upper-bound exponent \(\sigma(r)\) under a partially sparse all-edge triangle hypothesis, and in the fully sparse case gives an equivalence to a specific unbalanced all-edge triangle problem [2309.06317]. This positions exact OSMM at a fine-grained boundary tied closely to sparse graph triangle structure.

## 3. Compressed sensing and exact OSMM over rings

A separate exact OSMM framework studies \(n\times n\) matrices over an arbitrary ring \(R\) under the promise
\[
\|AB\|_0 \le O(n^\delta), \qquad \delta\in[0,2].
\]
This is \(\delta\)-OSMM over \(R\): the output is promised sparse, while the inputs may be dense [2508.10250]. The paper gives two compressed-sensing-based algorithms.

The deterministic algorithm runs in
\[
O\!\left(n^{\omega(\delta/2,1,1)+\varepsilon}\right)
\]
arithmetic operations over any ring \(R\), for all \(\delta\in[0,2]\) and \(\varepsilon>0\) [2508.10250]. Its mechanism is a two-pass reduction to sparse recovery. If \(C=AB\) has at most \(t^2\) nonzeros, with \(t\approx n^{\delta/2}\), the first pass recovers every \(t\)-sparse column of \(C\) from measurements
\[
HC = H(AB) = (HA)B,
\]
where \(H\) is a sparse deterministic compressed-sensing matrix [2508.10250]. Since there can be fewer than \(t\) columns with more than \(t\) nonzeros, the residual has fewer than \(t\) nonzero columns, and therefore every row of the residual is \(t\)-sparse; a second recovery pass on the transpose completes the product [2508.10250].

The randomized algorithm improves the exponent to
\[
O(n^{\beta+\varepsilon}),\qquad
\beta=
\begin{cases}
2 & \text{if } \delta \le 1+\omega^\perp,\\
\omega(\delta-1,1,1) & \text{otherwise,}
\end{cases}
\]
where \(\omega^\perp := \sup\{\eta\ge 0 : \omega(1,1,\eta)=2\}\) [2508.10250]. It iteratively peels columns by sparsity scale using compressed sensing and a column-wise Freivalds-type verification routine. The active subproblem width shrinks with the threshold, and a flattening inequality yields the bound \(\omega(\delta-1,1,1)\) [2508.10250].

The paper also proves optimality for the randomized bounds by reduction from rectangular matrix multiplication. For OSMM with \(\delta\in[1,2]\), there is a randomized algorithm in time \(O(n^{\beta+\varepsilon})\) for every \(\varepsilon>0\) if and only if
\[
\beta \ge \omega(\delta-1,1,1)
\]
[2508.10250]. This gives exact OSMM an alternative compressed-sensing interpretation: sparse recovery is used not to approximate the output, but to reconstruct it exactly from a small number of structured measurements.

## 4. Robust and top-\(k\) output variants

A recent generalization replaces exact recovery of all output nonzeros by recovery of the significant output entries. For \(A,B\in\mathbb{R}^{n\times n}\) and \(k\ge 1\), robust sparse matrix multiplication asks for a matrix \(C\) such that
\[
\|AB-C\|_\infty \le \frac{1}{\sqrt{k}}\|(AB)_{-k}\|_F,
\]
where \((AB)_{-k}\) is obtained by zeroing out the largest \(k\) entries in absolute value [2607.01427]. This is an \(\ell_\infty/\ell_2\)-style tail guarantee for matrices, and the paper observes that if \(k\ge m_{out}\), then \((AB)_{-k}=0\), so the guarantee forces \(C=AB\) exactly [2607.01427]. In that sense, robust sparse multiplication strictly generalizes exact sparse multiplication.

The main theorem is a black-box reduction from exact output-sensitive multiplication to robust top-\(k\) multiplication. If sparse matrix multiplication with input sparsity \(\IN\) and output sparsity \(\OUT\) runs in time \(T(n,\IN,\OUT)\), then robust sparse matrix multiplication is computable in time
\[
O(n\log^4 n + \log^3 n \cdot T(n,\IN,k))
= \widetilde O(T(n,\IN,k))
\]
by a randomized algorithm that succeeds with high probability [2607.01427]. In OSMM terms, any exact output-sensitive sparse multiplication routine can be converted into a robust top-\(k\) output-sensitive routine with only polylogarithmic overhead, replacing \(m_{out}\) by \(k\) [2607.01427].

Plugging in the state-of-the-art exact sparse multiplication algorithm yields
\[
\widetilde O((m_{in}+k)^{1.346}),
\]
and when
\[
k \ge m_{in}^{1.762},
\]
the paper obtains
\[
O(k^{1+\epsilon})
\]
for any \(\epsilon>0\), with high probability [2607.01427]. Since outputting \(k\) entries costs \(\Omega(k)\), the paper describes this as “almost-optimal” in that regime [2607.01427].

The reduction treats \(X:=AB\) as an unknown matrix accessible through compressed products \(LXR\), where \(L\) and \(R\) are sparse sketching matrices with
\[
L \in \{-1,0,1\}^{\ell\times n}
\quad\text{with column sparsity 1,}
\qquad
R \in \{-1,0,1\}^{n\times r}
\quad\text{with row sparsity 1.}
\]
Because
\[
LXR = (LA)(BR),
\]
such queries can be implemented via exact sparse multiplication on compressed instances [2607.01427]. The reduction then combines \(\ell_2\)-tail sketches, heavy-hitter recovery sketches, Count-Sketch, AMS sketches, random signs, error-correcting-code ideas, and a minimum-cost multiple-choice knapsack approximation to allocate per-column recovery budgets whose total sum is \(O(k)\) [2607.01427].

This robust variant is not exact OSMM unless \(k\ge m_{out}\) or the tail is zero, but it is more targeted than standard approximate matrix multiplication. The approximation depends on \(\|(AB)_{-k}\|_F\), not on all of \(AB\), and is entrywise rather than merely Frobenius-norm global [2607.01427]. This suggests a distinct OSMM regime: products that are sparse up to noise, or whose application semantics depend mainly on a sparse set of dominant entries.

## 5. Symbolic structure, masks, and compression ratio

Many practical sparse multiplication systems do not know \(m_{out}\) or the exact output structure in advance. A survey treatment emphasizes that SpGEMM is harder than SpMM because the output size is often unknown beforehand, and that output sparsity may arise explicitly through masks, implicitly through sparse products, or through application-level pruning and truncation [2508.04077]. In Masked-SpGEMM and SDDMM, only entries in a sparse mask are computed:
\[
Y\langle M\rangle \gets AX, \qquad Y \gets M \odot AX,
\]
which is the most direct systems realization of output-restricted multiplication [2508.04077].

The same survey highlights two implementation strategies for masked multiplication in triangle counting. One may use a mask-driven or output-driven method that iterates over existing mask entries and computes only the required dot products, or an input-driven method that traverses the sparse inputs but suppresses writes for entries masked out [2508.04077]. This distinction formalizes two contrasting OSMM philosophies: compute from desired outputs, or compute from input structure while filtering the result.

A related systems problem is output-structure prediction. One recent method predicts the number of nonzeros per output row by estimating the sampled compression ratio
\[
\mathrm{CR} = \frac{\mathrm{FLOP}(C)}{\mathrm{NNZ}(C)}
\]
rather than estimating \(\mathrm{NNZ}(C)\) directly [2207.13848]. Given exact row-wise FLOP counts and a sampled estimate \(r^*\) of the compression ratio, the predicted output row size is
\[
\widehat{\mathrm{NNZ}_i(C)} = \frac{\mathrm{FLOP}_i(C)}{r^*}.
\]
On 625 test cases, the paper reports average absolute relative error \(1.56\%\) for the proposed method versus \(8.12\%\) for the reference design, with worst-case errors \(25\%\) and \(156\%\), respectively [2207.13848]. This is not exact symbolic computation, but it addresses a core OSMM systems requirement: memory allocation and load balancing before materializing the output.

The notion of compression ratio also appears in performance studies as
\[
\mathrm{CR} = \frac{\mathrm{flop}}{\mathrm{nnz}(C)},
\]
quantifying how many intermediate products collapse into each final output nonzero on average [1804.01698, 2002.11302]. High compression ratio means the cost is driven more by candidate products than by actual output entries; low compression ratio means the output is sparse in a stronger, more directly exploitable sense [1804.01698, 2002.11302].

## 6. Systems, distributed, and I/O perspectives

In shared-memory implementations, exact SpGEMM kernels are often organized row-wise and compared via their dependence on intermediate work and output materialization. A study of multicore and Intel KNL systems models hash-based SpGEMM with
\[
T_{hash} = flop * c + \sum_{i=1}^{n} \left( nnz(c_{i*}) * \log nnz(c_{i*}) \right),
\]
where the first term reflects accumulation over generated products and the second reflects sorting output rows when sorted output is required [1804.01698]. The same paper models heap-based SpGEMM as
\[
T_{heap} = \sum_{i=1}^{n} \left( flop(c_{i*}) * \log nnz(a_{i*}) \right),
\]
making explicit that heap methods depend more strongly on intermediate products than on the final number of output nonzeros [1804.01698]. It concludes that unsorted output can significantly help hash-based methods, and that compression ratio \(flop/nnz(C)\) is a useful predictor of algorithm choice [1804.01698].

A complementary bandwidth-oriented approach, PB-SpGEMM, adopts an outer-product expand-sort-compress structure and analyzes arithmetic intensity in terms of
\[
cf = \frac{flop}{nnz(C)}.
\]
Its temporary storage is \(\Theta(flop)\), so the method is most suitable when the output is sparse and the compression factor is modest [2002.11302]. This sharpens an important OSMM distinction: output sparsity alone is insufficient if it is achieved only after a very large intermediate expansion.

In distributed memory, hypersparsity becomes a local phenomenon even when the global problem is only ordinarily sparse. A foundational 2D SpGEMM work introduces a hypersparse serial kernel based on the outer-product identity
\[
C = \sum_{\ell=1}^{k} A(:,\ell)\,B(\ell,:),
\]
with complexity
\[
O\big(\mathrm{nzc}(A)+\mathrm{nzr}(B)+\mathrm{flops}\cdot \log n_i\big)
\]
and space
\[
O\big(\mathrm{nnz}(A)+\mathrm{nnz}(B)+\mathrm{nnz}(C)\big)
\]
[1006.2183]. Its relevance to OSMM is that local subproblems in a distributed decomposition often have sparse or hypersparse outputs even when the global output is not strongly sparse [1006.2183].

External-memory complexity yields a different exact OSMM benchmark. For sparse matrices \(A\) and \(C\) over a semiring, with
\[
N = \nnz(A)+\nnz(C), \qquad Z = \nnz(AC),
\]
the product can be computed in
\[
\tilde{O} \left(\frac{N}{B} \min\left(\sqrt{\frac{Z}{M}},\frac{N}{M}\right) \right)
\]
I/Os, and this is matched up to polylogarithmic factors by a lower bound
\[
\Omega \left(\frac{N}{B} \min\left(\sqrt{\frac{Z}{M}},\frac{N}{M}\right) \right)
\]
in the semiring I/O model [1403.3551]. This result makes exact OSMM output-sensitive in terms of the true output size \(Z=\nnz(AC)\), even in the presence of cancellation [1403.3551].

A further distributed specialization is the low-bandwidth model with known output support. When each row and column of the support matrices of \(A\), \(B\), and a required-output indicator \(X\) has at most \(d\) nonzeros, the problem can be solved in \(O(d^{1.907})\) rounds over fields and rings supporting fast matrix multiplication and \(O(d^{1.927})\) rounds over semirings [2203.01297]. This is a supported OSMM result: only entries in the known sparse support of \(X\) must be produced.

## 7. Applications, distinctions, and open directions

OSMM arises across graph algorithms, machine learning, computational biology, chemistry, and scientific computing. Triangle counting is a canonical masked example:
\[
T = L^2 \circ L,
\]
where computing all of \(L^2\) is wasteful when wedges far outnumber triangles [2508.04077]. Sparse attention similarly computes only masked entries,
\[
A = M \odot QK^T,
\]
and graph sampling or mini-batch extraction in GNNs constructs sparse submatrices rather than full dense products [2508.04077]. In computational biology and chemistry, Gram matrices, overlap matrices, and truncation-based products are often effectively output-sparse because only a small subset of pairwise interactions survives thresholds or physical cutoffs [2508.04077].

Several distinctions recur throughout the literature. Exact OSMM computes the full sparse product and is parameterized by \(m_{out}\) or \(\|AB\|_0\) [2309.06317, 2508.10250]. Masked or support-restricted multiplication computes only entries in a known sparse output pattern [2508.04077, 2203.01297]. Robust OSMM computes only the significant entries in a top-\(k\) or heavy-output sense with tail-sensitive error guarantees, and becomes exact only when the tail vanishes or \(k\) dominates the true output sparsity [2607.01427]. This suggests that “OSMM” is best treated as a family of output-aware multiplication problems rather than a single formal problem statement.

A frequent misconception is to identify all sparse matrix multiplication with OSMM. The survey literature explicitly notes that general SpGEMM is broader: sparse inputs do not imply sparse outputs, and in some regimes the output is dense enough that a dense representation is preferable [2508.04077]. Another misconception is that output sparsity alone determines the right algorithm. In semiring settings, even the legality of intersection-based sparse traversal can depend on algebraic properties such as whether implicit zeros act as multiplicative annihilators [2508.04077].

The open directions emphasized by the cited work are complementary. Exact complexity papers point toward improved rectangular matrix multiplication exponents and sharper relations to triangle problems as the route to better exact bounds [2309.06317]. Compressed-sensing approaches suggest further simplification or derandomization, especially over rings [2508.10250]. Robust top-\(k\) work implicitly highlights deterministic robustification and stronger guarantees as natural next questions [2607.01427]. Supported distributed results explicitly ask whether the assumption of known output support can be removed [2203.01297]. Taken together, these directions indicate that the central unresolved theme in OSMM is not merely exploiting sparsity, but exploiting the right notion of output structure—exact support, masked support, or heavy-output significance—under the appropriate computational model.

Source: https://www.emergentmind.com/topics/output-sparse-matrix-multiplication-osmm