On parallelizing matrix multiplication by the column-row method

Andrea Campagna, Konstantin Kutzkov, Rasmus Pagh

TL;DR

This paper introduces CRoP (Column-Row Parallel), a communication-avoiding algorithm for sparse matrix multiplication. By using a clever hashing scheme to distribute output entries across processors, the method achieves linear speedup without any inter-processor communication, making it highly effective for large-scale data mining and streaming applications where the output matrix may be significantly denser than the input.

What Problem Does This Paper Address?

Multiplying two sparse matrices ($A \times B$) is a fundamental operation, but it poses a major challenge in distributed systems: the resulting matrix can be much denser than the inputs, leading to massive storage and communication overhead.

Traditional parallel algorithms (like Cannon’s algorithm) often rely on fixed sub-matrix partitioning. However, if the non-zero entries are not evenly distributed, some processors end up with much more work than others (load imbalance). Furthermore, most state-of-the-art methods require significant inter-processor communication to coordinate which processor handles which part of the sum. The authors tackle the problem of how to parallelize this process in a "shared-nothing" environment where processors can see the input (broadcast) but cannot talk to each other during computation.

Methods

The authors focus on the column-row method, where the product $AB$ is computed as the sum of $n$ outer products: $AB = \sum_{k=1}^{n} a_k b_k^T$.

Their core contribution is the CRoP algorithm, which uses a "consistent" hashing approach:

  1. Consistent Hashing: Every potential output entry $(i, j)$ is assigned to a processor based on a hash function $h(i, j) = (h_a(i) + h_b(j)) \mod \kappa$. Because this function depends only on the indices $i$ and $j$, any processor can independently determine if it is responsible for a specific entry without communicating with others.
  2. Efficient Filtering: To avoid iterating over every possible pair in an outer product (which would be $O(n^2)$), they use the additive structure of the hash function. By sorting the non-zero indices of the input vectors by their hash values, a processor can identify its assigned entries in time nearly linear to the number of non-zeros in the input.
  3. Heavy Hitter Integration: For cases where the output is too large to store, CRoP integrates with streaming algorithms like Space-Saving and Count-Sketch. These allow the system to approximate the "heaviest" (most frequent) entries in the product matrix using very little memory.

Datasets

The researchers evaluated CRoP on a variety of real-world datasets commonly used in frequent itemset mining, where the task is to find pairs of items that often appear together in transactions.

Table 1: Datasets used for evaluation, ranging from small sets like Mushroom to massive ones like Wikipedia with over 500 billion pairs.

Key datasets included:

  • FIMI Repository: Mushroom, Pumsb, Kosarak, Retail, Accidents.
  • UCI Machine Learning Repository: Nytimes, Pubmed (Bag of Words).
  • Wikipedia: A large-scale dataset crafted to test the limits of the algorithm.

Key Insights and Ideas

  • Communication is the Enemy: In modern parallel computing, moving data between processors is often slower than the computation itself. CRoP eliminates inter-processor communication entirely after the initial input broadcast.
  • The Hashing Trick: The specific form of the hash function $h(i, j) = (h_a(i) + h_b(j))$ is the "secret sauce." It allows processors to skip irrelevant data efficiently, turning a potential $O(n^2)$ search into a linear-time operation.
  • Load Balancing by Design: Because the hashing is randomized and pairwise independent, work is distributed extremely evenly across processors, even when the underlying data is highly skewed (e.g., following a power law).
  • Streaming Compatibility: The algorithm doesn't need to store the entire input; it processes vectors one by one, making it ideal for high-speed data streams.

Key Results

  • Linear Speedup: The algorithm demonstrates near-perfect scalability. As more cores are added, the time to process the matrix decreases linearly until the system becomes limited by the speed of reading the input data.
  • High Throughput: On a standard 8-core Mac Pro, the Java implementation processed nearly 100 million pairs per second for the Nytimes dataset.
  • Precision: When combined with Space-Saving summaries, the algorithm provides excellent approximations for the heaviest entries. As shown in the figures below, there is a sharp transition to near-perfect precision as the number of hash buckets increases.
Figure 2: (a) Upper and lower bounds for Nytimes entries relative to true values. (b) Average ratio of lower/upper bounds for top-100 pairs, showing rapid convergence to high precision.

Limitations and Future Work

  • Cache Contention: The authors noted that on some multi-core architectures (like the Intel Xeon E5570), scalability was slightly hampered by L2 cache limitations. If the hash table assigned to a core is too large to fit in its dedicated cache, memory contention between cores can slow down the process.
  • Broadcast Assumption: The method assumes that broadcasting the input to all processors is relatively cheap. In extremely large distributed systems where broadcast is expensive, this trade-off might be less favorable.
  • Positive Updates: While Count-Sketch handles any values, the Space-Saving integration is currently restricted to matrices with positive entries (common in data mining but not all scientific computing).

Summary updated

BibTeX
@inproceedings{campagna2013parallelizing,
  author = {Andrea Campagna and Konstantin Kutzkov and Rasmus Pagh},
  title = {{On parallelizing matrix multiplication by the column-row method}},
  booktitle = {ALENEX},
  year = {2013},
  doi = {10.1137/1.9781611972931.11},
}
Figure