From fe6c1c5f5d215a24b112a9ea1770e253b8012ff7 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 11 Feb 2025 03:43:06 -0800 Subject: [PATCH] Use new rapids-logger library (#644) Contributes to https://github.com/rapidsai/build-planning/issues/104. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Corey J. Nolet (https://github.com/cjnolet) - Bradley Dice (https://github.com/bdice) - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/cuvs/pull/644 --- ci/build_cpp.sh | 3 +- ci/build_wheel.sh | 1 + .../cuvs-bench-cpu/conda_build_config.yaml | 6 -- conda/recipes/cuvs-bench-cpu/meta.yaml | 2 - cpp/CMakeLists.txt | 12 ++-- cpp/bench/ann/CMakeLists.txt | 20 +------ cpp/cmake/thirdparty/get_raft.cmake | 2 +- cpp/include/cuvs/cluster/kmeans.hpp | 3 +- cpp/src/cluster/detail/kmeans_balanced.cuh | 1 - cpp/src/neighbors/ivf_flat/ivf_flat_build.cuh | 1 - .../neighbors/ivf_flat/ivf_flat_search.cuh | 1 - cpp/tests/CMakeLists.txt | 4 -- dependencies.yaml | 1 + docs/source/developer_guide.md | 55 ------------------- examples/cpp/CMakeLists.txt | 25 ++------- python/cuvs/CMakeLists.txt | 3 - python/cuvs/cuvs/common/CMakeLists.txt | 4 -- python/cuvs/cuvs/distance/CMakeLists.txt | 4 -- python/cuvs/cuvs/neighbors/CMakeLists.txt | 4 -- .../cuvs/neighbors/brute_force/CMakeLists.txt | 4 -- .../cuvs/cuvs/neighbors/cagra/CMakeLists.txt | 4 -- .../cuvs/neighbors/filters/CMakeLists.txt | 4 -- .../cuvs/cuvs/neighbors/hnsw/CMakeLists.txt | 4 -- .../cuvs/neighbors/ivf_flat/CMakeLists.txt | 4 -- .../cuvs/cuvs/neighbors/ivf_pq/CMakeLists.txt | 4 -- .../cuvs/neighbors/nn_descent/CMakeLists.txt | 4 -- .../quantize/scalar/CMakeLists.txt | 4 -- python/libcuvs/libcuvs/load.py | 17 +++--- python/libcuvs/pyproject.toml | 1 + 29 files changed, 28 insertions(+), 174 deletions(-) diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index db4c496cc..d0344061b 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -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 diff --git a/ci/build_wheel.sh b/ci/build_wheel.sh index f3b68c0b1..2c0040cfd 100755 --- a/ci/build_wheel.sh +++ b/ci/build_wheel.sh @@ -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 diff --git a/conda/recipes/cuvs-bench-cpu/conda_build_config.yaml b/conda/recipes/cuvs-bench-cpu/conda_build_config.yaml index 5407d7c17..74f45d911 100644 --- a/conda/recipes/cuvs-bench-cpu/conda_build_config.yaml +++ b/conda/recipes/cuvs-bench-cpu/conda_build_config.yaml @@ -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" diff --git a/conda/recipes/cuvs-bench-cpu/meta.yaml b/conda/recipes/cuvs-bench-cpu/meta.yaml index 016df56be..30c5a6b52 100644 --- a/conda/recipes/cuvs-bench-cpu/meta.yaml +++ b/conda/recipes/cuvs-bench-cpu/meta.yaml @@ -45,13 +45,11 @@ requirements: host: - benchmark - - fmt {{ fmt_version }} - glog {{ glog_version }} - nlohmann_json {{ nlohmann_json_version }} - openblas - python - rapids-build-backend>=0.3.0,<0.4.0.dev0 - - spdlog {{ spdlog_version }} run: - benchmark diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index fb33c1ab7..e73478fb9 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -495,16 +495,14 @@ if(BUILD_SHARED_LIBS) "$<$:${CUVS_CUDA_FLAGS}>" ) target_link_libraries( - cuvs_objs - PUBLIC raft::raft rmm::rmm rmm::rmm_logger ${CUVS_CTK_MATH_DEPENDENCIES} - $ - PRIVATE rmm::rmm_logger_impl raft::raft_logger_impl + cuvs_objs PUBLIC raft::raft rmm::rmm ${CUVS_CTK_MATH_DEPENDENCIES} + $ ) - add_library(cuvs SHARED $,EXCLUDE,rmm.*logger>) + add_library(cuvs SHARED $) if(NOT CUVS_COMPILE_DYNAMIC_ONLY) - add_library(cuvs_static STATIC $,EXCLUDE,rmm.*logger>) + add_library(cuvs_static STATIC $) endif() target_compile_options( @@ -726,7 +724,7 @@ target_compile_definitions(cuvs::cuvs INTERFACE $<$: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 diff --git a/cpp/bench/ann/CMakeLists.txt b/cpp/bench/ann/CMakeLists.txt index 1ec9eeb9f..fff2daa75 100644 --- a/cpp/bench/ann/CMakeLists.txt +++ b/cpp/bench/ann/CMakeLists.txt @@ -127,11 +127,9 @@ function(ConfigureAnnBench) PRIVATE ${ConfigureAnnBench_LINKS} nlohmann_json::nlohmann_json Threads::Threads - $ $<$:CUDA::cudart_static> $ $ - $ ) set_target_properties( @@ -177,13 +175,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 $ - ) -endif() - # ################################################################################################## # * Configure benchmark targets ------------------------------------------------------------- @@ -316,15 +307,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 - $<$:CUDA::nvtx3> - cuvs_bench_logger + ANN_BENCH PRIVATE raft::raft nlohmann_json::nlohmann_json benchmark::benchmark dl + $<$:CUDA::nvtx3> ) set_target_properties( ANN_BENCH diff --git a/cpp/cmake/thirdparty/get_raft.cmake b/cpp/cmake/thirdparty/get_raft.cmake index 3c352b693..a71dc4cb4 100644 --- a/cpp/cmake/thirdparty/get_raft.cmake +++ b/cpp/cmake/thirdparty/get_raft.cmake @@ -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} diff --git a/cpp/include/cuvs/cluster/kmeans.hpp b/cpp/include/cuvs/cluster/kmeans.hpp index cb8d36b10..64ac813ab 100644 --- a/cpp/include/cuvs/cluster/kmeans.hpp +++ b/cpp/include/cuvs/cluster/kmeans.hpp @@ -20,6 +20,7 @@ #include #include #include +#include namespace cuvs::cluster::kmeans { @@ -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. diff --git a/cpp/src/cluster/detail/kmeans_balanced.cuh b/cpp/src/cluster/detail/kmeans_balanced.cuh index ba4cabbde..89d8b05a3 100644 --- a/cpp/src/cluster/detail/kmeans_balanced.cuh +++ b/cpp/src/cluster/detail/kmeans_balanced.cuh @@ -25,7 +25,6 @@ #include #include -#include #include #include #include diff --git a/cpp/src/neighbors/ivf_flat/ivf_flat_build.cuh b/cpp/src/neighbors/ivf_flat/ivf_flat_build.cuh index f594343c7..2a4f1ab92 100644 --- a/cpp/src/neighbors/ivf_flat/ivf_flat_build.cuh +++ b/cpp/src/neighbors/ivf_flat/ivf_flat_build.cuh @@ -27,7 +27,6 @@ #include "../../cluster/kmeans_balanced.cuh" #include "../detail/ann_utils.cuh" #include -#include #include #include #include diff --git a/cpp/src/neighbors/ivf_flat/ivf_flat_search.cuh b/cpp/src/neighbors/ivf_flat/ivf_flat_search.cuh index 2df6f4f0e..b7ecdf438 100644 --- a/cpp/src/neighbors/ivf_flat/ivf_flat_search.cuh +++ b/cpp/src/neighbors/ivf_flat/ivf_flat_search.cuh @@ -27,7 +27,6 @@ #include // is_min_close, DistanceType #include // cuvs::selection::select_k #include -#include #include #include #include // raft::resources diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index cea4e0ce6..2a352b875 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -49,7 +49,6 @@ function(ConfigureTest) PRIVATE cuvs cuvs::cuvs raft::raft - test_rmm_logger GTest::gtest GTest::gtest_main Threads::Threads @@ -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 ################################################################################## # ################################################################################################## diff --git a/dependencies.yaml b/dependencies.yaml index eabfd1ca6..1a0c64e2d 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -106,6 +106,7 @@ files: includes: - cuda_wheels - depends_on_libraft + - depends_on_librmm py_build_cuvs: output: pyproject pyproject_dir: python/cuvs diff --git a/docs/source/developer_guide.md b/docs/source/developer_guide.md index 5ba0d77de..a8da506b5 100644 --- a/docs/source/developer_guide.md +++ b/docs/source/developer_guide.md @@ -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 - -// 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`. diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt index 6bf8f3408..96414534c 100644 --- a/examples/cpp/CMakeLists.txt +++ b/examples/cpp/CMakeLists.txt @@ -46,29 +46,14 @@ add_executable(VAMANA_EXAMPLE src/vamana_example.cu) # `$` 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 $ rmm_logger -) -target_link_libraries( - CAGRA_EXAMPLE PRIVATE cuvs::cuvs $ rmm_logger -) +target_link_libraries(BRUTE_FORCE_EXAMPLE PRIVATE cuvs::cuvs $) +target_link_libraries(CAGRA_EXAMPLE PRIVATE cuvs::cuvs $) target_link_libraries( CAGRA_PERSISTENT_EXAMPLE PRIVATE cuvs::cuvs $ Threads::Threads - rmm_logger ) target_link_libraries( DYNAMIC_BATCHING_EXAMPLE PRIVATE cuvs::cuvs $ Threads::Threads - rmm_logger -) -target_link_libraries( - IVF_PQ_EXAMPLE PRIVATE cuvs::cuvs $ rmm_logger -) -target_link_libraries( - IVF_FLAT_EXAMPLE PRIVATE cuvs::cuvs $ rmm_logger -) -target_link_libraries( - VAMANA_EXAMPLE PRIVATE cuvs::cuvs $ rmm_logger ) +target_link_libraries(IVF_PQ_EXAMPLE PRIVATE cuvs::cuvs $) +target_link_libraries(IVF_FLAT_EXAMPLE PRIVATE cuvs::cuvs $) +target_link_libraries(VAMANA_EXAMPLE PRIVATE cuvs::cuvs $) diff --git a/python/cuvs/CMakeLists.txt b/python/cuvs/CMakeLists.txt index 465a2ba8a..93946cfdb 100644 --- a/python/cuvs/CMakeLists.txt +++ b/python/cuvs/CMakeLists.txt @@ -56,9 +56,6 @@ target_include_directories(cuvs::cuvs INTERFACE "$=0.0.0a0", + "librmm==25.4.*,>=0.0.0a0", "nvidia-cublas", "nvidia-curand", "nvidia-cusolver",