Skip to content
Draft
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b68d63e
Begin refactoring RAFT CMake configuration
wphicks Jul 21, 2023
10093d3
Correct RAFT CMake configuration
wphicks Jul 21, 2023
77a4971
Conditionally link to RAFT
wphicks Jul 26, 2023
a1aa366
Add configuration structs for RAFT indexes
wphicks Jul 26, 2023
bcef4c1
Add IVF index headers
wphicks Jul 31, 2023
2ebcf93
Provide initial update of tiered RAFT index
wphicks Aug 4, 2023
44d6b15
Update style
wphicks Aug 4, 2023
418ecaa
Merge branch 'main' into fea-raft_integration
wphicks Aug 7, 2023
1ed0cc9
Merge branch 'main' into fea-raft_integration
lowener Oct 9, 2023
4d66fe8
Rename ivf, add factory
lowener Oct 10, 2023
dbe8bea
Fix add and searches
lowener Oct 13, 2023
1d62824
Add size computation of tiered index
lowener Oct 18, 2023
32ce6cc
Update tiered index
lowener Oct 19, 2023
f3cd7b1
Add CUDA_ARCHITECTURE for half type
lowener Oct 20, 2023
28765de
Add Tiered index update and test
lowener Nov 2, 2023
54b895c
Separate cuda code and flat/pq
lowener Nov 8, 2023
1f99e55
Rework IVF, add stream manager, interface, benchmark
lowener Nov 14, 2023
6bab5e3
Update Tiered vector ingestion
lowener Nov 20, 2023
d072d3a
Update Tiered index. Add vector deletion code
lowener Nov 21, 2023
cfa190b
Add search bitset filter
lowener Nov 23, 2023
1726318
Add USE_CUDA guardrails for compilation
lowener Nov 24, 2023
8ba3767
Fix style
lowener Nov 24, 2023
2071218
Remaining USE_CUDA guards
lowener Nov 24, 2023
b735b20
Fix thread pool benchmark
lowener Dec 5, 2023
0790982
USE_CUDA fix
lowener Dec 5, 2023
4c90248
Fix compilation
lowener Dec 7, 2023
7805aa1
Add ivfpq bench
lowener Dec 22, 2023
f8c02ef
Add test for Cosine and IP
lowener Jan 8, 2024
45c510c
Update src/VecSim/algorithms/raft_ivf/ivf_tiered.h
lowener Apr 2, 2024
21a7d20
Separate index Size
lowener Jun 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
cmake_minimum_required(VERSION 3.10)
option(USE_CUDA "Build Cuda code" On)
if(USE_CUDA)
cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR)
else()
cmake_minimum_required(VERSION 3.10)
endif()
cmake_policy(SET CMP0077 NEW)

set(CMAKE_CXX_STANDARD 20)
Expand All @@ -24,10 +29,22 @@ include(cmake/san.cmake)
# ----------------------------------------------------------------------------------------------
project(VectorSimilarity)

if (USE_CUDA)
# Enable CUDA compilation for this project
enable_language(CUDA)
# Add definition for conditional compilation of CUDA components
add_definitions(-DUSE_CUDA)
# Perform all RAFT-specific CMake setup
include(cmake/raft.cmake)
# Required flags for compiling RAFT
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-extended-lambda --expt-relaxed-constexpr")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -O3 -std=c++17")
endif()

# Only do these if this is the main project, and not if it is included through add_subdirectory
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions -fPIC ${CLANG_SAN_FLAGS} ${LLVM_CXX_FLAGS} ${COV_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions -fPIC -pthread ${CLANG_SAN_FLAGS} ${LLVM_CXX_FLAGS} ${COV_CXX_FLAGS}")

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?

Copy link
Author

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do, thanks!

set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} ${LLVM_LD_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} ${LLVM_LD_FLAGS}")

Expand Down
4 changes: 2 additions & 2 deletions check-format.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
CLANG_FMT_SRCS=$(find ./src/ \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' -o -name '*.hh' -o -name '*.hpp' \))
CLANG_FMT_TESTS="$(find ./tests/ -type d \( -path ./tests/unit/build \) -prune -false -o \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' -o -name '*.hh' -o -name '*.hpp' \))"
CLANG_FMT_SRCS=$(find ./src/ \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' -o -name '*.hh' -o -name '*.hpp' -o -name '*.cuh' -o -name '*.cu' \))
CLANG_FMT_TESTS="$(find ./tests/ -type d \( -path ./tests/unit/build \) -prune -false -o \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' -o -name '*.hh' -o -name '*.hpp' -o -name '*.cuh' -o -name '*.cu' \))"

E=0
for filename in $CLANG_FMT_SRCS $CLANG_FMT_TESTS; do
Expand Down
85 changes: 85 additions & 0 deletions cmake/raft.cmake
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()
10 changes: 8 additions & 2 deletions src/VecSim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,15 @@ add_library(VectorSimilarity ${VECSIM_LIBTYPE}
${HEADER_LIST}
)

target_link_libraries(VectorSimilarity VectorSimilaritySpaces)

if(VECSIM_BUILD_TESTS)
add_library(VectorSimilaritySerializer utils/serializer.cpp)
target_link_libraries(VectorSimilarity VectorSimilaritySerializer)
endif()

target_link_libraries(VectorSimilarity
PUBLIC
VectorSimilaritySpaces
$<$<BOOL:${VECSIM_BUILD_TESTS}>:VectorSimilaritySerializer>
PRIVATE
$<$<BOOL:${USE_CUDA}>:raft::raft>
)
5 changes: 5 additions & 0 deletions src/VecSim/algorithms/brute_force/brute_force.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ class BruteForceIndex : public VecSimIndexAbstract<DistType> {
public:
BruteForceIndex(const BFParams *params, const AbstractIndexInitParams &abstractInitParams);

void clear() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when do we need to use this?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clear() function is used in the Tiered Raft IVF index: The vectors from the flat buffers are all transferred to the backend index, and then the flat buffer is cleared.

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,
Expand Down
Loading