Skip to content

Commit 064a23b

Browse files
authored
ANN_BENCH (#130)
Porting the ANN benchmarks from RAFT. - [x] Make it build Sanity check that benchmarks work (runs and gives reasonable recall for Deep-1M dataset) - [x] cuVS brute force kNN - [x] cuVS IVF-Flat - [x] cuVS IVF-PQ (+ refinement) - [x] cuVS CAGRA - [x] cuVS CAGRA-Q (+refinement) - [x] Faiss GPU/CPU IVF-Flat & IVF-PQ - [x] HNSW - [x] CAGRA + HNSW - [x] GGNN NB: the indices built using the old ANN_BENCH in raft tend to crash in cuvs search benchmarks during index deserialization - don't forget to build the indexes anew when testing. Authors: - Artem M. Chirkin (https://github.com/achirkin) - Malte Förster (https://github.com/mfoerste4) - Tamas Bela Feher (https://github.com/tfeher) - Micka (https://github.com/lowener) - Corey J. Nolet (https://github.com/cjnolet) Approvers: - Tamas Bela Feher (https://github.com/tfeher) - James Lamb (https://github.com/jameslamb) - Corey J. Nolet (https://github.com/cjnolet) URL: #130
1 parent ebfd068 commit 064a23b

52 files changed

Lines changed: 7868 additions & 98 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.sh

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ ARGS=$*
1818
# scripts, and that this script resides in the repo dir!
1919
REPODIR=$(cd $(dirname $0); pwd)
2020

21-
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"
22-
HELP="$0 [<target> ...] [<flag> ...] [--cmake-args=\"<args>\"] [--cache-tool=<tool>] [--limit-tests=<targets>] [--build-metrics=<filename>]
21+
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"
22+
HELP="$0 [<target> ...] [<flag> ...] [--cmake-args=\"<args>\"] [--cache-tool=<tool>] [--limit-tests=<targets>] [--limit-bench-ann=<targets>] [--build-metrics=<filename>]
2323
where <target> is:
2424
clean - remove all existing build artifacts and configuration (start over)
2525
libcuvs - build the cuvs C++ code only. Also builds the C-wrapper library
@@ -28,6 +28,7 @@ HELP="$0 [<target> ...] [<flag> ...] [--cmake-args=\"<args>\"] [--cache-tool=<to
2828
rust - build the cuvs Rust bindings
2929
docs - build the documentation
3030
tests - build the tests
31+
bench-ann - build end-to-end ann benchmarks
3132
examples - build the examples
3233
3334
and <flag> is:
@@ -37,6 +38,7 @@ HELP="$0 [<target> ...] [<flag> ...] [--cmake-args=\"<args>\"] [--cache-tool=<to
3738
--uninstall - uninstall files for specified targets which were built and installed prior
3839
--compile-static-lib - compile static library for all components
3940
--limit-tests - semicolon-separated list of test executables to compile (e.g. NEIGHBORS_TEST;CLUSTER_TEST)
41+
--limit-bench-ann - semicolon-separated list of ann benchmark executables to compute (e.g. HNSWLIB_ANN_BENCH;RAFT_IVF_PQ_ANN_BENCH)
4042
--allgpuarch - build for all supported GPU architectures
4143
--no-nvtx - disable nvtx (profiling markers), but allow enabling it in downstream projects
4244
--show_depr_warn - show cmake deprecation warnings
@@ -70,6 +72,7 @@ BUILD_REPORT_METRICS=""
7072
BUILD_REPORT_INCL_CACHE_STATS=OFF
7173

7274
TEST_TARGETS="NEIGHBORS_ANN_CAGRA_TEST"
75+
ANN_BENCH_TARGETS="CUVS_ANN_BENCH_ALL"
7376

7477
CACHE_ARGS=""
7578
NVTX=ON
@@ -150,6 +153,21 @@ function limitTests {
150153
fi
151154
}
152155

156+
function limitAnnBench {
157+
# Check for option to limit the set of test binaries to build
158+
if [[ -n $(echo $ARGS | { grep -E "\-\-limit\-bench-ann" || true; } ) ]]; then
159+
# There are possible weird edge cases that may cause this regex filter to output nothing and fail silently
160+
# the true pipe will catch any weird edge cases that may happen and will cause the program to fall back
161+
# on the invalid option error
162+
LIMIT_ANN_BENCH_TARGETS=$(echo $ARGS | sed -e 's/.*--limit-bench-ann=//' -e 's/ .*//')
163+
if [[ -n ${LIMIT_ANN_BENCH_TARGETS} ]]; then
164+
# Remove the full LIMIT_TEST_TARGETS argument from list of args so that it passes validArgs function
165+
ARGS=${ARGS//--limit-bench-ann=$LIMIT_ANN_BENCH_TARGETS/}
166+
ANN_BENCH_TARGETS=${LIMIT_ANN_BENCH_TARGETS}
167+
fi
168+
fi
169+
}
170+
153171
function buildMetrics {
154172
# Check for multiple build-metrics options
155173
if [[ $(echo $ARGS | { grep -Eo "\-\-build\-metrics" || true; } | wc -l ) -gt 1 ]]; then
@@ -179,6 +197,7 @@ if (( ${NUMARGS} != 0 )); then
179197
cmakeArgs
180198
cacheTool
181199
limitTests
200+
limitAnnBench
182201
buildMetrics
183202
for a in ${ARGS}; do
184203
if ! (echo " ${VALIDARGS} " | grep -q " ${a} "); then
@@ -255,6 +274,11 @@ if hasArg tests || (( ${NUMARGS} == 0 )); then
255274
fi
256275
fi
257276

277+
if hasArg bench-ann || (( ${NUMARGS} == 0 )); then
278+
BUILD_ANN_BENCH=ON
279+
CMAKE_TARGET="${CMAKE_TARGET};${ANN_BENCH_TARGETS}"
280+
fi
281+
258282
if hasArg --no-nvtx; then
259283
NVTX=OFF
260284
fi
@@ -327,6 +351,7 @@ if (( ${NUMARGS} == 0 )) || hasArg libcuvs || hasArg docs || hasArg tests || has
327351
-DDISABLE_DEPRECATION_WARNINGS=${DISABLE_DEPRECATION_WARNINGS} \
328352
-DBUILD_TESTS=${BUILD_TESTS} \
329353
-DBUILD_C_TESTS=${BUILD_TESTS} \
354+
-DBUILD_ANN_BENCH=${BUILD_ANN_BENCH} \
330355
-DBUILD_CPU_ONLY=${BUILD_CPU_ONLY} \
331356
-DCMAKE_MESSAGE_LOG_LEVEL=${CMAKE_LOG_LEVEL} \
332357
${CACHE_ARGS} \

conda/environments/all_cuda-118_arch-aarch64.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ dependencies:
4141
- numpy>=1.23,<2.0a0
4242
- numpydoc
4343
- nvcc_linux-aarch64=11.8
44+
- openblas
4445
- pre-commit
4546
- pydata-sphinx-theme
4647
- pylibraft==24.8.*,>=0.0.0a0

conda/environments/all_cuda-118_arch-x86_64.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ dependencies:
4141
- numpy>=1.23,<2.0a0
4242
- numpydoc
4343
- nvcc_linux-64=11.8
44+
- openblas
4445
- pre-commit
4546
- pydata-sphinx-theme
4647
- pylibraft==24.8.*,>=0.0.0a0

conda/environments/all_cuda-122_arch-aarch64.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ dependencies:
3737
- ninja
3838
- numpy>=1.23,<2.0a0
3939
- numpydoc
40+
- openblas
4041
- pre-commit
4142
- pydata-sphinx-theme
4243
- pylibraft==24.8.*,>=0.0.0a0

conda/environments/all_cuda-122_arch-x86_64.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ dependencies:
3737
- ninja
3838
- numpy>=1.23,<2.0a0
3939
- numpydoc
40+
- openblas
4041
- pre-commit
4142
- pydata-sphinx-theme
4243
- pylibraft==24.8.*,>=0.0.0a0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
22
# Copyright (c) 2022-2024, NVIDIA CORPORATION.
33

4-
./build.sh tests --allgpuarch --no-nvtx --build-metrics=tests_bench --incl-cache-stats
4+
./build.sh tests bench-ann --allgpuarch --no-nvtx --build-metrics=tests_bench --incl-cache-stats
55
cmake --install cpp/build --component testing

conda/recipes/libcuvs/meta.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ outputs:
198198
- libraft ={{ minor_version }}
199199
- {{ pin_subpackage('libcuvs', exact=True) }}
200200
- cuda-version ={{ cuda_version }}
201+
- openblas # required by some CPU algos in benchmarks
201202
{% if cuda_major == "11" %}
202203
- cuda-profiler-api {{ cuda11_cuda_profiler_api_run_version }}
203204
- libcublas {{ cuda11_libcublas_host_version }}

cpp/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ option(BUILD_SHARED_LIBS "Build cuvs shared libraries" ON)
5555
option(BUILD_TESTS "Build cuvs unit-tests" ON)
5656
option(BUILD_C_LIBRARY "Build raft C API library" OFF)
5757
option(BUILD_C_TESTS "Build raft C API tests" OFF)
58+
option(BUILD_ANN_BENCH "Build cuVS ann benchmarks" OFF)
5859
option(CUDA_ENABLE_KERNELINFO "Enable kernel resource usage info" OFF)
5960
option(CUDA_ENABLE_LINEINFO
6061
"Enable the -lineinfo option for nvcc (useful for cuda-memcheck / profiler)" OFF
@@ -92,6 +93,7 @@ include(CMakeDependentOption)
9293

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

185187
include(cmake/thirdparty/get_cutlass.cmake)
186188

189+
if(BUILD_ANN_BENCH)
190+
include(${rapids-cmake-dir}/cpm/gbench.cmake)
191+
rapids_cpm_gbench(BUILD_STATIC)
192+
endif()
193+
187194
# ##################################################################################################
188195
# * cuvs ---------------------------------------------------------------------
189196

@@ -663,3 +670,10 @@ if(BUILD_TESTS OR BUILD_C_TESTS)
663670
include(internal/CMakeLists.txt)
664671
include(test/CMakeLists.txt)
665672
endif()
673+
674+
# ##################################################################################################
675+
# * build ann benchmark executable -----------------------------------------------
676+
677+
if(BUILD_ANN_BENCH)
678+
include(bench/ann/CMakeLists.txt)
679+
endif()

0 commit comments

Comments
 (0)