[Paper Review] Parallelizing Word2Vec in Multi-Core and Many-Core Architectures
This paper proposes HogBatch, a highly optimized word2vec implementation that replaces vector-vector operations in Hogwild with matrix-matrix multiply (GEMM) via minibatching and negative sample sharing, enabling near-linear scaling on multi-core and many-core systems. It achieves 5.8M words/sec on Intel Broadwell and 8.9M words/sec on Knights Landing, the fastest performance reported to date.
Word2vec is a widely used algorithm for extracting low-dimensional vector representations of words. State-of-the-art algorithms including those by Mikolov et al. have been parallelized for multi-core CPU architectures, but are based on vector-vector operations with "Hogwild" updates that are memory-bandwidth intensive and do not efficiently use computational resources. In this paper, we propose "HogBatch" by improving reuse of various data structures in the algorithm through the use of minibatching and negative sample sharing, hence allowing us to express the problem using matrix multiply operations. We also explore different techniques to distribute word2vec computation across nodes in a compute cluster, and demonstrate good strong scalability up to 32 nodes. The new algorithm is particularly suitable for modern multi-core/many-core architectures, especially Intel's latest Knights Landing processors, and allows us to scale up the computation near linearly across cores and nodes, and process hundreds of millions of words per second, which is the fastest word2vec implementation to the best of our knowledge.
Motivation & Objective
- To address the poor scalability of Hogwild-based word2vec on modern multi-core and many-core systems due to memory bandwidth bottlenecks and low computational utilization.
- To exploit data locality in word2vec updates by batching multiple context words and shared negative samples to enable level-3 BLAS operations.
- To enable strong scalability across multiple nodes in a cluster using data parallelism with minimal accuracy loss.
- To achieve near-linear performance scaling on Intel’s latest architectures, especially Knights Landing, surpassing existing CPU and GPU-based implementations.
Proposed method
- Introduce minibatching of input context words to group multiple word2vec updates into a single matrix operation.
- Implement negative sample sharing, where the same set of negative samples is reused across a batch of input words to enable GEMM-based computation.
- Transform the original vector-vector dot product operations into a matrix-matrix multiply (GEMM) operation, reducing memory bandwidth pressure and improving compute utilization.
- Use shared memory parallelization across CPU cores with reduced cache line ping-ponging by coalescing updates to the same model entries.
- Extend the optimization to distributed memory systems using data parallelism across nodes, with periodic model synchronization to maintain convergence.
- Optimize for Intel’s Knights Landing architecture by leveraging wide vector units and high on-package memory bandwidth.
Experimental results
Research questions
- RQ1Can GEMM-based batching significantly improve word2vec performance on modern multi-core CPUs by reducing memory bandwidth pressure?
- RQ2Does negative sample sharing enable efficient matrix-matrix multiplication in word2vec without sacrificing model accuracy?
- RQ3Can the proposed HogBatch algorithm achieve near-linear scaling across 36 CPU cores and up to 32 nodes in a cluster?
- RQ4How does the performance of HogBatch compare to state-of-the-art implementations on CPUs and GPUs in terms of throughput and accuracy?
Key findings
- HogBatch achieves 5.8 million words per second on a 36-core Intel Broadwell CPU, a 3.6× speedup over the original Hogwild implementation.
- On Intel’s Knights Landing processor, HogBatch delivers 8.9 million words per second, the highest reported throughput for word2vec on a CPU to date.
- The algorithm scales nearly linearly across all 36 threads of a Broadwell CPU, while the original Hogwild implementation degrades significantly beyond 8 threads.
- In distributed mode, HogBatch scales near-linearly across up to 16 Broadwell nodes or 8 Knights Landing nodes, achieving over 100 million words per second with only a 1% accuracy drop.
- The performance on 4 Knights Landing nodes reaches 29.4 million words per second, outperforming the best GPU-based implementation on 4 Titan-X GPUs (20M words/sec).
- The use of GEMM operations reduces cache line contention and inter-thread communication, enabling better utilization of compute resources and improved scalability.
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.