Abstract
Vectors of data are at the heart of machine learning and data mining. Recently, vector quantization methods have shown great promise in reducing both the time and space costs of operating on vectors. We introduce a vector quantization algorithm that can compress vectors over 12x faster than existing techniques while also accelerating approximate vector operations such as distance and dot product computations by up to 10x. Because it can encode over 2GB of vectors per second, it makes vector quantization cheap enough to employ in many more circumstances. For example, using our technique to compute approximate dot products in a nested loop can multiply matrices faster than a state-of-the-art BLAS implementation, even when our algorithm must first compress the matrices. In addition to showing the above speedups, we demonstrate that our approach can accelerate nearest neighbor search and maximum inner product search by over 100x compared to floating point operations and up to 10x compared to other vector quantization methods. Our approximate Euclidean distance and dot product computations are not only faster than those of related algorithms with slower encodings, but also faster than Hamming distance computations, which have direct hardware support on the tested platforms. We also assess the errors of our algorithm's approximate distances and dot products, and find that it is competitive with existing, slower vector quantization algorithms.
Introduction
In large-scale data mining, operating on massive collections of vectors—such as image descriptors or neural embeddings—presents significant challenges in terms of storage and computation. Vector Quantization (VQ) is a standard technique to mitigate these costs by compressing vectors into short codes, enabling fast approximate distance calculations via lookup tables. However, traditional VQ methods face a "write" bottleneck: the computational cost of encoding vectors often outweighs the benefits of faster queries, especially in dynamic or real-time datasets.
The Bolt Algorithm
Bolt addresses the encoding bottleneck through a hardware-aware design that optimizes both the compression and query phases. It introduces two key innovations:
- Reduced Codebook Size ($K=16$): While standard VQ typically uses codebooks of size 256 (fitting in one byte), Bolt utilizes codebooks of size 16. This reduction theoretically offers a 16x speedup in encoding by minimizing the number of distance calculations required to find the nearest centroid.
- Quantized SIMD Lookups: Standard VQ lookups often involve random memory accesses that are difficult to parallelize. Bolt learns an 8-bit quantization for the distance lookup tables themselves. This allows the algorithm to utilize SIMD instructions (e.g.,
vpshufbon x86) to perform 16 or more distance lookups simultaneously within a single CPU cycle, fitting the entire lookup table into registers.
Experimental Results
The authors evaluated Bolt on several benchmarks, including Sift1M, Convnet1M, LabelMe22k, and MNIST.
Encoding and Query Efficiency
Bolt demonstrates a dramatic improvement in encoding speed, processing data at over 2GB/s. This makes it approximately 12x faster than Product Quantization (PQ) and significantly faster than Optimized Product Quantization (OPQ).
In terms of query performance, Bolt computes Euclidean distances up to 10x faster than other Multi-Codebook Quantization (MCQ) methods. Remarkably, it even outperforms Hamming distance computations, despite the latter having direct hardware support on tested platforms.
Accelerated Linear Algebra
A compelling application of Bolt's efficiency is in general-purpose linear algebra. The authors show that a simple nested loop using Bolt for approximate dot products can outperform state-of-the-art BLAS implementations (like Eigen) for matrix multiplication. Crucially, this performance advantage holds even when the time required to compress the matrices is included in the total wall time.
Conclusion
Bolt significantly lowers the barrier to using vector quantization by drastically reducing encoding costs. By leveraging hardware-friendly SIMD operations, it provides an order-of-magnitude speedup in both data compression and approximate distance computation. While there is a slight trade-off in accuracy compared to more computationally intensive methods, Bolt's performance makes it an ideal candidate for high-throughput data mining and real-time approximate computing tasks.
Summary updated