VSAG: An Optimized Search Framework for Graph-based Approximate Nearest Neighbor Search

Xiaoyao Zhong, Haotian Li, Jiabao Jin, Mingyu Yang, Deming Chu, Xiangyu Wang, Zhitao Shen, Wei Jia, George Gu, Yi Xie, Xuemin Lin, Heng Tao Shen, Jingkuan Song, Peng Cheng

TL;DR

This paper introduces VSAG, an open-source framework designed to significantly boost the performance of graph-based Approximate Nearest Neighbor Search (ANNS) in production environments. By introducing novel optimizations for memory access, automated parameter tuning, and efficient distance computation, VSAG achieves up to 4x speedup over existing state-of-the-art libraries like HNSWlib while maintaining the same accuracy.

What Problem Does This Paper Address?

Approximate Nearest Neighbor Search (ANNS) is a cornerstone of modern AI and data infrastructure, enabling efficient retrieval of similar items in large, high-dimensional vector spaces. Graph-based ANNS algorithms, like HNSW, have shown great promise, balancing accuracy and efficiency. However, deploying these algorithms at scale in production faces several critical challenges:

  • Random Memory Access: Graph traversal involves jumping between nodes, leading to frequent cache misses and high memory access latency, which can dominate search time.
  • High Computational Overhead: Calculating distances between high-dimensional vectors is computationally intensive, especially when performed millions of times during a search.
  • Parameter Sensitivity: The performance of graph-based ANNS algorithms is highly sensitive to numerous parameters. Manually tuning these parameters is a time-consuming and costly process, often requiring index rebuilds that can take days.

These issues hinder the practical deployment and scalability of ANNS in real-world applications, such as those found in large tech companies.

Methods

VSAG tackles these challenges with a three-pronged optimization strategy:

  1. Efficient Memory Access:
    • Software-based Prefetching: VSAG strategically inserts prefetch instructions to load data into caches before it's needed, reducing stalls caused by cache misses.
  2. Deterministic Access Greedy Search: This technique ensures that prefetching is only performed for data that will actually be accessed, avoiding redundant operations and optimizing prefetch validity.
  3. Partial Redundant Storage (PRS): VSAG introduces a flexible storage design that co-locates neighbor lists with their vectors. This improves data locality, enabling hardware prefetching to work more effectively. A "redundancy ratio" parameter allows dynamic balancing between computational efficiency and memory utilization based on workload.
  4. Automated Parameter Tuning: VSAG employs a tripartite classification system for parameters:
  5. Environment-Level Parameters (ELPs): These affect QPS without impacting recall (e.g., prefetch stride). VSAG uses grid search for efficient tuning.
  6. Query-Level Parameters (QLPs): These impact both QPS and recall. VSAG uses a decision model and a GBDT classifier for adaptive, query-specific tuning.
  7. Index-Level Parameters (ILPs): These have the most significant impact and require index rebuilds for tuning. VSAG uses a novel "labeling-based" approach where edges are constructed with relaxed ILPs and then dynamically filtered using labels during search. This allows for adaptive ILP selection without rebuilding the entire index, drastically reducing tuning time.
  8. Efficient Distance Computation:
    • Low-Precision Traversal: VSAG uses low-precision vector representations for most of the graph traversal, significantly reducing computation costs.
  9. Selective Re-rank: To maintain accuracy, a small subset of promising candidates identified during low-precision traversal are re-ranked using high-precision distances. This approach balances accuracy and efficiency.
  10. Distance Decomposition: Euclidean distance is reformulated to primarily involve an inner product computation, which can be optimized.

Datasets

The paper evaluates VSAG on several standard ANNS datasets:

  • GIST1M: 1 million 960-dimensional image vectors.
  • SIFT1M: 1 million 128-dimensional image vectors.
  • TINY: 5 million 384-dimensional image vectors.
  • GLOVE-100: 1.18 million 100-dimensional text vectors.
  • WORD2VEC: 1 million 300-dimensional text vectors.
  • OPENAI: 1 million 1536-dimensional text vectors.
  • ANT-INTERNET: ~10 million 768-dimensional text vectors (internal Ant Group dataset).
  • MSMARCO: ~100 million 1024-dimensional text vectors (large-scale dataset).

The paper notes that these datasets are widely adopted in existing works and benchmarks.

Key Insights and Ideas

  • The "Curse of Dimensionality" is not just about distance, but also memory access: The paper highlights that random memory access patterns in graph traversals are a major bottleneck, often more so than the distance computation itself, especially in high-dimensional spaces.
  • Adaptive parameter tuning is crucial for production: Manually tuning ANNS parameters is impractical for large-scale systems. VSAG's multi-level auto-tuner, especially its labeling-based ILP tuning, is a significant advancement for making ANNS systems adaptable and efficient out-of-the-box.
  • Balancing computation and memory is key: The PRS design with its tunable redundancy ratio demonstrates a sophisticated approach to dynamically adapt to different hardware constraints and workload demands, optimizing resource utilization.
  • Low-precision for traversal, high-precision for validation: The selective re-ranking strategy effectively leverages the speed of low-precision computations while ensuring high accuracy by reserving expensive high-precision calculations for a carefully chosen subset of candidates.

Key Results

  • Up to 4x Speedup: VSAG achieves up to 4x speedup over HNSWlib on real-world datasets while maintaining the same accuracy.
  • Significant QPS Improvement: On GIST1M, VSAG provides ~400% higher QPS than hnswlib at Recall@10=80% on OPENAI.
  • Reduced Cache Misses: VSAG dramatically reduces L3 cache miss rates, for example, from 93.89% to 39.23% on GIST1M.
  • Efficient Parameter Tuning: VSAG's automated parameter tuning is significantly faster than brute-force methods, with ILP tuning taking only 2-3 times the index construction time, compared to over 60 hours for brute-force.
  • Scalability: VSAG demonstrates strong performance on large-scale datasets (up to 100 million vectors), outperforming hnswlib by 2.59x on MSMARCO at Recall@10=99%.

Limitations and Future Work

  • Limitations: The paper acknowledges that while VSAG can be applied to most graph-based ANNS algorithms, it is not directly applicable to space partitioning-based methods. The PRS strategy's effectiveness can vary depending on whether the workload is CPU-bound or memory-bound.
  • Future Work: The paper suggests that further research could explore more advanced quantization techniques and adaptive strategies for selective re-ranking. The framework's ability to adapt to different hardware and workloads also opens avenues for more sophisticated resource management. The authors also provide a technical report [60] for further details on algorithms and proofs.

Summary updated

BibTeX
@article{zhong2025vsag,
  author = {Xiaoyao Zhong and Haotian Li and Jiabao Jin and Mingyu Yang and Deming Chu and Xiangyu Wang and Zhitao Shen and Wei Jia and George Gu and Yi Xie and Xuemin Lin and Heng Tao Shen and Jingkuan Song and Peng Cheng},
  title = {{VSAG: An Optimized Search Framework for Graph-based Approximate Nearest Neighbor Search}},
  journal = {Proc. VLDB Endow.},
  year = {2025},
  doi = {10.14778/3750601.3750624},
}
Figure