# Turbocharging PiPNN for Proximity and $k$-NN Graph Building

Quantized, fused kernels make graph index construction up to 8 times faster

Tobias Rubel, Richard Wen, Guy Blelloch, Laxman Dhulipala, Lars Gottesbüren, Jakub Łącki and 1 more · arXiv · 2026-11-3

- **Problem** Graph indexes like HNSW and Vamana build slowly because each point insertion walks the partial graph, causing random memory reads and cache misses. Index rebuilds therefore take long as data changes.
- **Method** PiPNN II partitions the data and builds edges inside each partition instead of searching. It quantizes vectors to int8 and fuses the distance matrix multiply with top-K selection, so no distance matrix goes to memory.
- **Results** PiPNN II builds CPU graph indexes up to 8× faster than PiPNN on the datasets evaluated. For 10-NN graph building at 90% recall, it reaches up to a 13× speedup on CPUs.

## Why graph index builds are slow

Graph indexes such as HNSW and Vamana deliver strong query performance, but their construction is slow. Both insert points one at a time, and each insertion walks the partial graph to find candidate neighbors. Random memory reads and cache misses during that traversal make it the main cost of building. Build time matters because indexes must be rebuilt as data changes, and ANNS sits inside clustering and k-means loops.

PiPNN avoids that search by partitioning the data and generating edges inside each partition. The original PiPNN is still wasteful, though: it keeps float32 vectors for its GEMM and stores every distance matrix in memory before each top-k reduction. The authors' answer is to quantize the vectors and fuse the distance GEMM with top-k selection.

## Quantized GEMM fused with top-K on CPUs

The CPU kernels avoid a distance matrix by consuming each computed dot product in registers right away. The inputs are TQ coordinates, which the kernel decodes on the fly with an int8 codebook. TQ4 packs codes at 4 bits, and a 16-entry codebook expands them to int8 in register with vpshufb.

The core instruction is vpdpbusd from AVX-512 VNNI, which multiplies unsigned bytes by signed bytes in groups of four. Because the instruction accepts only one unsigned operand, the authors shift database codes by +128 to make them unsigned. They then subtract the resulting bias using the per-query byte sum, which recovers the true signed inner product.

Data layout matters here, since a row-major layout would spread one point across lanes and force a horizontal reduction. Instead, the database is interleaved into panels of 16 points, so one instruction yields 16 partial dot products. Queries are unrolled six at a time, and four panels share one query broadcast, so one broadcast serves four instructions.

The reduction depends on K, and the kernels keep the running state in SIMD registers across the panel loop. For K = 1, the kernel keeps a running per-lane minimum and its index, and it merges across lanes only after the last panel. For K = 3 and K = 10, a displacement sort keeps a per-lane top-K and defers the horizontal merge until all panels are scored.

With K = 10 the tracker state spills to L1, which the authors accept because that round-trip is negligible next to the GEMM work.

For leaves, the score matrix is symmetric, so the kernel scores only its lower triangle and updates two top-2 trackers per score. Masking sets entries to infinity where the pair would be self-distance or already counted, leaving one unordered pair per finite entry. Each insertion uses branchless blends, and this needs six blend instructions, two fewer than a generic top-2 insert.

## Reshaping PiPNN for GPUs

PiPNN's recursion and uneven buckets don't map onto a GPU as they are, so GPiPNN changes the partitioning structure first. Recursion is a poor fit for GPUs, so GPiPNN replaces it with a fixed number of assignment passes. Each pass assigns points to their nearest leaders within a subproblem and then sorts by the induced keys. Within each top-level bucket, bucket-local sub-leaders are sampled, each member is assigned to its f1 nearest sub-leaders, and a second sort exposes the second-level buckets.

Flattening alone doesn't fix skew, because some top-level buckets are large and some leaves are nearly empty. A GPU launch finishes only when its slowest block finishes, so a few oversized buckets would dominate the launch while small leaves leave SMs idle. GPiPNN reshapes the uneven buckets into nearly uniformly sized leaves before processing them in fixed-size score tiles.

It radix-sorts points by bucket id, run-length-encodes to recover bucket sizes, then splits oversized buckets and merges undersized ones to a target of about 1024. Each leaf is scored as one segment, and the leaf kernel runs on batches of these segments to keep the tensor cores occupied.

Each warpgroup issues wgmma on a tile of 64 query rows, 128 database-point columns, and a 32-byte contraction stripe. The accumulator stays in registers, and the score block is never written to global memory. Each lane keeps a private top-K list in registers, with the top-K array at compile-time-constant slots so no spill to local memory occurs.

The four lanes that own a row merge their lists with a two-step shuffle butterfly. A launch passes one slab of database rows and a descriptor per segment, so each leaf accesses its rows by offset without rebuilding a descriptor.

Two pruning changes complete the GPU pipeline. Sort-and-merge accumulation replaces the lock-based HashPrune, since locks on the reservoirs are impractical on GPUs. DirectEdgePrune replaces RobustPrune by reusing distances already witnessed in the HashPrune structure. DirectEdgePrune produces denser graphs than RobustPrune, yet the authors find this does not affect index quality.

## CPU build speedups and query quality

PiPNN II builds indexes up to 8× faster than PiPNN on the CPU datasets the authors evaluate.

On wiki-all, Vamana-FP32 takes 3.3h to build, while PiPNN-FP32 takes 14.9m and PiPNN-RSQ8 takes 3.0m. Vamana-JL+SQ8 takes 24.9m on the same dataset, so the quantized PiPNN build is far shorter. The authors report that PiPNN-FP32, PiPNN-TQ4 and PiPNN-RSQ8 trace nearly identical QPS-recall curves. So the quantized builds keep the full-precision query quality on the datasets shown.

On MS-Arctic, PiPNN II takes 249 s to build its index, compared to 1298 s for PiPNN. Vamana-FP32 takes 14440 s on MS-Arctic, so PiPNN II is far faster than the unquantized baseline. The same table lists PiPNN II at 3.6 s on Wiki-Qwen-500K, compared to 18 s for PiPNN.

## Where the leaf kernel's time goes

The leaf kernel gets faster through a sequence of optimizations, and each one moves the bottleneck to a new stage. The authors split the runtime into prepare, the dot-product GEMM, and top-2 filtering.

TQ Flat swaps the float32 GEMM for an int8 dot product using vpdpbusd, keeping the baseline's rows-as-points data layout. The block-transposed panel layout, labeled TQ Transposed, regresses against TQ Flat before query unrolling. Query Unrolling then lets the transposed layout pull ahead of flat by improving instruction-level parallelism.

The lower-triangle restriction roughly halves the GEMM work, which the authors measure as a 1.96× gain. Once the GEMM gets faster, top-2 filtering becomes the dominant cost. That shift is why the authors added SIMD Scatter, which targets the top-2 filtering bottleneck. The paper's figure shows each step in order, so the reader can trace where the time moves.

## GPU index build and query quality

GPiPNN builds ANNS indexes faster than Jasper and CAGRA on every dataset in the GPU benchmark. On DEEP-10M, the RSQ8 build takes 2.32 s, the FP16 build 2.57 s, Jasper 8.78 s and CAGRA 115 s. On MS-MARCO-10M, GPiPNN-RSQ8 finishes in 3.50 s, compared to 88.3 s for Jasper.

The authors check whether faster builds cost query quality, using the QPS-recall plots in Figure 5 for DEEP-10M and DBpedia-3072. Across the recall range, GPiPNN's QPS is equal or higher than that of Jasper and the CAGRA variants. The authors use Jasper's query code for every index, so query speed doesn't confound the index comparison.

![Table 3: GPU build times (s): ANNS index (left) and fastest 𝑘-NN graph at recall≥ 0.9 (right); build-then-search includes self-search. RSQ8/FP16: quantized/unq…](https://refivu.com/papers/a73f0638-6aa8-483d-952d-15f97cb4c587/figures/figure-c42dbe275bc510748c82dc402a20c978.png?thumb=512)

**Table 3** : GPU build times (s): ANNS index (left) and fastest 𝑘-NN graph at recall≥ 0.9 (right); build-then-search includes self-search. RSQ8/FP16: quantized/unquantized GPiPNN modes; NN-Desc: NN-Descent. Coloring follows Sec. 6.1; full results in Tab. 4 and 5.

[Original paper](https://arxiv.org/abs/2611.05690v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)

The k-NN graph experiments use the same GPU datasets, with build times compared at recall of at least 0.9. For GPiPNN-RSQ8 and NN-Descent the authors report the direct k-NN graph build time. For Jasper, IVF-PQ and CAGRA the reported time is the index build plus the time to query all n points. GPiPNN-RSQ8 is the fastest-building method on all thirteen datasets, including MS-MARCO-10M, where it takes 30.1 s against 39.4 s for NN-Descent.

## Direct k-NN graphs from PiPNN leaf candidates

That approach doubles the work and makes the query pass dominant. PiPNN already accumulates a pool of nearby candidates for each point within its leaves. The authors use those leaf candidates to retain the top-k neighbors directly and skip the search pass entirely. NN-Descent is the most popular prior method for direct k-NN construction, and the authors compare against it.

The leaf candidates come from the same leaf kernel that PiPNN II uses for graph building. Figure 4 plots k-NN graph build time against recall for wiki-all-88M and OpenAI-ArXiv-2M. The plot compares Vamana-JL+SQ8, pyNNDescent and PiPNN across recall levels from 0.80 to 1.00. From a parameter sweep, the authors keep the fastest builds at each recall level, forming a Pareto frontier per method.

All three methods produce k-NN graphs with reasonably high recall.

![Figure 4: 𝑘-NN graph build time vs. recall on two representa- tive datasets, zoomed to recall in \[0.8, 1.0\]. Results on the full set of datasets are shown in F…](https://refivu.com/papers/a73f0638-6aa8-483d-952d-15f97cb4c587/figures/figure-fa6eb4db4f33b6d7d89c7e738c788e38.png?thumb=512)

**Figure 4** :𝑘-NN graph build time vs. recall on two representa- tive datasets, zoomed to recall in \[0.8, 1.0\]. Results on the full set of datasets are shown in Fig. 11 (Sec. C).

[Original paper](https://arxiv.org/abs/2611.05690v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Tobias Rubel, Richard Wen, Guy Blelloch, Laxman Dhulipala, Lars Gottesbüren, Jakub Łącki, Vahab Mirrokni · Turbocharging PiPNN for Proximity and $k$-NN Graph Building · Original paper figure · Extracted the figure area from page 10 of the original PDF.

On the GPU, GPiPNN is up to 6.6× faster than cuVS NN-Descent at recall 10@10 ≥ 0.9. GPiPNN-RSQ8 is the fastest method on all thirteen datasets, building MS-MARCO-10M in 30.1 s against 39.4 s for NN-Descent.

## Limitations and the range the authors tested

The GPU experiments run on a single 80 GB H100, which sets the scale the authors could test. The GPU baselines, Jasper and CAGRA, don't complete at full scale, so several datasets appear as 10M or 1M slices. DEEP and MS-Turing appear at both 10M and 100M slices on the GPU side. Unquantized CAGRA is omitted on the unnormalized MIPS datasets because CAGRA's NN-Descent path is specialized to L2.

CAGRA's ANNS construction works only on Euclidean data, so the authors didn't compare it on MIPS datasets.

The authors describe DirectEdgePrune as a relaxation of RobustPrune that reuses already-witnessed distances. DirectEdgePrune produces denser graphs than RobustPrune, and the authors find this does not affect index quality. The authors used two assign-and-sort rounds, which they found adequate to achieve high recall. They report recursion-depth effects only in a figure, so the depth beyond two rounds stays outside the main text.

## Paper info

- **Authors**: Tobias Rubel, Richard Wen, Guy Blelloch, Laxman Dhulipala, Lars Gottesbüren, Jakub Łącki, Vahab Mirrokni
- **Venue**: arXiv · Preprint
- **First published**: 2026-11-3
- **Added**: 2026-11-6
- **Updated**: 2026-11-3
- **Version**: v1
- **arXiv**: 2611.05690
- **Category**: cs.DB · cs.IR
- **Original paper terms**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **What we show**: Paper info, commentary and permitted figures from the original paper

[Original paper ↗](https://arxiv.org/abs/2611.05690v1) · [PDF ↗](https://arxiv.org/pdf/2611.05690v1)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## 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 leveraging 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\\times$ speedups for graph-based ANNS index construction. In addition, we present GPiPNN, a GPU implementation which builds comparable ANNS indices up to $43.7\\times$ faster than Jasper and up to $50\\times$ faster than CAGRA. We also extend PiPNN II and GPiPNN to compute high-quality $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\\times$ speedup on CPUs and $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 with specialized code for specific $K$, and by fusing with the matrix kernel to avoid materializing the distance matrix to memory. On CPUs, we demonstrate further performance improvements by leveraging our matrix kernels in the RobustPrune procedure 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 new candidate-to-candidate scoring passes.

## Quote from the paper

Tobias Rubel, Richard Wen, Guy Blelloch, Laxman Dhulipala, Lars Gottesbüren, Jakub Łącki, Vahab Mirrokni (2026). Turbocharging PiPNN for Proximity and $k$-NN Graph Building. arXiv:2611.05690v1. https://arxiv.org/abs/2611.05690v1

**BibTeX**

```
@misc{rubel2026turbocharging,
  title = {{Turbocharging PiPNN for Proximity and $k$-NN Graph Building}},
  author = {Tobias Rubel and Richard Wen and Guy Blelloch and Laxman Dhulipala and Lars Gottesbüren and Jakub Łącki and Vahab Mirrokni},
  year = {2026},
  eprint = {2611.05690},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.05690v1}
}
```

## Other paper commentary

- [CounterFactual Retrieval for Evidence-Aware Individual Animal Identification](https://refivu.com/en/papers/3cf8f3a0-3ddd-4d12-8317-757a81b8ce8e-counterfactual-retrieval-for-evidence-aware-individual.md)
- [Unsupervised Dense Information Retrieval with Contrastive Learning](https://refivu.com/en/papers/2fbce187-1a33-4d74-941c-36d004c9a79b-unsupervised-dense-information-retrieval-with-contrastive.md)
- [InstructRetro: Instruction Tuning post Retrieval-Augmented Pretraining](https://refivu.com/en/papers/dd0abb30-a6bc-4a8d-9d46-a2308c9cb88b-instructretro-instruction-tuning-post-retrieval-augmented.md)
- [Dense Passage Retrieval for Open-Domain Question Answering](https://refivu.com/en/papers/c44c51e1-e59a-4cb6-8e94-20a4b572abc0-dense-passage-retrieval-for-open-domain-question-answering.md)
- [Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks](https://refivu.com/en/papers/569bb9ab-8345-4766-a539-e7ffb7b1754e-retrieval-augmented-generation-for-knowledge-intensive-nlp.md)
- [EchoSpec: Training Search Agents to Weigh Evidence Above Echoes](https://refivu.com/en/papers/22f39cf0-d41a-4695-8d6b-0d26df622012-echospec-training-search-agents-to-weigh-evidence-above.md)
- [Give the Drafter a Second Chance to Guess: Parallel Reconsideration for Speculative Decoding](https://refivu.com/en/papers/45cee162-6db4-4196-abcd-f72a1304c123-give-the-drafter-a-second-chance-to-guess.md)
- [Revisiting Critic Estimation in Soft Actor-Critic Algorithms](https://refivu.com/en/papers/3b523ee0-ead6-4c46-a193-319c3c9a36b7-revisiting-critic-estimation-in-soft-actor-critic-algorithms.md)
- [Learning vs. Optimizing Players in Budgeted Games](https://refivu.com/en/papers/1768fa8e-86a3-44ad-befa-e71d7bf1ea63-learning-vs-optimizing-players-in-budgeted-games.md)
- [Discarded or Unreachable? Diagnosing and Repairing Spatial Relation Failure in Vision--Language Similarity](https://refivu.com/en/papers/0fafe702-8cfc-439c-87e0-4bdffb12b1c8-discarded-or-unreachable-diagnosing-and-repairing-spatial.md)
- [AGORA: Reliability-Aware Aggregation of LLM Judges via Item-Response Theory](https://refivu.com/en/papers/0038d415-6622-454c-ae5b-e99ae5a41f64-agora-reliability-aware-aggregation-of-llm-judges-via.md)
- [Iterated creation, grading, and revision of data science projects by language models](https://refivu.com/en/papers/6e806f60-e68c-4a63-b8ee-18fbe24f7095-iterated-creation-grading-and-revision-of-data-science.md)

## Terms in this paper

- [GEMM](https://refivu.com/en/terms/2ab461ff0bcb-gemm)
- [HNSW](https://refivu.com/en/terms/d22a60488835-hnsw)
- [Vamana](https://refivu.com/en/terms/0ee2e85101ce-vamana)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/a73f0638-6aa8-483d-952d-15f97cb4c587-turbocharging-pipnn-for-proximity-and-k-nn-graph)
