arXiv:2611.05690cs.DBNov 2026

Manuscript Offprint

arXiv:2611.05690

Turbocharging PiPNN for Proximity and kk-NN Graph Building

Tobias Rubel, Richard Wen, Guy Blelloch, Laxman Dhulipala, Lars Gottesbüren, Jakub Łącki, Vahab Mirrokni

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Tobias Rubel

UMD

College Park, USA

trubel@umd.edu

Richard Wen

UMD

College Park, USA

rwen1@umd.edu

Guy Blelloch

CMU and Google Research

Pittsburgh, USA

blelloch@cs.cmu.edu

Laxman Dhulipala

UMD and Google Research

College Park, USA

laxman@umd.edu

Lars Gottesbüren

Google Research

Zürich, Switzerland

gottesbueren@google.com

Jakub Łącki

Google Research

New York City, USA

jlacki@google.com

Vahab Mirrokni

Google Research

New York City, USA

mirrokni@google.com

Abstract

Graph-based Approximate Nearest Neighbor Search (ANNS) indexes such as HNSW and Vamana deliver state-of-the-art query performance at the cost of large indexing times. The recently introduced PiPNN method drastically accelerated index construction by way of a partitioning-based algorithm which leverages efficient dense matrix multiplication and top-k aggregation kernels.

In this paper, we unlock the full potential of PiPNN's hardware-friendly algorithm design. We introduce PiPNN II, which optimizes multiple steps of the PiPNN recipe, giving up to 8×8\times speedups for graph-based ANNS index construction. In addition, we present GPIPNN, a GPU implementation of PiPNN, which builds comparable ANNS indices up to 43.7×43.7\times faster than Jasper and up to 50×50\times faster than CAGRA. We also extend PiPNN II and GPIPNN to compute high-quality k-nearest-neighbor (k-NN) graphs directly, which unlocks massive speedups over methods used in many existing systems for clustering, anomaly detection, and more. For 10-NN graph building at 90% recall, we obtain up to a 13×13\times speedup on CPUs and 6.6×6.6\times on GPUs as compared to the prior best methods. PiPNN II can build a billion-scale 10-NN graph in under 16 minutes.

Common to both PiPNN II and GPIPNN is the use of quantization to reduce memory traffic and leverage fast low-precision matrix operations. Top-K emerges as a new bottleneck, which we optimize by specializing the code to the specific K, as well as fusing with the matrix kernel to avoid materializing the distance matrix to memory. For CPUs, we demonstrate further performance improvements by leveraging our matrix kernels in the RobustPrune procedure originally proposed in Vamana and used in PiPNN. On GPUs, we flatten recursive partitioning into segmented batches, use one fused top-K abstraction for partitioning and leaf scoring, and prune with already-witnessed direct edges rather than a new candidate-to-candidate scoring pass.

1 Introduction

Vector embeddings power modern search, recommendation, entity resolution, and retrieval-augmented generation systems [22, 36, 37, 45, 55, 65, 69]. These systems rely on approximate nearest-neighbor search (ANNS) because exact search is prohibitively expensive and small errors are tolerable. Graph-based indexes such as HNSW, Vamana (DiskANN), and NSG have become the standard for high-recall, low-latency ANNS [17, 30, 40]. Unfortunately, their excellent query performance has come at the cost of slow index construction: building a high-quality search graph (also termed “proximity

Figure

Figure 1: Index-build speedup of PiPNN II and GPIPNN over well-optimized baselines. Left: CPU speedup of PiPNN II over unquantized Vamana. Right: GPU speedup of GPIPNN over CAGRA.

graph") over a large dataset has historically required many hours or even days of compute on powerful multi-core machines [41].

Fast index construction is not merely a convenience: build time is often a major factor in the total cost of the system. Indexes must be rebuilt as data drifts, parameters need to be tuned across datasets, and ANNS appears as an inner loop in fundamental tasks including accelerated k-means [60], hierarchical clustering [12, 67], minimum spanning trees, and single-linkage clustering [1, 3, 5, 7]. Small modifications to graph-index construction also yield high-quality k-NN graphs [8], a primitive that we directly target in this paper. An indexing method that takes hours or days is simply unusable in many modern workflows.

The recently introduced Pick-in-Partitions Nearest Neighbors (PiPNN) method significantly speeds up high-quality index construction by replacing build-time graph search with regular partition-local scoring work [56]. It recursively partitions the input vectors into small overlapping collections (termed "leaves"), generates candidate edges through batched all-pairs distance comparisons and top-K aggregation inside each leaf, and streams those candidates through an online history-independent pruning procedure (HASHPRUNE) to retain sparsity. The bulk of PiPNN's construction is comprised of all-to-all comparisons over small, cache-resident sets of vectors; an operation far more amenable to modern hardware than the irregular pointer-chasing of incremental graph construction [17, 30, 40]. The payoff of this approach is that the existing version of PiPNN is up to 11.6×11.6\times faster than

Tobias Rubel, Richard Wen, Guy Blelloch, Laxman Dhulipala, Lars Gottesbüren, Jakub Lăcki, and Vahab Mirrokni

the ParlayANN implementation of Vamana on CPU and produces indexes with equivalent QPS-recall performance [56].

Despite these significant improvements in build times, the first version of PiPNN fails to leverage modern hardware to its full potential. For instance, it keeps vectors in full-precision float32 form to perform GEMM (General Matrix Multiply) and materializes the full distance matrices to memory to perform per-row top-k reduction. In this paper we significantly optimize the entire approach from first principles. We start by leveraging quantization to replace the full-precision vectors with compact integer codes that are cheaper to compare [14, 27, 32, 35, 41, 61]. Quantizing the vectors not only speeds up memory accesses, but it also enables low-precision multiply-accumulate instructions. Decoding cost may seem concerning at first glance, but is easily amortized over many distance computations. Lastly, we fuse the GEMM kernel with top-k reduction in register, to avoid materializing an M×NM \times N distance matrix to memory. While fused distance computation and in-register k-selection are established in GPU similarity search [14, 32], our contribution is a family of compressed-domain kernels specialized to PiPNN's leader-assignment and leaf-processing shapes and instantiated across CPUs and GPUs.

The aforementioned opportunity and challenge carries over to hardware acceleration using GPUs. Compared to existing GPU ANNS systems [42, 50] which struggle to leverage the full potential of the hardware due to relying on either beam search or iterative refinement on graphs, PiPNN's batched many-to-many structure is an ideal fit for tensor cores. However, implementing PiPNN on GPUs presents non-trivial challenges: PiPNN's recursive partitioning produces irregularly-sized subproblems whose control flow is not handled well by the GPU scheduler and must be flattened into uniform passes; the vectors needed for each local comparison are scattered in device memory and must be gathered into dense batches; and the HASHPRUNE reservoirs for each point must be maintained without the use of locks.

In this paper we realize the full potential of PiPNN by carefully restructuring PiPNN's construction pipeline around fused quantized batched top-K kernels. We instantiate this design on both shared memory CPU systems (PiPNN II 1^{1}) as well as GPUs (GPiPNN), thus cashing in on the promise for hardware-accelerated ANNS builds within the PiPNN framework. Our results show that our GEMM kernels take full advantage of the hardware: the CPU score-and-select kernels run near instruction throughput roofline, whereas the corresponding GPU kernels are memory bound for high-dimensional vectors typical of modern embeddings.

On GPUs, PiPNN flattens the recursion used in PiPNN's partitioning routines by refactoring them as radix sorts over leader-assignment keys. In addition, it processes multiple collections of points in a single kernel using a segmented top-K primitive, which ameliorates workload imbalances. Finally, it avoids a costly final prune, by way of a novel DIRECTEDGEPRUNE over the cached distances in the HASHPRUNE structure.

Our extensive experimental study establishes PiPNN II and GPiPNN as the new state of the art for proximity-graph index construction on CPUs and GPUs, delivering large speedups over the strongest prior methods while preserving high-recall query performance. On CPUs, PiPNN II builds indexes up to 8×8\times faster than PiPNN and substantially outperforms all prior graph-based ANNS builders on the datasets we evaluate. On GPUs, GPiPNN achieves speedups of up to 43.7×43.7\times over Jasper and 50×50\times over CA-GRA across a diverse benchmark of text, image, and text-to-image datasets, while matching or exceeding their query throughput at high recall. On CPU, we show that our new methods enable the construction of billion-point graph indexes on a single machine in under 10 minutes, as opposed to hours for prior best methods.

Beyond proximity-graph construction, we show that the same methods produce high-quality k-NN graphs (a connection between partitioning-based construction and k-NN graphs also briefly noted in prior work [25]), making PiPNN II and GPiPNN state-of-the-art for k-NN graph construction as well. At recall10@10 ≥ 0.9, PiPNN II is up to 13×13\times faster than the best prior CPU k-NN builder (Vamana-Q), and GPiPNN is up to 6.6×6.6\times faster than the best prior GPU k-NN builder (cUVS NN-DESCENT).

In summary, the main contributions of this paper are:

(1) Highly optimized quantized GEMM fused with top-K kernels.

(2) PiPNN II, a shared-memory CPU implementation leveraging quantization and our new fused kernels to achieve state-of-the-art index construction and k-NN graph building performance.

(3) GPiPNN, a GPU implementation of the same method which redesigns the PiPNN framework for excellent performance on modern accelerators.

(4) An extensive experimental evaluation spanning twelve datasets across text, image, and text-to-image modalities at scales up to one billion points (one hundred million on GPU), including direct k-NN graph construction results, that establishes PiPNN II and GPiPNN as state of the art for fast high-quality ANNS index construction on modern CPUs and GPUs.

References (27)