Papers
Topics
Authors
Recent
Search
2000 character limit reached

Hierarchical Clustering for SpGEMM

Updated 7 July 2026
  • Hierarchical clustering for SpGEMM is a technique that groups matrix rows with shared nonzero indices to improve B-row reuse and lower data movement.
  • It leverages row reordering, Jaccard similarity–based clustering, and a row-clustered CSR format to convert structural overlap into temporal locality.
  • Empirical evaluations show speedups up to 4.68× with reduced preprocessing overhead compared to graph partitioning, highlighting its cost-effective performance gains.

Searching arXiv for the cited papers and closely related work on hierarchical clustering and SpGEMM. Hierarchical clustering for sparse matrix–sparse matrix multiplication (SpGEMM) is a locality-oriented technique that groups rows of the first input matrix AA so that rows with overlapping nonzero column indices are processed together, thereby improving reuse of rows of the second input matrix BB during multiplication. In the formulation developed for Gustavson-style SpGEMM, the method combines row reordering, cluster formation, and a row-clustered sparse format to convert structural overlap in AA into temporal locality for BB, with the explicit goal of reducing data movement in a kernel that is typically memory-bound rather than arithmetic-bound (Islam et al., 28 Jul 2025).

1. Computational setting and locality objective

SpGEMM is a key kernel in many scientific applications and graph workloads, yet it is bottlenecked by data movement due to irregular memory access patterns. In Gustavson’s row-wise algorithm, processing row ii of AA requires streaming the rows of BB indexed by all nonzero column positions pp in that row, and then scattering products into an irregular sparse accumulator for row ii of CC. Two sources of irregularity dominate: the set of rows of BB0 touched by adjacent rows of BB1 changes rapidly and often overlaps, forcing repeated loads of the same BB2 rows, and the accumulator accesses are sparse and unpredictable (Islam et al., 28 Jul 2025).

For BB3, BB4, and BB5, let the set of nonzero column indices in row BB6 of BB7 be

BB8

The scalar multiply-add count in Gustavson’s algorithm is

BB9

where AA0 is the set of nonzeros in row AA1 of AA2 (Islam et al., 28 Jul 2025).

The locality opportunity is cross-row reuse in AA3. If rows AA4 and AA5 satisfy AA6, then they both require the same rows AA7 for AA8. When the two rows are processed with sufficient temporal proximity, those AA9 rows can remain hot in cache and avoid reloads from main memory. This is the key distinction from many SpMV-oriented reorderings, which mostly target bandwidth reduction or adjacency of nonzeros to a dense vector. For SpGEMM, simply reordering rows of BB0 while retaining CSR row-major traversal does not ensure that BB1’s hot rows remain in cache across adjacent BB2 rows (Islam et al., 28 Jul 2025).

To formalize this dependence structure, the method defines a row-intersection graph BB3 over rows of BB4, with BB5, and for BB6, an undirected edge BB7 weighted by

BB8

A partition BB9 of the rows induces a cut

ii0

A locality-maximizing clustering then seeks to minimize

ii1

subject to balance constraints ii2 and optionally ii3. Equivalently, it maximizes the total intra-cluster overlap (Islam et al., 28 Jul 2025).

The same objective can be expressed directly in terms of data movement on ii4. For a cluster ii5, define the set of unique ii6 rows touched by the cluster as

ii7

If ii8 is the number of bytes needed to stream row ii9 of AA0, then the row-wise traffic model is

AA1

whereas the cluster-wise model is

AA2

The reduction factor is approximately

AA3

If AA4 fits in cache, the benefit approaches the ideal suggested by AA5 (Islam et al., 28 Jul 2025).

2. Construction of hierarchical clusters

The hierarchical clustering method is a bottom-up merging scheme driven by overlap estimates obtained from one binary SpGEMM between AA6 and AA7. The procedure sets all values of AA8 to AA9, computes

BB0

and interprets each entry BB1 as the exact overlap count BB2. For each row BB3, it keeps the topK neighbors BB4 by Jaccard similarity

BB5

above a threshold BB6, producing candidate pairs. The paper states that this replaces expensive LSH while yielding exact overlap counts (Islam et al., 28 Jul 2025).

Cluster growth proceeds by greedily merging disjoint-set representatives using a max-heap keyed by similarity, subject to a maximum cluster size BB7 and a minimum similarity threshold BB8. The method is hierarchical in the sense of progressively coarsening row groups guided by overlap. In the reported experiments, practical defaults were BB9 and pp0 (Islam et al., 28 Jul 2025).

A central design choice is the decoupling of reordering from the clustered matrix format. Any reordering can be applied to pp1, or no reordering can be applied, and clusters can then be formed using one of three schemes: fixed-length clustering, variable-length clustering, or hierarchical clustering. Fixed-length clustering uses contiguous blocks of pp2 rows. Variable-length clustering uses contiguous blocks determined by Jaccard similarity to a representative row, subject to pp3 and pp4. Hierarchical clustering merges noncontiguous rows via bottom-up union-find using pp5-derived candidates, followed by relayout (Islam et al., 28 Jul 2025).

This decoupling is conceptually important. The row-clustered format is independent of how clusters were chosen, and its benefits accrue whenever intra-cluster overlap is high, regardless of the reordering heuristic used. A plausible implication is that hierarchical clustering should be viewed less as a single monolithic preprocessing step than as one element in a modular locality pipeline (Islam et al., 28 Jul 2025).

3. Row-clustered sparse format and cluster-wise execution

To realize the locality implied by clustering, the method introduces a row-clustered CSR layout, denoted CSRpp6, that stores nonzeros grouped by column within a cluster, enabling column-wise traversal over merged rows. The format contains a cluster pointer array, and for each cluster pp7, a column header array listing the union

pp8

in ascending column order. For each column pp9, it stores a compact list of ii0 pairs for rows ii1 that satisfy ii2. Variable-length CSRii3 uses sparse per-column lists and an additional pointer array to values; a fixed-length variant can encode a dense row mask for the cluster (Islam et al., 28 Jul 2025).

Indices are remapped so that rows are local within a cluster, ii4, allowing tight loops over cluster rows. Metadata per cluster includes the cluster size, a mapping from row-local indices to global row IDs or an implicit mapping via original IDs and cluster sizes, and offsets to each column’s sublists. The reported space overhead stems from padding when ii5 is large but many rows in ii6 do not have that column; empirically it is ii7 in ii8 of cases, and is often smaller than standard CSR because indices are shared across rows within a column of a cluster (Islam et al., 28 Jul 2025).

The associated access pattern is column-major within each cluster. For every cluster ii9, the algorithm traverses each column CC0 once, loads row CC1 into cache, and then updates every row CC2 for which CC3 is present. In condensed form, the multiply phase is:

  • parallelize over clusters CC4;
  • for each column CC5, load row CC6;
  • for each CC7 in the column-sublist of CC8, recover the global row CC9;
  • for each BB00, update the accumulator entry for BB01.

This changes the reuse mechanism from accidental cache residency under row-wise traversal to explicit one-read-per-cluster reuse of BB02 when overlap is present (Islam et al., 28 Jul 2025).

The arithmetic work remains

BB03

but memory traffic for BB04 approaches BB05 rather than BB06. Preprocessing complexity depends on the clustering method. Fixed-length clustering requires BB07 conversion. Variable-length clustering requires BB08 for similarity scans of consecutive rows, plus BB09 conversion. Hierarchical clustering requires one BB10 with unit values, topK filtering, union-find merges with complexity BB11 where BB12, followed by BB13 conversion (Islam et al., 28 Jul 2025).

4. Relationship to matrix reordering

The study evaluates ten reordering algorithms: Original, Random (Shuffled), Reverse Cuthill–McKee (RCM), Approximate Minimum Degree (AMD), Nested Dissection (ND), Graph Partitioning (GP via METIS, edge cut), Hypergraph Partitioning (HP via PaToH, cut-net/quality), Gray code ordering, Rabbit, Degree-based, and SlashBurn. Their objectives differ. CM/RCM target bandwidth reduction to improve locality. AMD/ND target fill-in reduction. GP/HP minimize cut and thereby implicitly maximize intra-part overlap of BB14, which aligns well with the cut objective on the row-intersection graph. Gray, Rabbit, Degree, and SlashBurn aim to group structurally similar rows or communities and to reduce random accesses (Islam et al., 28 Jul 2025).

The empirical finding is that reordering based on graph partitioning provides better SpGEMM performance than existing alternatives at the cost of high preprocessing time. The paper also states that GP/HP perform best for SpGEMM because their optimization more directly minimizes cross-part edges weighted by overlap, which is strongly correlated with reducing duplicate reads of BB15 across parts. However, many GP/HP instances require BB16 the cost of one SpGEMM to amortize, whereas hierarchical clustering achieves competitive speedups at BB17 cost in BB18 of inputs (Islam et al., 28 Jul 2025).

This creates a cost–benefit distinction between reordering and clustering. When preprocessing can be amortized over many multiplies, GP or HP may be justified. When preprocessing budget is tighter, hierarchical clustering offers a lower-cost route to exploiting overlap. The paper’s explicit recommendation is to treat reordering and clustering independently. If a domain already provides a good ordering, fixed-length clustering may suffice. If ordering is unknown or expensive, hierarchical clustering yields high-quality clusters, and an implied reordering, in one pass. Combining reordering and clustering can be synergistic but is matrix-dependent (Islam et al., 28 Jul 2025).

A common misconception is that row reordering alone is sufficient for SpGEMM locality. The study directly argues against this: simply reordering rows of BB19 and keeping CSR row-major traversal does not ensure that frequently used rows of BB20 remain in cache across adjacent rows of BB21. Cluster-wise computation is therefore not merely an implementation detail of reordering, but the mechanism that converts structural overlap into realized reuse (Islam et al., 28 Jul 2025).

5. Empirical characterization

The evaluation uses 110 square matrices from SuiteSparse, including 26 from prior SpGEMM studies and 32 from recent graph-oriented suites. Selection ensures BB22M, BB23B, and reduced redundancy among grouped publishers, while full SNAP and DIMACS10 are kept. Results are averaged over 10 runs on Perlmutter CPU nodes with AMD EPYC 7763, 64 cores, DDR4, BB24 MiB/core, OpenMP with 64 threads, Intel icpc 2024.1 BB25, and a hash-table accumulator. The workloads are BB26 and BB27 tall-skinny frontier matrices from CombBLAS BC (Islam et al., 28 Jul 2025).

For hierarchical clustering, the reported average speedup is BB28, with improvements on BB29 of matrices. The distribution shows speedups up to BB30, with most between BB31 and BB32. The preprocessing cost is BB33 the cost of a single SpGEMM on BB34 of inputs (Islam et al., 28 Jul 2025).

For reordering alone, HP achieves geomean BB35 with positive speedups on BB36 of inputs, and GP and RCM are also strong. Best-per-matrix reordering achieves up to BB37 geomean across datasets, but with high overhead (Islam et al., 28 Jul 2025).

For clustering without reordering, fixed-length and variable-length clustering speed up BB38 and BB39 of cases, respectively. With HP or GP preprocessing, they improve BB40 of inputs with BB41 geomean. On tall-skinny SpGEMM, reorderings that help BB42 also help BB43, and hierarchical clustering is often beneficial across frontier iterations, which the paper interprets as confirming reuse benefits independent of the specific BB44 operand (Islam et al., 28 Jul 2025).

The paper also supplies an illustrative example. If

BB45

then BB46, BB47, BB48, and so forth. For cluster BB49, the touched set is BB50. In row-wise SpGEMM, BB51 is read three times across rows BB52, and BB53 twice. In cluster-wise traversal, BB54 and BB55 are each read once per cluster, reducing BB56 to BB57 by BB58–BB59 for those rows (Islam et al., 28 Jul 2025).

The method is explicitly most beneficial when rows of BB60 share substantial overlap in BB61, but similar rows are not adjacent. Low-overlap matrices, including diagonally dominant or random sparsity patterns, yield little reuse; clustering then adds overhead and padding. Fixed-length clustering can inflate memory because of padding columns with sparse participation. Excessively large clusters can expand BB62 beyond cache, negating locality. The paper therefore recommends choosing BB63 and BB64 so that the expected BB65 fits in BB66, and stopping merging when adding a row increases BB67 beyond cache-, NUMA-, or bandwidth-optimal bounds, or when BB68 (Islam et al., 28 Jul 2025).

There are also interactions with parallelism. Union-find merging can produce uneven clusters, and load imbalance may hurt parallel efficiency. Variable or heterogeneous cluster sizes require dynamic scheduling. Per-row accumulators should be private or lock-free. Symbolic computation can be fused with numeric by first-touch marker arrays per row. The format primarily improves BB69-row reuse; hash-based kernels benefit most, though heap- and SPA-based kernels can also benefit from reduced BB70-row read duplication (Islam et al., 28 Jul 2025).

GPU-specific constraints are not addressed in the row-clustering work; the paper states that extending CSRBB71 to GPUs requires careful tiling. This is distinct from the sense of hierarchy in "Communication-Avoiding SpGEMM via Trident Partitioning on Hierarchical GPU Interconnects," where “hierarchy-aware partitioning/clustering” refers to grouping computation and communication to match the hardware hierarchy of local and global interconnects, rather than clustering rows by overlap. That work introduces Trident, a hierarchy-aware 2D distributed SpGEMM algorithm for modern heterogeneous supercomputers, and explicitly clarifies that this usage of clustering is not graph or data clustering (Bellavita et al., 22 Mar 2026).

A broader antecedent appears in "Rapid Near-Neighbor Interaction of High-dimensional Data via Hierarchical Clustering," which introduced a method for obtaining a matrix permutation that renders a desirable sparsity profile, guided by the principle of a block-sparse matrix with dense blocks, using lower-dimensional embedding, hierarchical data clustering, multi-level matrix compression storage, and multi-level interaction computations (Pitsianis et al., 2017). This suggests a wider lineage of locality-oriented hierarchical organization for sparse computations. However, the row-overlap formulation for SpGEMM is more specific: it derives clusters directly from shared BB72-row access requirements and couples them to a cluster-wise access pattern and a row-clustered CSR layout (Islam et al., 28 Jul 2025).

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Hierarchical Clustering for SpGEMM.