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

Add cuvs_bench.run python code and build #279

Merged
merged 29 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7e37218
FEA Add cuvs-bench to dependencies and conda environments
dantegd Aug 5, 2024
b2aef6d
FIX add missing deps
dantegd Aug 5, 2024
bf75242
FIX version and other improvements
dantegd Aug 6, 2024
a8bcdef
FEA Add cuvs_bench.run
dantegd Aug 6, 2024
ec6d70c
FIX some cuvs_bench python build dependencies
dantegd Aug 6, 2024
585ad53
FIX add missing algorithms.yaml
dantegd Aug 6, 2024
bb9dc28
Merge branch 'branch-24.10' into cuvsbench-run
cjnolet Aug 12, 2024
a400e4c
ENH refactor run code and add prompts to CLI
dantegd Aug 21, 2024
0e36e21
FEA Add first version of pytests
dantegd Aug 21, 2024
f652172
Merge branch 'cuvsbench-run' of github.com:dantegd/cuvs into cuvsbenc…
dantegd Aug 21, 2024
a8652e0
Merge branch 'branch-24.10' into cuvsbench-run
cjnolet Sep 4, 2024
17264f1
Merge branch 'branch-24.10' into cuvsbench-run
cjnolet Sep 6, 2024
5e36a13
Merge dev branch and branch-24.10
dantegd Sep 17, 2024
f4cbdf5
FIX more merge conflicts
dantegd Sep 17, 2024
20886a0
Merge branch 'branch-24.10' into cuvsbench-run
dantegd Sep 17, 2024
742e7c5
fix runners
divyegala Sep 18, 2024
c342662
Merge branch 'branch-24.10' into cuvsbench-run
divyegala Sep 18, 2024
1ef9a6e
Merge branch 'branch-24.10' into cuvsbench-run
rhdong Sep 19, 2024
9b69460
pre-commit
divyegala Sep 24, 2024
bce9d22
Merge remote-tracking branch 'upstream/branch-24.10' into cuvsbench-run
divyegala Sep 24, 2024
6deb9ca
Merge branch 'branch-24.10' into cuvsbench-run
divyegala Sep 25, 2024
2b4cf8c
remove bench-ann build from cpp conda recipe
divyegala Sep 25, 2024
611f190
address review
divyegala Sep 25, 2024
2f868bb
Manage rapids-build-backend dependencies with dependencies.yaml.
bdice Sep 26, 2024
f460b3b
Remove extraneous file listing.
bdice Sep 26, 2024
8a82802
Fixes discussed with Divye.
bdice Sep 26, 2024
ac81e2f
Apply suggestions from code review
divyegala Sep 26, 2024
b2e5c48
json ignore only in root
divyegala Sep 26, 2024
0606697
Merge branch 'branch-24.10' into cuvsbench-run
cjnolet Sep 27, 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,6 @@ cagra_index
ivf_flat_index
ivf_pq_index

# cuvs_bench
datasets/
/*.json
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add back the trailing newline? And is there a name pattern that we can attach to this? Like “/bench*.json”? It’s very possible that we might want top level configuration in JSON.

Copy link
Member

Choose a reason for hiding this comment

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

We'll rework this if we add top-level JSON configurations later on. For now, this tool sometimes create top-level JSON files so we'll refactor it, if needed, so it doesn't do that

9 changes: 7 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ if hasArg tests || (( ${NUMARGS} == 0 )); then
fi

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

Expand Down Expand Up @@ -351,7 +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_CUVS_BENCH=${BUILD_CUVS_BENCH} \
-DBUILD_CPU_ONLY=${BUILD_CPU_ONLY} \
-DCMAKE_MESSAGE_LOG_LEVEL=${CMAKE_LOG_LEVEL} \
${CACHE_ARGS} \
Expand Down Expand Up @@ -419,6 +419,11 @@ if (( ${NUMARGS} == 0 )) || hasArg python; then
python -m pip install --no-build-isolation --no-deps --config-settings rapidsai.disable-cuda=true ${REPODIR}/python/cuvs
fi

# Build and (optionally) install the cuvs_bench Python package
if (( ${NUMARGS} == 0 )) || hasArg bench-ann; then
python -m pip install --no-build-isolation --no-deps --config-settings rapidsai.disable-cuda=true ${REPODIR}/python/cuvs_bench
fi

# Build the cuvs Rust bindings
if (( ${NUMARGS} == 0 )) || hasArg rust; then
cd ${REPODIR}/rust
Expand Down
3 changes: 3 additions & 0 deletions conda/environments/bench_ann_cuda-118_arch-aarch64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@ dependencies:
- pandas
- pylibraft==24.10.*,>=0.0.0a0
- pyyaml
- rapids-build-backend>=0.3.0,<0.4.0.dev0
- setuptools
- sysroot_linux-aarch64==2.17
- wheel
name: bench_ann_cuda-118_arch-aarch64
3 changes: 3 additions & 0 deletions conda/environments/bench_ann_cuda-118_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@ dependencies:
- pandas
- pylibraft==24.10.*,>=0.0.0a0
- pyyaml
- rapids-build-backend>=0.3.0,<0.4.0.dev0
- setuptools
- sysroot_linux-64==2.17
- wheel
name: bench_ann_cuda-118_arch-x86_64
3 changes: 3 additions & 0 deletions conda/environments/bench_ann_cuda-125_arch-aarch64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@ dependencies:
- pandas
- pylibraft==24.10.*,>=0.0.0a0
- pyyaml
- rapids-build-backend>=0.3.0,<0.4.0.dev0
- setuptools
- sysroot_linux-aarch64==2.17
- wheel
name: bench_ann_cuda-125_arch-aarch64
3 changes: 3 additions & 0 deletions conda/environments/bench_ann_cuda-125_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@ dependencies:
- pandas
- pylibraft==24.10.*,>=0.0.0a0
- pyyaml
- rapids-build-backend>=0.3.0,<0.4.0.dev0
- setuptools
- sysroot_linux-64==2.17
- wheel
name: bench_ann_cuda-125_arch-x86_64
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 bench-ann --allgpuarch --no-nvtx --build-metrics=tests_bench --incl-cache-stats
./build.sh tests --allgpuarch --no-nvtx --build-metrics=tests --incl-cache-stats
cmake --install cpp/build --component testing
8 changes: 4 additions & 4 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ option(BUILD_SHARED_LIBS "Build cuvs shared libraries" ON)
option(BUILD_TESTS "Build cuvs unit-tests" ON)
option(BUILD_C_LIBRARY "Build cuVS C API library" OFF)
option(BUILD_C_TESTS "Build cuVS C API tests" OFF)
option(BUILD_ANN_BENCH "Build cuVS ann benchmarks" OFF)
option(BUILD_CUVS_BENCH "Build cuVS ann benchmarks" OFF)
option(BUILD_CAGRA_HNSWLIB "Build CAGRA+hnswlib interface" ON)
option(CUDA_ENABLE_KERNELINFO "Enable kernel resource usage info" OFF)
option(CUDA_ENABLE_LINEINFO
Expand Down Expand Up @@ -96,7 +96,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: Build ANN benchmarks: ${BUILD_CUVS_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 @@ -188,7 +188,7 @@ endif()

include(cmake/thirdparty/get_cutlass.cmake)

if(BUILD_ANN_BENCH)
if(BUILD_CUVS_BENCH)
include(${rapids-cmake-dir}/cpm/gbench.cmake)
rapids_cpm_gbench(BUILD_STATIC)
endif()
Expand Down Expand Up @@ -651,6 +651,6 @@ endif()
# ##################################################################################################
# * build ann benchmark executable -----------------------------------------------

if(BUILD_ANN_BENCH)
if(BUILD_CUVS_BENCH)
add_subdirectory(bench/ann/)
endif()
52 changes: 13 additions & 39 deletions cpp/bench/ann/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,30 +199,19 @@ if(NOT TARGET CUVS_ANN_BENCH_ALL)
endif()

if(CUVS_ANN_BENCH_USE_HNSWLIB)
ConfigureAnnBench(
NAME HNSWLIB PATH src/hnswlib/hnswlib_benchmark.cpp LINKS hnswlib::hnswlib
)
ConfigureAnnBench(NAME HNSWLIB PATH src/hnswlib/hnswlib_benchmark.cpp LINKS hnswlib::hnswlib)

endif()

if(CUVS_ANN_BENCH_USE_CUVS_IVF_PQ)
ConfigureAnnBench(
NAME CUVS_IVF_PQ
PATH
src/cuvs/cuvs_benchmark.cu
src/cuvs/cuvs_ivf_pq.cu
LINKS cuvs
NAME CUVS_IVF_PQ PATH src/cuvs/cuvs_benchmark.cu src/cuvs/cuvs_ivf_pq.cu LINKS cuvs
)
endif()

if(CUVS_ANN_BENCH_USE_CUVS_IVF_FLAT)
ConfigureAnnBench(
NAME CUVS_IVF_FLAT
PATH
src/cuvs/cuvs_benchmark.cu
src/cuvs/cuvs_ivf_flat.cu
LINKS
cuvs
NAME CUVS_IVF_FLAT PATH src/cuvs/cuvs_benchmark.cu src/cuvs/cuvs_ivf_flat.cu LINKS cuvs
)
endif()

Expand All @@ -232,12 +221,8 @@ endif()

if(CUVS_KNN_BENCH_USE_CUVS_BRUTE_FORCE)
ConfigureAnnBench(
NAME
CUVS_KNN_BRUTE_FORCE
PATH
$<$<BOOL:${CUVS_KNN_BENCH_USE_CUVS_BRUTE_FORCE}>:src/cuvs/cuvs_brute_force_knn.cu>
LINKS
cuvs
NAME CUVS_KNN_BRUTE_FORCE PATH
$<$<BOOL:${CUVS_KNN_BENCH_USE_CUVS_BRUTE_FORCE}>:src/cuvs/cuvs_brute_force_knn.cu> LINKS cuvs
)
endif()

Expand All @@ -258,45 +243,39 @@ endif()

if(CUVS_ANN_BENCH_USE_CUVS_CAGRA_HNSWLIB)
ConfigureAnnBench(
NAME CUVS_CAGRA_HNSWLIB PATH src/cuvs/cuvs_cagra_hnswlib.cu LINKS cuvs
hnswlib::hnswlib
NAME CUVS_CAGRA_HNSWLIB PATH src/cuvs/cuvs_cagra_hnswlib.cu LINKS cuvs hnswlib::hnswlib
)
endif()

message("CUVS_FAISS_TARGETS: ${CUVS_FAISS_TARGETS}")
message("CUDAToolkit_LIBRARY_DIR: ${CUDAToolkit_LIBRARY_DIR}")
if(CUVS_ANN_BENCH_USE_FAISS_CPU_FLAT)
ConfigureAnnBench(
NAME FAISS_CPU_FLAT PATH src/faiss/faiss_cpu_benchmark.cpp LINKS
${CUVS_FAISS_TARGETS}
NAME FAISS_CPU_FLAT PATH src/faiss/faiss_cpu_benchmark.cpp LINKS ${CUVS_FAISS_TARGETS}
)
endif()

if(CUVS_ANN_BENCH_USE_FAISS_CPU_IVF_FLAT)
ConfigureAnnBench(
NAME FAISS_CPU_IVF_FLAT PATH src/faiss/faiss_cpu_benchmark.cpp LINKS
${CUVS_FAISS_TARGETS}
NAME FAISS_CPU_IVF_FLAT PATH src/faiss/faiss_cpu_benchmark.cpp LINKS ${CUVS_FAISS_TARGETS}
)
endif()

if(CUVS_ANN_BENCH_USE_FAISS_CPU_IVF_PQ)
ConfigureAnnBench(
NAME FAISS_CPU_IVF_PQ PATH src/faiss/faiss_cpu_benchmark.cpp LINKS
${CUVS_FAISS_TARGETS}
NAME FAISS_CPU_IVF_PQ PATH src/faiss/faiss_cpu_benchmark.cpp LINKS ${CUVS_FAISS_TARGETS}
)
endif()

if(CUVS_ANN_BENCH_USE_FAISS_GPU_IVF_FLAT AND CUVS_FAISS_ENABLE_GPU)
ConfigureAnnBench(
NAME FAISS_GPU_IVF_FLAT PATH src/faiss/faiss_gpu_benchmark.cu LINKS
${CUVS_FAISS_TARGETS}
NAME FAISS_GPU_IVF_FLAT PATH src/faiss/faiss_gpu_benchmark.cu LINKS ${CUVS_FAISS_TARGETS}
)
endif()

if(CUVS_ANN_BENCH_USE_FAISS_GPU_IVF_PQ AND CUVS_FAISS_ENABLE_GPU)
ConfigureAnnBench(
NAME FAISS_GPU_IVF_PQ PATH src/faiss/faiss_gpu_benchmark.cu LINKS
${CUVS_FAISS_TARGETS}
NAME FAISS_GPU_IVF_PQ PATH src/faiss/faiss_gpu_benchmark.cu LINKS ${CUVS_FAISS_TARGETS}
)
endif()

Expand All @@ -322,13 +301,8 @@ if(CUVS_ANN_BENCH_SINGLE_EXE)

target_link_libraries(
ANN_BENCH
PRIVATE raft::raft
nlohmann_json::nlohmann_json
benchmark::benchmark
dl
fmt::fmt-header-only
spdlog::spdlog_header_only
$<$<BOOL:${NVTX3_HEADERS_FOUND}>:CUDA::nvtx3>
PRIVATE raft::raft nlohmann_json::nlohmann_json benchmark::benchmark dl fmt::fmt-header-only
spdlog::spdlog_header_only $<$<BOOL:${NVTX3_HEADERS_FOUND}>:CUDA::nvtx3>
)
set_target_properties(
ANN_BENCH
Expand Down
15 changes: 11 additions & 4 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ files:
- develop
- bench
- bench_python
- rapids_build_setuptools
bdice marked this conversation as resolved.
Show resolved Hide resolved
test_cpp:
output: none
includes:
Expand Down Expand Up @@ -115,6 +116,13 @@ files:
table: build-system
includes:
- rapids_build_setuptools
py_rapids_build_py_cuvs_bench:
output: pyproject
pyproject_dir: python/cuvs_bench
extras:
table: tool.rapids-build-backend
key: requires
includes: []
py_run_cuvs_bench:
output: pyproject
pyproject_dir: python/cuvs_bench
Expand Down Expand Up @@ -187,7 +195,7 @@ dependencies:

rapids_build_setuptools:
common:
- output_types: [requirements, pyproject]
- output_types: [conda, requirements, pyproject]
packages:
- &rapids_build_backend rapids-build-backend>=0.3.0,<0.4.0.dev0
- setuptools
Expand Down Expand Up @@ -469,13 +477,12 @@ dependencies:
- openblas
bench_python:
common:
- output_types: [conda]
- output_types: [conda, pyproject, requirements]
packages:
- click
- matplotlib
- pandas
- pyyaml
- pandas
- click
depends_on_librmm:
common:
- output_types: conda
Expand Down
22 changes: 15 additions & 7 deletions python/cuvs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,22 @@ if(NOT cuvs_FOUND)

if(NOT CUDA_STATIC_MATH_LIBRARIES AND USE_CUDA_MATH_WHEELS)
set(rpaths
"$ORIGIN/../nvidia/cublas/lib"
"$ORIGIN/../nvidia/curand/lib"
"$ORIGIN/../nvidia/cusolver/lib"
"$ORIGIN/../nvidia/cusparse/lib"
"$ORIGIN/../nvidia/nvjitlink/lib"
"$ORIGIN/../nvidia/cublas/lib"
"$ORIGIN/../nvidia/curand/lib"
"$ORIGIN/../nvidia/cusolver/lib"
"$ORIGIN/../nvidia/cusparse/lib"
"$ORIGIN/../nvidia/nvjitlink/lib"
)
set_property(
TARGET cuvs
PROPERTY INSTALL_RPATH ${rpaths}
APPEND
)
set_property(
TARGET cuvs_c
PROPERTY INSTALL_RPATH ${rpaths}
APPEND
)
set_property(TARGET cuvs PROPERTY INSTALL_RPATH ${rpaths} APPEND)
set_property(TARGET cuvs_c PROPERTY INSTALL_RPATH ${rpaths} APPEND)
endif()

set(cython_lib_dir cuvs)
Expand Down
3 changes: 1 addition & 2 deletions python/cuvs/cuvs/neighbors/filters/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ set(linked_libraries cuvs::cuvs cuvs::c_api)
rapids_cython_create_modules(
CXX
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${linked_libraries}" ASSOCIATED_TARGETS cuvs MODULE_PREFIX
neighbors_prefilter_
LINKED_LIBRARIES "${linked_libraries}" ASSOCIATED_TARGETS cuvs MODULE_PREFIX neighbors_prefilter_
)
17 changes: 17 additions & 0 deletions python/cuvs_bench/cuvs_bench/config/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Copyright (c) 2024, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from .algos.constraints import *
42 changes: 42 additions & 0 deletions python/cuvs_bench/cuvs_bench/config/algorithms.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
faiss_gpu_flat:
executable: FAISS_GPU_FLAT_ANN_BENCH
requires_gpu: true
faiss_gpu_ivf_flat:
executable: FAISS_GPU_IVF_FLAT_ANN_BENCH
requires_gpu: true
faiss_gpu_ivf_pq:
executable: FAISS_GPU_IVF_PQ_ANN_BENCH
requires_gpu: true
faiss_gpu_ivf_sq:
executable: FAISS_GPU_IVF_PQ_ANN_BENCH
requires_gpu: true
faiss_cpu_flat:
executable: FAISS_CPU_FLAT_ANN_BENCH
requires_gpu: false
faiss_cpu_ivf_flat:
executable: FAISS_CPU_IVF_FLAT_ANN_BENCH
requires_gpu: false
faiss_cpu_ivf_pq:
executable: FAISS_CPU_IVF_PQ_ANN_BENCH
requires_gpu: false
cuvs_ivf_flat:
executable: CUVS_IVF_FLAT_ANN_BENCH
requires_gpu: true
cuvs_ivf_pq:
executable: CUVS_IVF_PQ_ANN_BENCH
requires_gpu: true
cuvs_cagra:
executable: CUVS_CAGRA_ANN_BENCH
requires_gpu: true
cuvs_brute_force:
executable: CUVS_BRUTE_FORCE_ANN_BENCH
requires_gpu: true
ggnn:
executable: GGNN_ANN_BENCH
requires_gpu: true
hnswlib:
executable: HNSWLIB_ANN_BENCH
requires_gpu: false
cuvs_cagra_hnswlib:
executable: CUVS_CAGRA_HNSWLIB_ANN_BENCH
requires_gpu: true
Empty file.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2023-2024, NVIDIA CORPORATION.
# Copyright (c) 2024, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Loading
Loading