Skip to content

A distributed approximate nearest neighborhood search (ANN) library which provides a high quality vector index build, search and distributed online serving toolkits for large scale vector search scenario.

master
Go to file
Code

Latest commit

* separate BuildCEF and AddCEF

* no change

* add gpu support for building approximate KNN graph

* remove GPUIndexBuilder from solution builder

* Merge master changes (#122)

* try to add an end-to-end tutorial for building vector search online s… (#116)

* try to add an end-to-end tutorial for building vector search online service.

* update the tutorial and getting start page

* fix space and new line issues

* fix gcc5 compiling issue (#120)

* fix gcc5 compiling issue

* fix gcc5 compiling issue

* fix maxcheck and maxcheckforrefine

* add linux gpu build support

* fix compiling issue

* try to fix hash table is full issue

* remove empty space

* remove empty spaces and replace tab with space

* try to make refine not to visit duplicated nodes

* fix debug mode test acc issue

* try to fix checkduplicated issue

* move nobetterpropagation out

* check refine iter larger than 0

* update debug flag in CMakeLists.txt

* change to finegrain lock

* change mergeIndex interface

* fix the interface in the wrappers

* update IndexSearcher to support two different format of input and gpu openmp support

* remove tab space

* try to add opt

* try to avoid openmp reduction error

* fix distanceutils

* fix avx compiling

* try to check maxcheck before travel node in graph

* remove omp merge

* fix dataset add batch

* fix truth load

* try to fix MergeIndex issue

* Merge from separate_params

* to avoid overflow in distance calculation

* Integrate updated GPU graph construction  (#130)

* Integrated latest GPU graph construction code into gpuindexbuilder.  Includes:

- Fix of cosine distance for float, int8, and int 16 datatypes

- Many KNN optimizations that improve performance

- New GPU-RNG construction that create a more accurate graph on the GPU without additional refinement

- GPU-RNG includes a new "accessibility check" that slows it down, but significantly improves recall without needing additional refinement.

- Cleaned up some of the code and removed some unnecessary and depricated code

* Small fix to reduce executable size and slightly improve cosine perf

* Cleanup and small fixes

* try to add initial points from Tree to enable rng refine

* try to provide a separate interface for tree search and remove the tab spaces.

* GPU Graph refinement working and achieves desired accuracy (#137)

* Additional documentation for setting up SPTAG on Windows (#114)

* updating documentation for windows

* Add screenshots and further edits for windows installation docs

* Cleanup Windows Installation Documentation

Co-authored-by: Jean-Sébastien Dupuy <jdupuy@microsoft.com>
Co-authored-by: Parag Paithankar <parag.paithankar@gmail.com>
Co-authored-by: MaggieQi <chenqi871025@gmail.com>

* Added Linux Installation Documentation (#115)

Cleanup Linux Installation Docs

Co-authored-by: Lukasz Grzegorczyk <43997649+luckylukash@users.noreply.github.com>
Co-authored-by: MaggieQi <chenqi871025@gmail.com>

* Add end-to-end walkthrough on usage of SPTAG (#113)

* base image feature extr code

* Add end-to-end walkthrough on usage of SPTAG

Co-authored-by: Karol Żak <karol.zak@hotmail.com>
Co-authored-by: Lukasz Grzegorczyk <43997649+luckylukash@users.noreply.github.com>
Co-authored-by: MaggieQi <chenqi871025@gmail.com>

* Small changes before new code...

* Fix cmake to work on dtcluster

* Debugging and testing

* Fixed several bugs, added unit test for internal testing, just need to fix parallel RNG pruning.

* Initial GPU refinement code

* Fixed bug with refinement

* Fixed bug with RNG shrinking function

* Stable GPU refinement debugged.

* Cleaned up code a bit

* Removed specific paths for local build

Co-authored-by: Alyssa Ong <aong844@aucklanduni.ac.nz>
Co-authored-by: Jean-Sébastien Dupuy <jdupuy@microsoft.com>
Co-authored-by: Parag Paithankar <parag.paithankar@gmail.com>
Co-authored-by: MaggieQi <chenqi871025@gmail.com>
Co-authored-by: Lukasz Grzegorczyk <43997649+luckylukash@users.noreply.github.com>
Co-authored-by: Karol Żak <karol.zak@hotmail.com>
Co-authored-by: Ben Karsin <bkarsin@dtlogin.cm.cluster>
Co-authored-by: Ben Karsin <bkarsin@dt03.eth.cluster>

* Direct RNG construction and batched GPU execution (#140)

* Additional documentation for setting up SPTAG on Windows (#114)

* updating documentation for windows

* Add screenshots and further edits for windows installation docs

* Cleanup Windows Installation Documentation

Co-authored-by: Jean-Sébastien Dupuy <jdupuy@microsoft.com>
Co-authored-by: Parag Paithankar <parag.paithankar@gmail.com>
Co-authored-by: MaggieQi <chenqi871025@gmail.com>

* Added Linux Installation Documentation (#115)

Cleanup Linux Installation Docs

Co-authored-by: Lukasz Grzegorczyk <43997649+luckylukash@users.noreply.github.com>
Co-authored-by: MaggieQi <chenqi871025@gmail.com>

* Add end-to-end walkthrough on usage of SPTAG (#113)

* base image feature extr code

* Add end-to-end walkthrough on usage of SPTAG

Co-authored-by: Karol Żak <karol.zak@hotmail.com>
Co-authored-by: Lukasz Grzegorczyk <43997649+luckylukash@users.noreply.github.com>
Co-authored-by: MaggieQi <chenqi871025@gmail.com>

* Small changes before new code...

* Fix cmake to work on dtcluster

* Debugging and testing

* Fixed several bugs, added unit test for internal testing, just need to fix parallel RNG pruning.

* Initial GPU refinement code

* Fixed bug with refinement

* Fixed bug with RNG shrinking function

* Stable GPU refinement debugged.

* Cleaned up code a bit

* Removed specific paths for local build

* Initial implementation of "strict" initial RNG construction

* Fixed strict RNG construction and added separate options for loose and strict construction

* Initial code of new strict RNG construction that reaches refinement accuracy target.

* Fix / improve int8 cosine using dp4a intrinsic

* Debugging batched execution of RNG graph build

* before merge

* More work debugging TPT issues for large datasets

* Polishing, fixing default values, and removing some scaffolding

Co-authored-by: Alyssa Ong <aong844@aucklanduni.ac.nz>
Co-authored-by: Jean-Sébastien Dupuy <jdupuy@microsoft.com>
Co-authored-by: Parag Paithankar <parag.paithankar@gmail.com>
Co-authored-by: MaggieQi <chenqi871025@gmail.com>
Co-authored-by: Lukasz Grzegorczyk <43997649+luckylukash@users.noreply.github.com>
Co-authored-by: Karol Żak <karol.zak@hotmail.com>
Co-authored-by: Ben Karsin <bkarsin@dtlogin.cm.cluster>
Co-authored-by: Ben Karsin <bkarsin@dt03.eth.cluster>
Co-authored-by: Ben Karsin <bkarsin@prm-dgx-17.nvidia.com>
Co-authored-by: Ben Karsin <bkarsin@prm-dgx-01.nvidia.com>
Co-authored-by: Ben Karsin <bkarsin@prom.nvidia.com>
Co-authored-by: Ben Karsin <bkarsin@prm-dgx-23.nvidia.com>
Co-authored-by: Ben Karsin <bkarsin@prm-dgx-05.nvidia.com>
Co-authored-by: Ben Karsin <bkarsin@prm-dgx-04.nvidia.com>

* clean code

* remove options.h in indexbuilder

* fix buildtree

* GPU error handling and more debug information (#151)

* Small changes before new code...

* Fix cmake to work on dtcluster

* Debugging and testing

* Fixed several bugs, added unit test for internal testing, just need to fix parallel RNG pruning.

* Initial GPU refinement code

* Fixed bug with refinement

* Fixed bug with RNG shrinking function

* Stable GPU refinement debugged.

* Cleaned up code a bit

* Removed specific paths for local build

* Initial implementation of "strict" initial RNG construction

* Fixed strict RNG construction and added separate options for loose and strict construction

* Initial code of new strict RNG construction that reaches refinement accuracy target.

* Fix / improve int8 cosine using dp4a intrinsic

* Debugging batched execution of RNG graph build

* before merge

* More work debugging TPT issues for large datasets

* Polishing, fixing default values, and removing some scaffolding

* before merge

* Added more useful error handling and debug info

Co-authored-by: Ben Karsin <bkarsin@dtlogin.cm.cluster>
Co-authored-by: Ben Karsin <bkarsin@dt03.eth.cluster>
Co-authored-by: Ben Karsin <bkarsin@prm-dgx-17.nvidia.com>
Co-authored-by: Ben Karsin <bkarsin@prm-dgx-01.nvidia.com>
Co-authored-by: Ben Karsin <bkarsin@prom.nvidia.com>
Co-authored-by: Ben Karsin <bkarsin@prm-dgx-23.nvidia.com>
Co-authored-by: Ben Karsin <bkarsin@prm-dgx-05.nvidia.com>
Co-authored-by: Ben Karsin <bkarsin@prm-dgx-04.nvidia.com>
Co-authored-by: Ben Karsin <bkarsin@prm-dgx-12.nvidia.com>
Co-authored-by: Ben Karsin <bkarsin@prm-dgx-15.nvidia.com>

* fix for boost1.72

* fix GPUIndexBuilder

* fix debug mode vsbuild and wrapper vsbuild

* fix cub path

* clear code

* fix workspace size

* Added non-intrinsic version of cosine distance so it can be compiled/run on hardware with compute capability < 61 (#153)

Co-authored-by: Ben Karsin <bkarsin@dtlogin.cm.cluster>

* fix CMakeLists

* fix workspace and cpu indexbuild threads

* Add support for signed int8 datatype for gpuindexbuilder (#157)

* Added non-intrinsic version of cosine distance so it can be compiled/run on hardware with compute capability < 61

* Add signed int8 support

Co-authored-by: Ben Karsin <bkarsin@dtlogin.cm.cluster>
Co-authored-by: Ben Karsin <bkarsin@prom.nvidia.com>

* add HashTableExponent

* fix GPUIndexBuilder

* remove some logs

* remove repeat config

* fix azure pipeline

* fix cmakelist in gpu

* fix gpu cmakelist

Co-authored-by: Qi Chen <cheqi@microsoft.com>
Co-authored-by: cheqi <cheqi@SRGSSD-08>
Co-authored-by: cheqi <cheqi@DESKTOP-D7RUSOI>
Co-authored-by: Ben Karsin <bkarsin@nvidia.com>
Co-authored-by: Alyssa Ong <aong844@aucklanduni.ac.nz>
Co-authored-by: Jean-Sébastien Dupuy <jdupuy@microsoft.com>
Co-authored-by: Parag Paithankar <parag.paithankar@gmail.com>
Co-authored-by: Lukasz Grzegorczyk <43997649+luckylukash@users.noreply.github.com>
Co-authored-by: Karol Żak <karol.zak@hotmail.com>
Co-authored-by: Ben Karsin <bkarsin@dtlogin.cm.cluster>
Co-authored-by: Ben Karsin <bkarsin@dt03.eth.cluster>
Co-authored-by: Ben Karsin <bkarsin@prm-dgx-17.nvidia.com>
Co-authored-by: Ben Karsin <bkarsin@prm-dgx-01.nvidia.com>
Co-authored-by: Ben Karsin <bkarsin@prom.nvidia.com>
Co-authored-by: Ben Karsin <bkarsin@prm-dgx-23.nvidia.com>
Co-authored-by: Ben Karsin <bkarsin@prm-dgx-05.nvidia.com>
Co-authored-by: Ben Karsin <bkarsin@prm-dgx-04.nvidia.com>
Co-authored-by: Ben Karsin <bkarsin@prm-dgx-12.nvidia.com>
Co-authored-by: Ben Karsin <bkarsin@prm-dgx-15.nvidia.com>
bc02f16

Git stats

Files

Permalink
Failed to load latest commit information.

README.md

SPTAG: A library for fast approximate nearest neighbor search

MIT licensed Build status

SPTAG

SPTAG (Space Partition Tree And Graph) is a library for large scale vector approximate nearest neighbor search scenario released by Microsoft Research (MSR) and Microsoft Bing.

architecture

Introduction

This library assumes that the samples are represented as vectors and that the vectors can be compared by L2 distances or cosine distances. Vectors returned for a query vector are the vectors that have smallest L2 distance or cosine distances with the query vector.

SPTAG provides two methods: kd-tree and relative neighborhood graph (SPTAG-KDT) and balanced k-means tree and relative neighborhood graph (SPTAG-BKT). SPTAG-KDT is advantageous in index building cost, and SPTAG-BKT is advantageous in search accuracy in very high-dimensional data.

How it works

SPTAG is inspired by the NGS approach [WangL12]. It contains two basic modules: index builder and searcher. The RNG is built on the k-nearest neighborhood graph [WangWZTG12, WangWJLZZH14] for boosting the connectivity. Balanced k-means trees are used to replace kd-trees to avoid the inaccurate distance bound estimation in kd-trees for very high-dimensional vectors. The search begins with the search in the space partition trees for finding several seeds to start the search in the RNG. The searches in the trees and the graph are iteratively conducted.

Highlights

  • Fresh update: Support online vector deletion and insertion
  • Distributed serving: Search over multiple machines

Build

Requirements

  • swig >= 3.0
  • cmake >= 3.12.0
  • boost >= 1.67.0

Install

For Linux:

mkdir build
cd build && cmake .. && make

It will generate a Release folder in the code directory which contains all the build targets.

For Windows:

mkdir build
cd build && cmake -A x64 ..

It will generate a SPTAGLib.sln in the build directory. Compiling the ALL_BUILD project in the Visual Studio (at least 2019) will generate a Release directory which contains all the build targets.

For detailed instructions on installing Windows binaries, please see here

Using Docker:

docker build -t sptag .

Will build a docker container with binaries in /app/Release/.

Verify

Run the test (or Test.exe) in the Release folder to verify all the tests have passed.

Usage

The detailed usage can be found in Get started. There is also an end-to-end tutorial for building vector search online service using Python Wrapper in Python Tutorial. The detailed parameters tunning can be found in Parameters.

References

Please cite SPTAG in your publications if it helps your research:

@manual{ChenW18,
  author    = {Qi Chen and
               Haidong Wang and
               Mingqin Li and 
               Gang Ren and
               Scarlett Li and
               Jeffery Zhu and
               Jason Li and
               Chuanjie Liu and
               Lintao Zhang and
               Jingdong Wang},
  title     = {SPTAG: A library for fast approximate nearest neighbor search},
  url       = {https://github.com/Microsoft/SPTAG},
  year      = {2018}
}

@inproceedings{WangL12,
  author    = {Jingdong Wang and
               Shipeng Li},
  title     = {Query-driven iterated neighborhood graph search for large scale indexing},
  booktitle = {ACM Multimedia 2012},
  pages     = {179--188},
  year      = {2012}
}

@inproceedings{WangWZTGL12,
  author    = {Jing Wang and
               Jingdong Wang and
               Gang Zeng and
               Zhuowen Tu and
               Rui Gan and
               Shipeng Li},
  title     = {Scalable k-NN graph construction for visual descriptors},
  booktitle = {CVPR 2012},
  pages     = {1106--1113},
  year      = {2012}
}

@article{WangWJLZZH14,
  author    = {Jingdong Wang and
               Naiyan Wang and
               You Jia and
               Jian Li and
               Gang Zeng and
               Hongbin Zha and
               Xian{-}Sheng Hua},
  title     = {Trinary-Projection Trees for Approximate Nearest Neighbor Search},
  journal   = {{IEEE} Trans. Pattern Anal. Mach. Intell.},
  volume    = {36},
  number    = {2},
  pages     = {388--403},
  year      = {2014
}

Contribute

This project welcomes contributions and suggestions from all the users.

We use GitHub issues for tracking suggestions and bugs.

License

The entire codebase is under MIT license

About

A distributed approximate nearest neighborhood search (ANN) library which provides a high quality vector index build, search and distributed online serving toolkits for large scale vector search scenario.

Topics

Resources

License

Releases

No releases published
You can’t perform that action at this time.