-
Notifications
You must be signed in to change notification settings - Fork 22
Provide GPU-accelerated vector indexes with RAFT #413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 8 commits
b68d63e
10093d3
77a4971
a1aa366
bcef4c1
2ebcf93
44d6b15
418ecaa
1ed0cc9
4d66fe8
dbe8bea
1d62824
32ce6cc
f3cd7b1
28765de
54b895c
1f99e55
6bab5e3
d072d3a
cfa190b
1726318
8ba3767
2071218
b735b20
0790982
4c90248
7805aa1
f8c02ef
45c510c
21a7d20
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| if(USE_CUDA) | ||
| # Set which version of RAPIDS to use | ||
| set(RAPIDS_VERSION 23.10) | ||
| # Set which version of RAFT to use (defined separately for testing | ||
| # minimal dependency changes if necessary) | ||
| set(RAFT_VERSION "${RAPIDS_VERSION}") | ||
| # TODO(wphicks): Reset to main fork and branch after | ||
| # https://github.com/rapidsai/raft/pull/1716 has been merged | ||
| # set(RAFT_FORK "rapidsai") | ||
| set(RAFT_FORK "wphicks") | ||
| # set(RAFT_PINNED_TAG "branch-${RAPIDS_VERSION}") | ||
| set(RAFT_PINNED_TAG "fea-resource_manager") | ||
|
|
||
| # Download CMake file for bootstrapping RAPIDS-CMake, a utility that | ||
| # simplifies handling of complex RAPIDS dependencies | ||
| if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/RAPIDS.cmake) | ||
| file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-${RAPIDS_VERSION}/RAPIDS.cmake | ||
| ${CMAKE_CURRENT_BINARY_DIR}/RAPIDS.cmake) | ||
| endif() | ||
| include(${CMAKE_CURRENT_BINARY_DIR}/RAPIDS.cmake) | ||
|
|
||
| # General tool for orchestrating RAPIDS dependencies | ||
| include(rapids-cmake) | ||
| # CPM helper functions with dependency tracking | ||
| include(rapids-cpm) | ||
| rapids_cpm_init() | ||
| # Common CMake CUDA logic | ||
| include(rapids-cuda) | ||
| # Include required dependencies in Project-Config.cmake modules | ||
| # include(rapids-export) TODO(wphicks) | ||
| # Functions to find system dependencies with dependency tracking | ||
| include(rapids-find) | ||
|
|
||
| # Correctly handle supported CUDA architectures | ||
| # (From rapids-cuda) | ||
| rapids_cuda_init_architectures(VectorSimilarity) | ||
|
|
||
| # Find system CUDA toolkit | ||
| rapids_find_package(CUDAToolkit REQUIRED) | ||
|
|
||
| set(RAFT_VERSION "${RAPIDS_VERSION}") | ||
| set(RAFT_FORK "rapidsai") | ||
| set(RAFT_PINNED_TAG "branch-${RAPIDS_VERSION}") | ||
|
|
||
| function(find_and_configure_raft) | ||
| set(oneValueArgs VERSION FORK PINNED_TAG COMPILE_LIBRARY) | ||
| cmake_parse_arguments(PKG "${options}" "${oneValueArgs}" | ||
| "${multiValueArgs}" ${ARGN} ) | ||
|
|
||
| set(RAFT_COMPONENTS "") | ||
| if(PKG_COMPILE_LIBRARY) | ||
| string(APPEND RAFT_COMPONENTS " compiled") | ||
| endif() | ||
| # Invoke CPM find_package() | ||
| # (From rapids-cpm) | ||
| rapids_cpm_find(raft ${PKG_VERSION} | ||
| GLOBAL_TARGETS raft::raft | ||
| BUILD_EXPORT_SET VectorSimilarity-exports | ||
| INSTALL_EXPORT_SET VectorSimilarity-exports | ||
| COMPONENTS ${RAFT_COMPONENTS} | ||
| CPM_ARGS | ||
| GIT_REPOSITORY https://github.com/${PKG_FORK}/raft.git | ||
| GIT_TAG ${PKG_PINNED_TAG} | ||
| SOURCE_SUBDIR cpp | ||
| OPTIONS | ||
| "BUILD_TESTS OFF" | ||
| "BUILD_BENCH OFF" | ||
| "RAFT_COMPILE_LIBRARY ${PKG_COMPILE_LIBRARY}" | ||
| ) | ||
| if(raft_ADDED) | ||
| message(VERBOSE "VectorSimilarity: Using RAFT located in ${raft_SOURCE_DIR}") | ||
| else() | ||
| message(VERBOSE "VectorSimilarity: Using RAFT located in ${raft_DIR}") | ||
| endif() | ||
| endfunction() | ||
|
|
||
| # Change pinned tag here to test a commit in CI | ||
| # To use a different RAFT locally, set the CMake variable | ||
| # CPM_raft_SOURCE=/path/to/local/raft | ||
| find_and_configure_raft(VERSION ${RAFT_VERSION}.00 | ||
| FORK ${RAFT_FORK} | ||
| PINNED_TAG ${RAFT_PINNED_TAG} | ||
| COMPILE_LIBRARY OFF | ||
| ) | ||
| endif() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,11 @@ class BruteForceIndex : public VecSimIndexAbstract<DistType> { | |
| public: | ||
| BruteForceIndex(const BFParams *params, const AbstractIndexInitParams &abstractInitParams); | ||
|
|
||
| void clear() { | ||
|
||
| idToLabelMapping.clear(); | ||
| vectorBlocks.clear(); | ||
| count = idType{}; | ||
| } | ||
| size_t indexSize() const override; | ||
| size_t indexCapacity() const override; | ||
| vecsim_stl::vector<DistType> computeBlockScores(const DataBlock &block, const void *queryBlob, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need pthread here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually meant to ask you about that. I was having trouble compiling without it (even before making any of my other changes), but I'll have to recreate the failing build log. Will either post it here or as a separate issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please do, thanks!