Skip to content

Commit

Permalink
Merge branch 'branch-25.04' into diskann-wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
tarang-jain authored Feb 11, 2025
2 parents b4f301e + fe6c1c5 commit d09e71e
Show file tree
Hide file tree
Showing 29 changed files with 28 additions and 174 deletions.
3 changes: 2 additions & 1 deletion ci/build_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ rapids-logger "Begin cpp build"

sccache --zero-stats

RAPIDS_PACKAGE_VERSION=$(rapids-generate-version) rapids-conda-retry mambabuild conda/recipes/libcuvs
RAPIDS_PACKAGE_VERSION=$(rapids-generate-version) rapids-conda-retry mambabuild \
conda/recipes/libcuvs

sccache --show-adv-stats

Expand Down
1 change: 1 addition & 0 deletions ci/build_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ EXCLUDE_ARGS=(
--exclude "libcusolver.so.*"
--exclude "libcusparse.so.*"
--exclude "libnvJitLink.so.*"
--exclude "librapids_logger.so"
)

if [[ "${package_dir}" != "python/libcuvs" ]]; then
Expand Down
6 changes: 0 additions & 6 deletions conda/recipes/cuvs-bench-cpu/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,3 @@ h5py_version:

nlohmann_json_version:
- ">=3.11.2"

spdlog_version:
- ">=1.14.1,<1.15"

fmt_version:
- ">=11.0.2,<12"
2 changes: 0 additions & 2 deletions conda/recipes/cuvs-bench-cpu/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ requirements:

host:
- benchmark
- fmt {{ fmt_version }}
- glog {{ glog_version }}
- libaio
- libboost-devel=1.87
Expand All @@ -54,7 +53,6 @@ requirements:
- openblas
- python
- rapids-build-backend>=0.3.0,<0.4.0.dev0
- spdlog {{ spdlog_version }}

run:
- benchmark
Expand Down
12 changes: 5 additions & 7 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -499,16 +499,14 @@ if(BUILD_SHARED_LIBS)
"$<$<COMPILE_LANGUAGE:CUDA>:${CUVS_CUDA_FLAGS}>"
)
target_link_libraries(
cuvs_objs
PUBLIC raft::raft rmm::rmm rmm::rmm_logger ${CUVS_CTK_MATH_DEPENDENCIES}
$<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX>
PRIVATE rmm::rmm_logger_impl raft::raft_logger_impl
cuvs_objs PUBLIC raft::raft rmm::rmm ${CUVS_CTK_MATH_DEPENDENCIES}
$<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX>
)

add_library(cuvs SHARED $<FILTER:$<TARGET_OBJECTS:cuvs_objs>,EXCLUDE,rmm.*logger>)
add_library(cuvs SHARED $<TARGET_OBJECTS:cuvs_objs>)

if(NOT CUVS_COMPILE_DYNAMIC_ONLY)
add_library(cuvs_static STATIC $<FILTER:$<TARGET_OBJECTS:cuvs_objs>,EXCLUDE,rmm.*logger>)
add_library(cuvs_static STATIC $<TARGET_OBJECTS:cuvs_objs>)
endif()

target_compile_options(
Expand Down Expand Up @@ -731,7 +729,7 @@ target_compile_definitions(cuvs::cuvs INTERFACE $<$<BOOL:${CUVS_NVTX}>:NVTX_ENAB
target_link_libraries(
cuvs_c
PUBLIC cuvs::cuvs ${CUVS_CTK_MATH_DEPENDENCIES}
PRIVATE raft::raft rmm::rmm_logger_impl raft::raft_logger_impl
PRIVATE raft::raft
)

# ensure CUDA symbols aren't relocated to the middle of the debug build binaries
Expand Down
20 changes: 2 additions & 18 deletions cpp/bench/ann/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,9 @@ function(ConfigureAnnBench)
PRIVATE ${ConfigureAnnBench_LINKS}
nlohmann_json::nlohmann_json
Threads::Threads
$<TARGET_NAME_IF_EXISTS:raft::raft_logger>
$<$<BOOL:${GPU_BUILD}>:CUDA::cudart_static>
$<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX>
$<TARGET_NAME_IF_EXISTS:conda_env>
$<TARGET_NAME_IF_EXISTS:cuvs_bench_logger>
)

set_target_properties(
Expand Down Expand Up @@ -189,13 +187,6 @@ function(ConfigureAnnBench)
add_dependencies(CUVS_ANN_BENCH_ALL ${BENCH_NAME})
endfunction()

if(CUVS_FAISS_ENABLE_GPU OR CUVS_ANN_BENCH_SINGLE_EXE)
add_library(cuvs_bench_logger OBJECT)
target_link_libraries(
cuvs_bench_logger PRIVATE rmm::rmm_logger_impl $<TARGET_NAME_IF_EXISTS:raft::raft_logger>
)
endif()

# ##################################################################################################
# * Configure benchmark targets -------------------------------------------------------------

Expand Down Expand Up @@ -341,15 +332,8 @@ if(CUVS_ANN_BENCH_SINGLE_EXE)
target_include_directories(ANN_BENCH PRIVATE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})

target_link_libraries(
ANN_BENCH
PRIVATE raft::raft
nlohmann_json::nlohmann_json
benchmark::benchmark
dl
fmt::fmt-header-only
spdlog::spdlog_header_only
$<$<TARGET_EXISTS:CUDA::nvtx3>:CUDA::nvtx3>
cuvs_bench_logger
ANN_BENCH PRIVATE raft::raft nlohmann_json::nlohmann_json benchmark::benchmark dl
$<$<TARGET_EXISTS:CUDA::nvtx3>:CUDA::nvtx3>
)
set_target_properties(
ANN_BENCH
Expand Down
2 changes: 1 addition & 1 deletion cpp/cmake/thirdparty/get_raft.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function(find_and_configure_raft)
# Invoke CPM find_package()
#-----------------------------------------------------
rapids_cpm_find(raft ${PKG_VERSION}
GLOBAL_TARGETS raft::raft raft::raft_logger raft::raft_logger_impl
GLOBAL_TARGETS raft::raft
BUILD_EXPORT_SET cuvs-exports
INSTALL_EXPORT_SET cuvs-exports
COMPONENTS ${RAFT_COMPONENTS}
Expand Down
3 changes: 2 additions & 1 deletion cpp/include/cuvs/cluster/kmeans.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <raft/core/logger.hpp>
#include <raft/core/resources.hpp>
#include <raft/random/rng_state.hpp>
#include <rapids_logger/logger.hpp>

namespace cuvs::cluster::kmeans {

Expand Down Expand Up @@ -86,7 +87,7 @@ struct params : base_params {
/**
* verbosity level.
*/
raft::level_enum verbosity = raft::level_enum::info;
rapids_logger::level_enum verbosity = rapids_logger::level_enum::info;

/**
* Seed to the random number generator.
Expand Down
1 change: 0 additions & 1 deletion cpp/src/cluster/detail/kmeans_balanced.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#include <cuvs/distance/distance.hpp>
#include <raft/core/cudart_utils.hpp>
#include <raft/core/logger-macros.hpp>
#include <raft/core/logger.hpp>
#include <raft/core/operators.hpp>
#include <raft/core/resource/cuda_stream.hpp>
Expand Down
1 change: 0 additions & 1 deletion cpp/src/neighbors/ivf_flat/ivf_flat_build.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "../../cluster/kmeans_balanced.cuh"
#include "../detail/ann_utils.cuh"
#include <cuvs/distance/distance.hpp>
#include <raft/core/logger-macros.hpp>
#include <raft/core/logger.hpp>
#include <raft/core/mdarray.hpp>
#include <raft/core/operators.hpp>
Expand Down
1 change: 0 additions & 1 deletion cpp/src/neighbors/ivf_flat/ivf_flat_search.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <cuvs/distance/distance.hpp> // is_min_close, DistanceType
#include <cuvs/selection/select_k.hpp> // cuvs::selection::select_k
#include <raft/core/error.hpp>
#include <raft/core/logger-macros.hpp>
#include <raft/core/logger.hpp>
#include <raft/core/resource/cuda_stream.hpp>
#include <raft/core/resources.hpp> // raft::resources
Expand Down
4 changes: 0 additions & 4 deletions cpp/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ function(ConfigureTest)
PRIVATE cuvs
cuvs::cuvs
raft::raft
test_rmm_logger
GTest::gtest
GTest::gtest_main
Threads::Threads
Expand Down Expand Up @@ -88,9 +87,6 @@ function(ConfigureTest)
)
endfunction()

add_library(test_rmm_logger OBJECT)
target_link_libraries(test_rmm_logger PRIVATE rmm::rmm_logger_impl raft::raft_logger_impl)

# ##################################################################################################
# test sources ##################################################################################
# ##################################################################################################
Expand Down
1 change: 1 addition & 0 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ files:
includes:
- cuda_wheels
- depends_on_libraft
- depends_on_librmm
py_build_cuvs:
output: pyproject
pyproject_dir: python/cuvs
Expand Down
55 changes: 0 additions & 55 deletions docs/source/developer_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,61 +227,6 @@ Keep in mind that this only applies to files tracked by git that have been modif
## Error handling
Call CUDA APIs via the provided helper macros `RAFT_CUDA_TRY`, `RAFT_CUBLAS_TRY` and `RAFT_CUSOLVER_TRY`. These macros take care of checking the return values of the used API calls and generate an exception when the command is not successful. If you need to avoid an exception, e.g. inside a destructor, use `RAFT_CUDA_TRY_NO_THROW`, `RAFT_CUBLAS_TRY_NO_THROW ` and `RAFT_CUSOLVER_TRY_NO_THROW`. These macros log the error but do not throw an exception.

## Logging

### Introduction
Anything and everything about logging is defined inside [logger.hpp](https://github.com/rapidsai/raft/blob/branch-25.04/cpp/include/raft/core/logger.hpp). It uses [spdlog](https://github.com/gabime/spdlog) underneath, but this information is transparent to all.

### Usage
```cpp
#include <raft/core/logger.hpp>

// Inside your method or function, use any of these macros
RAFT_LOG_TRACE("Hello %s!", "world");
RAFT_LOG_DEBUG("Hello %s!", "world");
RAFT_LOG_INFO("Hello %s!", "world");
RAFT_LOG_WARN("Hello %s!", "world");
RAFT_LOG_ERROR("Hello %s!", "world");
RAFT_LOG_CRITICAL("Hello %s!", "world");
```
### Changing logging level
There are 7 logging levels with each successive level becoming quieter:
1. RAFT_LEVEL_TRACE
2. RAFT_LEVEL_DEBUG
3. RAFT_LEVEL_INFO
4. RAFT_LEVEL_WARN
5. RAFT_LEVEL_ERROR
6. RAFT_LEVEL_CRITICAL
7. RAFT_LEVEL_OFF
Pass one of these as per your needs into the `set_level()` method as follows:
```cpp
raft::logger::get().set_level(RAFT_LEVEL_WARN);
// From now onwards, this will print only WARN and above kind of messages
```

### Changing logging pattern
Pass the [format string](https://github.com/gabime/spdlog/wiki/3.-Custom-formatting) as follows in order use a different logging pattern than the default.
```cpp
raft::logger::get.set_pattern(YourFavoriteFormat);
```
One can also use the corresponding `get_pattern()` method to know the current format as well.

### Temporarily changing the logging pattern
Sometimes, we need to temporarily change the log pattern (eg: for reporting decision tree structure). This can be achieved in a RAII-like approach as follows:
```cpp
{
PatternSetter _(MyNewTempFormat);
// new log format is in effect from here onwards
doStuff();
// once the above temporary object goes out-of-scope, the old format will be restored
}
```

### Tips
* Do NOT end your logging messages with a newline! It is automatically added by spdlog.
* The `RAFT_LOG_TRACE()` is by default not compiled due to the `RAFT_ACTIVE_LEVEL` macro setup, for performance reasons. If you need it to be enabled, change this macro accordingly during compilation time

## Common Design Considerations

1. Use the `hpp` extension for files which can be compiled with `gcc` against the CUDA-runtime. Use the `cuh` extension for files which require `nvcc` to be compiled. `hpp` can also be used for functions marked `__host__ __device__` only if proper checks are in place to remove the `__device__` designation when not compiling with `nvcc`.
Expand Down
25 changes: 5 additions & 20 deletions examples/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,14 @@ add_executable(VAMANA_EXAMPLE src/vamana_example.cu)

# `$<TARGET_NAME_IF_EXISTS:conda_env>` is a generator expression that ensures that targets are
# installed in a conda environment, if one exists
add_library(rmm_logger OBJECT)
target_link_libraries(rmm_logger PRIVATE rmm::rmm_logger_impl)

target_link_libraries(
BRUTE_FORCE_EXAMPLE PRIVATE cuvs::cuvs $<TARGET_NAME_IF_EXISTS:conda_env> rmm_logger
)
target_link_libraries(
CAGRA_EXAMPLE PRIVATE cuvs::cuvs $<TARGET_NAME_IF_EXISTS:conda_env> rmm_logger
)
target_link_libraries(BRUTE_FORCE_EXAMPLE PRIVATE cuvs::cuvs $<TARGET_NAME_IF_EXISTS:conda_env>)
target_link_libraries(CAGRA_EXAMPLE PRIVATE cuvs::cuvs $<TARGET_NAME_IF_EXISTS:conda_env>)
target_link_libraries(
CAGRA_PERSISTENT_EXAMPLE PRIVATE cuvs::cuvs $<TARGET_NAME_IF_EXISTS:conda_env> Threads::Threads
rmm_logger
)
target_link_libraries(
DYNAMIC_BATCHING_EXAMPLE PRIVATE cuvs::cuvs $<TARGET_NAME_IF_EXISTS:conda_env> Threads::Threads
rmm_logger
)
target_link_libraries(
IVF_PQ_EXAMPLE PRIVATE cuvs::cuvs $<TARGET_NAME_IF_EXISTS:conda_env> rmm_logger
)
target_link_libraries(
IVF_FLAT_EXAMPLE PRIVATE cuvs::cuvs $<TARGET_NAME_IF_EXISTS:conda_env> rmm_logger
)
target_link_libraries(
VAMANA_EXAMPLE PRIVATE cuvs::cuvs $<TARGET_NAME_IF_EXISTS:conda_env> rmm_logger
)
target_link_libraries(IVF_PQ_EXAMPLE PRIVATE cuvs::cuvs $<TARGET_NAME_IF_EXISTS:conda_env>)
target_link_libraries(IVF_FLAT_EXAMPLE PRIVATE cuvs::cuvs $<TARGET_NAME_IF_EXISTS:conda_env>)
target_link_libraries(VAMANA_EXAMPLE PRIVATE cuvs::cuvs $<TARGET_NAME_IF_EXISTS:conda_env>)
3 changes: 0 additions & 3 deletions python/cuvs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ target_include_directories(cuvs::cuvs INTERFACE "$<BUILD_INTERFACE:${DLPACK_INCL

rapids_cython_init()

add_library(cuvs_rmm_logger OBJECT)
target_link_libraries(cuvs_rmm_logger PRIVATE rmm::rmm_logger_impl)

add_subdirectory(cuvs/common)
add_subdirectory(cuvs/distance)
add_subdirectory(cuvs/neighbors)
Expand Down
4 changes: 0 additions & 4 deletions python/cuvs/cuvs/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,3 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX common_
)

foreach(tgt IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
target_link_libraries(${tgt} PRIVATE cuvs_rmm_logger)
endforeach()
4 changes: 0 additions & 4 deletions python/cuvs/cuvs/distance/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,3 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX distance_
)

foreach(tgt IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
target_link_libraries(${tgt} PRIVATE cuvs_rmm_logger)
endforeach()
4 changes: 0 additions & 4 deletions python/cuvs/cuvs/neighbors/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,3 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX neighbors_refine_
)

foreach(tgt IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
target_link_libraries(${tgt} PRIVATE cuvs_rmm_logger)
endforeach()
4 changes: 0 additions & 4 deletions python/cuvs/cuvs/neighbors/brute_force/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,3 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX neighbors_brute_force_
)

foreach(tgt IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
target_link_libraries(${tgt} PRIVATE cuvs_rmm_logger)
endforeach()
4 changes: 0 additions & 4 deletions python/cuvs/cuvs/neighbors/cagra/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,3 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX neighbors_cagra_
)

foreach(tgt IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
target_link_libraries(${tgt} PRIVATE cuvs_rmm_logger)
endforeach()
4 changes: 0 additions & 4 deletions python/cuvs/cuvs/neighbors/filters/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,3 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX neighbors_prefilter_
)

foreach(tgt IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
target_link_libraries(${tgt} PRIVATE cuvs_rmm_logger)
endforeach()
4 changes: 0 additions & 4 deletions python/cuvs/cuvs/neighbors/hnsw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,3 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX neighbors_hnsw_
)

foreach(tgt IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
target_link_libraries(${tgt} PRIVATE cuvs_rmm_logger)
endforeach()
4 changes: 0 additions & 4 deletions python/cuvs/cuvs/neighbors/ivf_flat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,3 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX neighbors_ivf_flat_
)

foreach(tgt IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
target_link_libraries(${tgt} PRIVATE cuvs_rmm_logger)
endforeach()
4 changes: 0 additions & 4 deletions python/cuvs/cuvs/neighbors/ivf_pq/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,3 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX neighbors_pq_
)

foreach(tgt IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
target_link_libraries(${tgt} PRIVATE cuvs_rmm_logger)
endforeach()
4 changes: 0 additions & 4 deletions python/cuvs/cuvs/neighbors/nn_descent/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,3 @@ rapids_cython_create_modules(
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX neighbors_nn_descent_
)

foreach(tgt IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
target_link_libraries(${tgt} PRIVATE cuvs_rmm_logger)
endforeach()
4 changes: 0 additions & 4 deletions python/cuvs/cuvs/preprocessing/quantize/scalar/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,3 @@ rapids_cython_create_modules(
LINKED_LIBRARIES "${linked_libraries}" ASSOCIATED_TARGETS cuvs MODULE_PREFIX
preprocessing_quantize_scalar_
)

foreach(tgt IN LISTS RAPIDS_CYTHON_CREATED_TARGETS)
target_link_libraries(${tgt} PRIVATE cuvs_rmm_logger)
endforeach()
Loading

0 comments on commit d09e71e

Please sign in to comment.