-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate IVF-Flat from RAFT (#2521)
Summary: This is a design proposal that demonstrates an approach to enabling optional support for [RAFT](https://github.com/rapidsai/raft) versions of IVF PQ and IVF Flat (and brute force w/ fused k-selection when k <= 64). There are still a few open issues and design discussions needed for the new RAFT index types to support the full range of features of that FAISS' current gpu index types. Checklist for the integration todos: - [x] Rebase on current `main` branch - [X] The raft handle has been plugged directly into the StandardGpuResources - [X] `FlatIndex` passing Googletests - [x] Use `CodePacker` to support `copyFrom()` and `copyTo()` - [X] `IVF-flat passing Googletests - [ ] Raise appropriate exceptions for operations which are not yet supported by RAFT Additional features we've discussed: - [x] Separate IVF lists into individual memory chunks - [ ] Saving/loading To build FAISS w/ optional RAFT support: ``` mkdir build cd build cmake ../ -DFAISS_ENABLE_RAFT=ON -DFAISS_ENABLE_GPU=ON make -j ``` For development/testing, we've also supplied a bash script to make things easier: `build.sh` Below is a benchmark comparing the training of IVF Flat indices for RAFT and FAISS: ![image](https://user-images.githubusercontent.com/1242464/194944737-8b808f11-e28e-4556-82d1-1ea4b0707283.png) The benchmark was produced using Googlebench in [this](https://github.com/tfeher/raft/tree/raft_faiss_bench) RAFT fork. We're going to provide benchmarks for the queries as well. There are still a couple bottlenecks to be removed in the IVF-Flat training implementation and we'll update the current benchmark when ready. Pull Request resolved: #2521 Test Plan: `buck test mode/debuck test mode/dev-nosan //faiss/gpu/test:test_gpu_index_ivfflat` Reviewed By: algoriddle Differential Revision: D49118319 Pulled By: mdouze fbshipit-source-id: 5916108bc27154acf7c92021ba579a6ca85d730b
- Loading branch information
1 parent
458633c
commit edcf743
Showing
14 changed files
with
1,231 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
|
||
# NOTE: This file is temporary for the proof-of-concept branch and will be removed before this PR is merged | ||
|
||
BUILD_TYPE=Release | ||
BUILD_DIR=build/ | ||
|
||
RAFT_REPO_REL="" | ||
EXTRA_CMAKE_ARGS="" | ||
set -e | ||
|
||
if [[ ${RAFT_REPO_REL} != "" ]]; then | ||
RAFT_REPO_PATH="`readlink -f \"${RAFT_REPO_REL}\"`" | ||
EXTRA_CMAKE_ARGS="${EXTRA_CMAKE_ARGS} -DCPM_raft_SOURCE=${RAFT_REPO_PATH}" | ||
fi | ||
|
||
if [ "$1" == "clean" ]; then | ||
rm -rf build | ||
rm -rf .cache | ||
exit 0 | ||
fi | ||
|
||
if [ "$1" == "test" ]; then | ||
make -C build -j test | ||
exit 0 | ||
fi | ||
|
||
if [ "$1" == "test-raft" ]; then | ||
./build/faiss/gpu/test/TestRaftIndexIVFFlat | ||
exit 0 | ||
fi | ||
|
||
mkdir -p $BUILD_DIR | ||
cd $BUILD_DIR | ||
|
||
cmake \ | ||
-DFAISS_ENABLE_GPU=ON \ | ||
-DFAISS_ENABLE_RAFT=ON \ | ||
-DFAISS_ENABLE_PYTHON=OFF \ | ||
-DBUILD_TESTING=ON \ | ||
-DBUILD_SHARED_LIBS=OFF \ | ||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ | ||
-DFAISS_OPT_LEVEL=avx2 \ | ||
-DRAFT_NVTX=OFF \ | ||
-DCMAKE_CUDA_ARCHITECTURES="NATIVE" \ | ||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ | ||
-DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \ | ||
-DCMAKE_C_COMPILER_LAUNCHER=ccache \ | ||
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ | ||
${EXTRA_CMAKE_ARGS} \ | ||
../ | ||
|
||
|
||
# make -C build -j12 faiss | ||
cmake --build . -j12 | ||
# make -C build -j12 swigfaiss | ||
# (cd build/faiss/python && python setup.py install) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.