Skip to content
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

ANN_BENCH #130

Merged
merged 79 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 76 commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
4416b0b
enable asynchronous host-refinement for cagra index build
mfoerste4 May 17, 2024
118906c
Copy the benchmark scaffolding from RAFT
achirkin May 17, 2024
7814d35
GGNN/HNSW/FAISS_CPU are compiled
achirkin May 17, 2024
f8d8b68
Fix FAISS_GPU builds
achirkin May 17, 2024
946e106
move alloc out of OMP region
mfoerste4 May 17, 2024
7c6644e
added test for refinement -- disabled until detail::build API is exposed
mfoerste4 May 17, 2024
0619207
Merge remote-tracking branch 'origin/branch-24.06' into fea-ann-bench
tfeher May 21, 2024
9313d1f
cuvs_ivf_flat bench compiles
tfeher May 21, 2024
2e61d61
IVF compiles, linker error
tfeher May 22, 2024
8c6f9fe
Disabled ivf_pq refinement, as a workaround for linking error
tfeher May 22, 2024
2c3f5e4
expose more cagra build parameters
mfoerste4 May 22, 2024
4d5ff0c
clarify code
mfoerste4 May 22, 2024
545032b
fix merge conflict
mfoerste4 May 22, 2024
53caff9
Accept host_mdspan for IVF-PQ build and extend
tfeher May 23, 2024
d2c1dad
slightly reduce expected recall to catch refinement 1 results on all …
mfoerste4 May 24, 2024
9f31182
Fix extend API
tfeher May 24, 2024
292e947
Merge remote-tracking branch 'origin/branch-24.06' into ivf_pq_host_m…
tfeher May 24, 2024
f1297da
init
lowener May 24, 2024
9445708
CAGRA bench compiles
tfeher May 24, 2024
2401fcd
Fix refine_host duplication, add test
lowener May 24, 2024
0d214c0
fix style
tfeher May 24, 2024
5efe1c6
Update cpp/include/cuvs/neighbors/refine.hpp
lowener May 24, 2024
4b9ec70
Add half, update doc
lowener May 24, 2024
4418cf7
Merge branch 'branch-24.06' into ivf_pq_host_mdspan
cjnolet May 24, 2024
09c1d73
Merge branch 'branch-24.06' into 24-06_refine
cjnolet May 24, 2024
5dcaecb
add full doc
lowener May 25, 2024
55924cf
Fix test compilation issue
tfeher May 26, 2024
8c37b94
Revert math dependencies to PRIVATE
tfeher May 27, 2024
8837d2d
Merge remote-tracking branch 'origin/branch-24.06' into fea-ann-bench
tfeher May 27, 2024
c0fbae5
Add ivf_flat<half>
lowener May 27, 2024
a84659a
enable cuvs_ prefix for algos, disable half
tfeher May 27, 2024
c7d1bb6
Merge remote-tracking branch 'tfeher/ivf_pq_host_mdspan' into fea-ann…
tfeher May 27, 2024
669fc0e
Fix deserialization of IVF methods
tfeher May 27, 2024
eac32f0
Merge branch '24-06_refine' into fea-ann-bench
tfeher May 27, 2024
a6dcbd0
re-enable refinement
tfeher May 27, 2024
8e2b62a
Fix refinment data type
tfeher May 28, 2024
bb6dbb2
enable brute force benchmark
tfeher May 28, 2024
d1969ce
cuvs brute needs dataset for search
tfeher May 28, 2024
971623c
Fix set_search_param
tfeher May 28, 2024
aafc748
Fix index arg for cagra::serialize_to_hnswlib
tfeher May 28, 2024
e412122
Merge remote-tracking branch 'origin/branch-24.06' into fea-ann-bench
tfeher May 28, 2024
9823831
cleanup API - use std::variant to switch algo of cagra graph build
mfoerste4 May 29, 2024
f310971
fix c-api nn_descent
mfoerste4 May 29, 2024
c1136c5
move documentation to API header
mfoerste4 May 29, 2024
bb87c97
resolve merge conflicts
mfoerste4 May 29, 2024
8506c6a
correct typo
mfoerste4 May 29, 2024
3a6e776
review suggestions
mfoerste4 May 29, 2024
42aa3eb
check valid nn_descent graph-degree / rename build_paramas to graph_b…
mfoerste4 May 29, 2024
68f490b
updating docs
mfoerste4 May 29, 2024
95f6064
Update CAGRA API (NN descent build by default)
tfeher May 30, 2024
3e22b13
Fix style
tfeher May 30, 2024
fd66402
remove cagra's build_host and build_device functions
tfeher May 30, 2024
b867488
Merge remote-tracking branch 'origin/branch-24.06' into fea-ann-bench
tfeher May 30, 2024
d82e497
Merge remote-tracking branch 'origin/pull-request/131' into fea-ann-b…
tfeher May 30, 2024
4f67adc
Merge remote-tracking branch 'origin/branch-24.06' into fea-ann-bench
tfeher Jun 3, 2024
a96dcb9
Handle detailed CAGRA build params in benchmark wrapper
tfeher Jun 3, 2024
2eaf0c6
Add compatibility helper for aliasing cuvs-raft algorithms to allow u…
achirkin Jun 4, 2024
9e90d8d
Fix style errors
achirkin Jun 4, 2024
48f8353
Re-enable all benchmark components
achirkin Jun 4, 2024
0fbf825
Merge branch 'branch-24.08' into fea-ann-bench
achirkin Jun 4, 2024
6a20121
Apply clang-tidy suggestions
achirkin Jun 5, 2024
1e64d05
Remove the unused dev_list parameter and add a few more clang-tidy fixes
achirkin Jun 5, 2024
baf8863
Merge branch 'branch-24.08' into fea-ann-bench
achirkin Jun 5, 2024
c047931
Merge branch 'branch-24.08' into fea-ann-bench
achirkin Jun 6, 2024
887a656
Fix using missing (de)serialize_file
achirkin Jun 6, 2024
001108d
Merge branch 'branch-24.08' into fea-ann-bench
achirkin Jun 10, 2024
449be8c
Fix: serialize_to_hnswlib_file -> serialize_to_hnswlib
achirkin Jun 10, 2024
a71dcb0
Properly add instances of serialize_to_hnswlib
achirkin Jun 11, 2024
8887225
Add an aggregate target CUVS_ANN_BENCH_ALL to build all enabled bench…
achirkin Jun 11, 2024
a32abd5
Include the bench-ann component into the CI alongside with the tests
achirkin Jun 11, 2024
c22035c
Add openblas dependency to test environment
achirkin Jun 11, 2024
512cff6
Merge branch 'branch-24.08' into fea-ann-bench
achirkin Jun 11, 2024
c8ae918
Add openblas requirement to libcuvs-tests recipe (meta.yaml)
achirkin Jun 12, 2024
3fd97f6
Temporarily disable all algos except cuvs
achirkin Jun 12, 2024
3daa597
Re-enable all benchmarks but GGNN.
achirkin Jun 12, 2024
10171cf
Merge branch 'branch-24.08' into fea-ann-bench
achirkin Jun 12, 2024
398a808
Merge branch 'branch-24.08' into fea-ann-bench
achirkin Jun 17, 2024
d7c25bd
Merge branch 'branch-24.08' into fea-ann-bench
achirkin Jun 19, 2024
660c40d
Move openblas conda dependency from build to host
achirkin Jun 19, 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
29 changes: 27 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ ARGS=$*
# scripts, and that this script resides in the repo dir!
REPODIR=$(cd $(dirname $0); pwd)

VALIDARGS="clean libcuvs python rust docs tests examples --uninstall -v -g -n --compile-static-lib --allgpuarch --no-nvtx --show_depr_warn --incl-cache-stats --time -h"
HELP="$0 [<target> ...] [<flag> ...] [--cmake-args=\"<args>\"] [--cache-tool=<tool>] [--limit-tests=<targets>] [--build-metrics=<filename>]
VALIDARGS="clean libcuvs python rust docs tests bench-ann examples --uninstall -v -g -n --compile-static-lib --allgpuarch --no-nvtx --show_depr_warn --incl-cache-stats --time -h"
Copy link
Member

Choose a reason for hiding this comment

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

Can we rename this to benchmarks, maybe? I'm thinking maybe we could start building one benchmarks suite but maybe have different entrypoints for the ANN grid searches vs clustering benchmarking, for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This sounds like the benchmark infrastructure differs significantly between vector search vs clustering.
What about having multiple entry points but renaming them to better reflect what we're benchmarking? e.g. bench-search, bench-clustering.
Update: bench-ann currently handles search and indexing, so probably "bench-search" is not very appropriate. Maybe keep this bench-ann and add the bench-clustering, bench-dists later?

HELP="$0 [<target> ...] [<flag> ...] [--cmake-args=\"<args>\"] [--cache-tool=<tool>] [--limit-tests=<targets>] [--limit-bench-ann=<targets>] [--build-metrics=<filename>]
where <target> is:
clean - remove all existing build artifacts and configuration (start over)
libcuvs - build the cuvs C++ code only. Also builds the C-wrapper library
Expand All @@ -28,6 +28,7 @@ HELP="$0 [<target> ...] [<flag> ...] [--cmake-args=\"<args>\"] [--cache-tool=<to
rust - build the cuvs Rust bindings
docs - build the documentation
tests - build the tests
bench-ann - build end-to-end ann benchmarks
examples - build the examples

and <flag> is:
Expand All @@ -37,6 +38,7 @@ HELP="$0 [<target> ...] [<flag> ...] [--cmake-args=\"<args>\"] [--cache-tool=<to
--uninstall - uninstall files for specified targets which were built and installed prior
--compile-static-lib - compile static library for all components
--limit-tests - semicolon-separated list of test executables to compile (e.g. NEIGHBORS_TEST;CLUSTER_TEST)
--limit-bench-ann - semicolon-separated list of ann benchmark executables to compute (e.g. HNSWLIB_ANN_BENCH;RAFT_IVF_PQ_ANN_BENCH)
--allgpuarch - build for all supported GPU architectures
--no-nvtx - disable nvtx (profiling markers), but allow enabling it in downstream projects
--show_depr_warn - show cmake deprecation warnings
Expand Down Expand Up @@ -70,6 +72,7 @@ BUILD_REPORT_METRICS=""
BUILD_REPORT_INCL_CACHE_STATS=OFF

TEST_TARGETS="NEIGHBORS_ANN_CAGRA_TEST"
ANN_BENCH_TARGETS="CUVS_ANN_BENCH_ALL"

CACHE_ARGS=""
NVTX=ON
Expand Down Expand Up @@ -150,6 +153,21 @@ function limitTests {
fi
}

function limitAnnBench {
# Check for option to limit the set of test binaries to build
if [[ -n $(echo $ARGS | { grep -E "\-\-limit\-bench-ann" || true; } ) ]]; then
# There are possible weird edge cases that may cause this regex filter to output nothing and fail silently
# the true pipe will catch any weird edge cases that may happen and will cause the program to fall back
# on the invalid option error
LIMIT_ANN_BENCH_TARGETS=$(echo $ARGS | sed -e 's/.*--limit-bench-ann=//' -e 's/ .*//')
if [[ -n ${LIMIT_ANN_BENCH_TARGETS} ]]; then
# Remove the full LIMIT_TEST_TARGETS argument from list of args so that it passes validArgs function
ARGS=${ARGS//--limit-bench-ann=$LIMIT_ANN_BENCH_TARGETS/}
ANN_BENCH_TARGETS=${LIMIT_ANN_BENCH_TARGETS}
fi
fi
}

function buildMetrics {
# Check for multiple build-metrics options
if [[ $(echo $ARGS | { grep -Eo "\-\-build\-metrics" || true; } | wc -l ) -gt 1 ]]; then
Expand Down Expand Up @@ -179,6 +197,7 @@ if (( ${NUMARGS} != 0 )); then
cmakeArgs
cacheTool
limitTests
limitAnnBench
buildMetrics
for a in ${ARGS}; do
if ! (echo " ${VALIDARGS} " | grep -q " ${a} "); then
Expand Down Expand Up @@ -255,6 +274,11 @@ if hasArg tests || (( ${NUMARGS} == 0 )); then
fi
fi

if hasArg bench-ann || (( ${NUMARGS} == 0 )); then
BUILD_ANN_BENCH=ON
CMAKE_TARGET="${CMAKE_TARGET};${ANN_BENCH_TARGETS}"
fi

if hasArg --no-nvtx; then
NVTX=OFF
fi
Expand Down Expand Up @@ -327,6 +351,7 @@ if (( ${NUMARGS} == 0 )) || hasArg libcuvs || hasArg docs || hasArg tests || has
-DDISABLE_DEPRECATION_WARNINGS=${DISABLE_DEPRECATION_WARNINGS} \
-DBUILD_TESTS=${BUILD_TESTS} \
-DBUILD_C_TESTS=${BUILD_TESTS} \
-DBUILD_ANN_BENCH=${BUILD_ANN_BENCH} \
-DBUILD_CPU_ONLY=${BUILD_CPU_ONLY} \
-DCMAKE_MESSAGE_LOG_LEVEL=${CMAKE_LOG_LEVEL} \
${CACHE_ARGS} \
Expand Down
1 change: 1 addition & 0 deletions conda/environments/all_cuda-118_arch-aarch64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ dependencies:
- numpy>=1.23,<2.0a0
- numpydoc
- nvcc_linux-aarch64=11.8
- openblas
- pre-commit
- pydata-sphinx-theme
- pylibraft==24.8.*,>=0.0.0a0
Expand Down
1 change: 1 addition & 0 deletions conda/environments/all_cuda-118_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ dependencies:
- numpy>=1.23,<2.0a0
- numpydoc
- nvcc_linux-64=11.8
- openblas
- pre-commit
- pydata-sphinx-theme
- pylibraft==24.8.*,>=0.0.0a0
Expand Down
1 change: 1 addition & 0 deletions conda/environments/all_cuda-122_arch-aarch64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dependencies:
- ninja
- numpy>=1.23,<2.0a0
- numpydoc
- openblas
- pre-commit
- pydata-sphinx-theme
- pylibraft==24.8.*,>=0.0.0a0
Expand Down
1 change: 1 addition & 0 deletions conda/environments/all_cuda-122_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dependencies:
- ninja
- numpy>=1.23,<2.0a0
- numpydoc
- openblas
- pre-commit
- pydata-sphinx-theme
- pylibraft==24.8.*,>=0.0.0a0
Expand Down
2 changes: 1 addition & 1 deletion conda/recipes/libcuvs/build_libcuvs_tests.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# Copyright (c) 2022-2024, NVIDIA CORPORATION.

./build.sh tests --allgpuarch --no-nvtx --build-metrics=tests_bench --incl-cache-stats
./build.sh tests bench-ann --allgpuarch --no-nvtx --build-metrics=tests_bench --incl-cache-stats
Copy link
Member

Choose a reason for hiding this comment

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

Over in RAFT, bench-ann is its own package with its own dependencies, build scripts, etc.:

https://github.com/rapidsai/raft/tree/877644a423c0268746af62cecb7150afa65d8386/python/raft-ann-bench

https://github.com/rapidsai/raft/blob/877644a423c0268746af62cecb7150afa65d8386/conda/recipes/raft-ann-bench/meta.yaml

For my own understanding in reviewing this... why is this being added to the libcuvs-tests package here instead of creating a new standalone package as exists in RAFT?

Having these separate things be their own packages can be helpful for parallelizing development, limiting the potential impact of packaging changes, and speeding up debugging.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree that benchmarks should probably be a separate package. I'm only hesitating to add this because I'm not very familiar with this conda/CI setup. I hoped to postpone this question till a follow-on PR together with the naming decision (#160 (comment)). @benfred, @cjnolet , what do you think?

cmake --install cpp/build --component testing
1 change: 1 addition & 0 deletions conda/recipes/libcuvs/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ outputs:
- cuda-version ={{ cuda_version }}
- cmake {{ cmake_version }}
- ninja
- openblas
achirkin marked this conversation as resolved.
Show resolved Hide resolved
- {{ stdlib("c") }}
host:
- libraft ={{ minor_version }}
Expand Down
14 changes: 14 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ option(BUILD_SHARED_LIBS "Build cuvs shared libraries" ON)
option(BUILD_TESTS "Build cuvs unit-tests" ON)
option(BUILD_C_LIBRARY "Build raft C API library" OFF)
option(BUILD_C_TESTS "Build raft C API tests" OFF)
option(BUILD_ANN_BENCH "Build cuVS ann benchmarks" OFF)
Copy link
Member

Choose a reason for hiding this comment

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

Can we add an option to build this in CI?

It looks to me that this is off by default (which is fine), but that does mean that we don't have any guarantee that any of this is compiling.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We enable this currently together with tests in build.sh (see #130 (comment))

option(CUDA_ENABLE_KERNELINFO "Enable kernel resource usage info" OFF)
option(CUDA_ENABLE_LINEINFO
"Enable the -lineinfo option for nvcc (useful for cuda-memcheck / profiler)" OFF
Expand Down Expand Up @@ -92,6 +93,7 @@ include(CMakeDependentOption)

message(VERBOSE "cuVS: Build cuVS unit-tests: ${BUILD_TESTS}")
message(VERBOSE "cuVS: Build CPU only components: ${BUILD_CPU_ONLY}")
message(VERBOSE "cuVS: Build ANN benchmarks: ${BUILD_ANN_BENCH}")
message(VERBOSE "cuVS: Enable detection of conda environment for dependencies: ${DETECT_CONDA_ENV}")
message(VERBOSE "cuVS: Disable depreaction warnings " ${DISABLE_DEPRECATION_WARNINGS})
message(VERBOSE "cuVS: Disable OpenMP: ${DISABLE_OPENMP}")
Expand Down Expand Up @@ -184,6 +186,11 @@ endif()

include(cmake/thirdparty/get_cutlass.cmake)

if(BUILD_ANN_BENCH)
include(${rapids-cmake-dir}/cpm/gbench.cmake)
rapids_cpm_gbench(BUILD_STATIC)
endif()

# ##################################################################################################
# * cuvs ---------------------------------------------------------------------

Expand Down Expand Up @@ -663,3 +670,10 @@ if(BUILD_TESTS OR BUILD_C_TESTS)
include(internal/CMakeLists.txt)
include(test/CMakeLists.txt)
endif()

# ##################################################################################################
# * build ann benchmark executable -----------------------------------------------

if(BUILD_ANN_BENCH)
include(bench/ann/CMakeLists.txt)
endif()
Loading
Loading