Zarc: Exact Nearest Neighbors over a Billion Vectors in Seconds
Abstract
Exact k-nearest-neighbor vector search lies on the critical path of machine learning systems, from sparse attention in the latest large language models (LLMs) to long-context memories and training-data deduplication. Exhaustive GPU search scans the whole dataset for every query, while approximate indexes return inexact neighbors. Recent methods skip almost every vector with a cheap half-precision proof that it lies too far away, but only on one GPU that holds the whole dataset. Our insight is to keep only the short rows of these proofs in GPU memory and to fetch the few remaining full vectors from host memory. Our system, Zarc, answers Euclidean, cosine, inner-product, and filtered queries exactly under updates. On four H100 GPUs, it answers 10,000 exact queries over one billion vectors in 1.1 seconds instead of five minutes. On eleven open LLMs, it retrieves the exact top-10 attention keys 2.2x to 13.1x faster than exhaustive search. In sparse attention over one million tokens, it runs 3.1x faster than bf16 selection with FlashInfer, which misses the exact top-64 for most queries.
Figures & tables
| System | Exact | Beyond HBM | Updates | Exact filters |
|---|---|---|---|---|
| cuVS brute force NVIDIA (2026) | partial | ✗ | ✓ | partial |
| cuVS IVF-PQ Jégou et al. (2011) | ✗ | ✓ | partial | ✗ |
| CAGRA Ootomo et al. (2024) | ✗ | ✗ | partial | ✗ |
| DiskANN Subramanya et al. (2019) | ✗ | ✓ | ✗ | ✗ |
| FreshDiskANN Singh et al. (2021) | ✗ | ✓ | ✓ | ✗ |
| ACORN Patel et al. (2024) | ✗ | ✗ | partial | ✗ |
| Library | Drop-in for | Use case |
|---|---|---|
| cuVS, C++ | index modules ( build , search ) | Vector databases |
| cuVS, C | cuvsBruteForce calls | Vector databases |
| cuVS, Python | brute_force module | RAG, training-data deduplication |
| Faiss | IndexFlatL2 , IndexFlatIP | RAG, benchmark ground truth |
| PyTorch | torch.topk over attention scores | Sparse attention, long-context memory |
| FlashInfer | top- page-table and ragged transforms | Sparse attention in LLM serving |
Appendix figures & tables7 assets
Supplementary material from the paper’s appendix.
Appendix
| Model | Layer | Dim | Heads | Chunk | Keys per head |
|---|---|---|---|---|---|
| gpt-oss-120b | 17 of 36 | 64 | 4 | 8,192 | 10.0M |
| Qwen2.5-7B | 14 of 28 | 128 | 4 | 8,192 | 250.0M |
| Qwen2.5-32B | 32 of 64 | 128 | 4 | 8,192 | 40.0M |
| Qwen2.5-72B | 40 of 80 | 128 | 4 | 8,192 | 40.0M |
| Hy3 | 20 of 80 | 128 | 4 | 8,192 | 10.0M |
| Qwen3-235B-A22B | 47 of 94 | 128 | 4 | 8,192 | 10.0M |
| Dataset | Vectors | Dim | Metric | Workload |
|---|---|---|---|---|
| SIFT1M | 1,000,000 | 128 | Local bounds | |
| DINOv2-1.28M | 1,281,167 | 768 | Local bounds | |
| BIGANN | 10M to 1B | 128 | Tiers, filters, updates, tuning | |
| DataComp-12.8M | 12,790,000 | 768 | cosine | 10-NN graph |
| Deep1B | 1,000,000,000 | 96 | Multi-GPU scaling | |
| MS MARCO | 8,841,823 | 768 | cos, IP | Retrieval, inner product |
| Input | Metrics | Exact queries |
|---|---|---|
| Gaussian vectors | L2, IP, cos | 100% |
| Rank-4 data | L2 | 100% |
| 50 copies of every vector | L2, IP | 100% |
| Coordinates in | L2, IP | 100% |
| Pairs one float32 ulp apart | L2 | 100% |
| Gaussian scaled by | L2, cos | 100% |