Abstract
The fastest indexes for Approximate Nearest Neighbor Search today are also the slowest to build: graph-based methods like HNSW and Vamana achieve state-of-the-art query performance but have large construction times due to relying on random-access-heavy beam searches. We introduce PiPNN (Pick-in-Partitions Nearest Neighbors), an ultra-scalable graph construction algorithm that avoids this "search bottleneck" that existing graph-based methods suffer from. PiPNN's core innovation is HashPrune, a novel online pruning algorithm which dynamically maintains sparse collections of edges. HashPrune enables PiPNN to partition the dataset into overlapping sub-problems, efficiently perform bulk distance comparisons via dense matrix multiplication kernels, and stream a subset of the edges into HashPrune. HashPrune guarantees bounded memory during index construction which permits PiPNN to build higher quality indices without the use of extra intermediate memory. PiPNN builds state-of-the-art indexes up to 11.6x faster than Vamana (DiskANN) and up to 12.9x faster than HNSW. PiPNN is significantly more scalable than recent algorithms for fast graph construction. PiPNN builds indexes at least 19.1x faster than MIRAGE and 17.3x than FastKCNA while producing indexes that achieve higher query throughput. PiPNN enables us to build, for the first time, high-quality ANN indexes on billion-scale datasets in under 20 minutes using a single multicore machine.
Introduction
Approximate Nearest Neighbor Search (ANNS) is a critical component in modern AI applications, including Retrieval-Augmented Generation (RAG) and large-scale recommendation systems. While graph-based indexes like HNSW and Vamana provide exceptional query speed and accuracy, they suffer from a significant "search bottleneck" during construction. These methods rely on incremental insertion, requiring a "beam search" through the existing graph for every new point. This process is dominated by random memory accesses and cache misses, leading to construction times that can span days for billion-scale datasets.
PiPNN (Pick-in-Partitions Nearest Neighbors) addresses this by replacing the incremental search approach with a hardware-aligned "partition-and-prune" strategy. By leveraging dense matrix multiplication and a novel deterministic pruning algorithm, PiPNN can index a billion vectors in under 20 minutes on a single multicore machine.
Methodology
PiPNN's architecture is designed to align with the strengths of modern hardware, shifting the workload from memory-latency-bound random accesses to compute-bound vectorized operations.
Partitioning and Bulk Computation
The algorithm begins with Randomized Ball Carving (RBC) combined with Multi-Level Fanout. This partitions the dataset into small, overlapping clusters (leaves). Within these clusters (typically 1000-2000 points), PiPNN computes all-pairs distances using highly optimized General Matrix Multiplication (GEMM) kernels. This allows the system to process data in dense blocks, maximizing CPU throughput.
HashPrune: Online Directional Pruning
The core innovation of PiPNN is HashPrune, an online, history-independent pruning algorithm. HashPrune uses Locality Sensitive Hashing (LSH) to ensure that each point maintains a diverse set of neighbors in different directions, which is essential for graph navigability.
Because HashPrune is history-independent, the final graph structure is deterministic regardless of the order in which edges are processed. This property enables massive parallelization and allows the system to stream edges into a bounded-memory reservoir without sacrificing index quality.
Experimental Results
PiPNN was evaluated against industry-standard benchmarks, including billion-scale datasets like BigANN-1B and DEEP-1B, as well as high-dimensional sets like OpenAI-ArXiv (1536 dimensions).
Construction Speed
PiPNN demonstrates dramatic improvements in build efficiency. It constructs indexes up to 11.6x faster than Vamana and 12.9x faster than HNSW. On a single machine, PiPNN successfully indexed one billion vectors in under 20 minutes, outperforming recent fast-construction algorithms like MIRAGE and FastKCNA by over 17x.
Index Quality
Despite the accelerated build times, the resulting indexes maintain high quality. PiPNN matches or exceeds the query performance (measured in queries per second vs. recall) of Vamana and HNSW across nearly all tested benchmarks. Furthermore, when used for $k$-NN graph construction in clustering tasks, PiPNN provided a 1.9x end-to-end speedup over HNSW-based pipelines.
Conclusion and Future Work
PiPNN proves that searching a graph is not a prerequisite for building a high-quality one. By aligning algorithmic design with hardware capabilities—specifically through GEMM-based leaf building and deterministic pruning—PiPNN enables billion-scale indexing at unprecedented speeds. Future research will explore further acceleration via GPUs and TPUs, as well as the integration of scalar and product quantization to further reduce memory footprints.
Summary updated