[Paper Review] An Efficient Shared-memory Parallel Sinkhorn-Knopp Algorithm to Compute the Word Mover's Distance
This paper presents a shared-memory parallel Sinkhorn-Knopp algorithm that accelerates Word Mover's Distance (WMD) computation by transforming dense matrix operations into a sparse kernel fusion, achieving 67× speedup on 96 cores and over 700× speedup over naive Python implementations. The method combines SDDMM_SpMM fusion and optimized Euclidean distance computation for high-performance semantic text similarity on modern CPUs.
The Word Mover's Distance (WMD) is a metric that measures the semantic dissimilarity between two text documents by computing the cost of moving all words of a source/query document to the most similar words of a target document optimally. Computing WMD between two documents is costly because it requires solving an optimization problem that costs \(O(V^3log(V))\) where \(V\) is the number of unique words in the document. Fortunately, the WMD can be framed as the Earth Mover's Distance (EMD) (also known as the Optimal Transportation Distance) for which it has been shown that the algorithmic complexity can be reduced to \(O(V^2)\) by adding an entropy penalty to the optimization problem and a similar idea can be adapted to compute WMD efficiently. Additionally, the computation can be made highly parallel by computing WMD of a single query document against multiple target documents at once (e.g., finding whether a given tweet is similar to any other tweets happened in a day). In this paper, we present a shared-memory parallel Sinkhorn-Knopp Algorithm to compute the WMD of one document against many other documents by adopting the \(O(V^2)\) EMD algorithm. We used algorithmic transformations to change the original dense compute-heavy kernel to a sparse compute kernel and obtained \(67 imes\) speedup using \(96\) cores on the state-of-the-art of Intel extregistered{} 4-sockets Cascade Lake machine w.r.t. its sequential run. Our parallel algorithm is over \(700 imes\) faster than the naive parallel python code that internally uses optimized matrix library calls.
Motivation & Objective
- To address the high computational cost of computing Word Mover's Distance (WMD), which scales as O(V³log V) for V unique words.
- To enable efficient parallel computation of WMD between one query document and multiple target documents simultaneously.
- To reduce the computational burden of dense matrix operations in the Sinkhorn-Knopp algorithm through algorithmic transformation to sparse kernels.
- To achieve high performance and strong scaling on shared-memory, multi-socket x86 systems using OpenMP and C++.
Proposed method
- The paper adopts the entropy-regularized Earth Mover’s Distance (EMD) formulation to reduce WMD computation complexity from O(V³log V) to O(V²).
- It applies the Sinkhorn-Knopp matrix scaling algorithm to solve the regularized EMD problem efficiently, enabling fast and stable convergence.
- A novel sparse kernel fusion, SDDMM_SpMM, is introduced to combine Sparse-Dense-Dense matrix multiplication (SDDMM) and Dense-Sparse matrix multiplication (SpMM) into a single optimized kernel.
- The Euclidean distance computation is restructured as a blocked, GEMM-like matrix multiplication kernel to improve data locality and cache efficiency.
- The implementation uses OpenMP for task-level parallelism across multiple CPU cores and NUMA domains, with memory access patterns tuned for scalability.
- The algorithmic transformation replaces dense computation kernels with sparse ones, reducing memory bandwidth pressure and improving arithmetic intensity.
Experimental results
Research questions
- RQ1Can the dense computation kernel in the Sinkhorn-Knopp algorithm for WMD be effectively transformed into a sparse kernel to improve performance?
- RQ2What level of speedup can be achieved by parallelizing WMD computation across multiple target documents using shared-memory systems?
- RQ3How does the performance of a highly optimized C++/OpenMP implementation compare to a naive parallel Python implementation using optimized math libraries?
- RQ4To what extent does algorithmic optimization of the Euclidean distance kernel impact overall WMD computation performance?
- RQ5How does the algorithm scale across multiple NUMA nodes in a 4-socket x86 server architecture?
Key findings
- The proposed parallel Sinkhorn-WMD algorithm achieves 67× speedup on 96 cores across four NUMA sockets on an Intel Cascade Lake system compared to its sequential counterpart.
- The implementation runs over 700× faster than a naive parallel Python implementation that uses optimized parallel math libraries.
- The SDDMM_SpMM kernel fusion reduces memory bandwidth pressure and improves arithmetic intensity, enabling efficient utilization of modern CPU caches.
- The optimized GEMM-like Euclidean distance kernel improves performance by enhancing data locality, especially for tall and skinny matrices common in WMD workloads.
- The algorithm scales well across NUMA domains, with peak performance observed at v_r = 37 words in the source document on the 4-socket system.
- Cold-start effects were observed in the performance trace, with v_r = 31 showing the worst speedup due to cache misses, indicating the importance of input ordering and data layout.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.