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

Use new rapids-logger library #2566

Merged
merged 19 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 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/libraft
RAPIDS_PACKAGE_VERSION=$(rapids-generate-version) rapids-conda-retry mambabuild \
conda/recipes/libraft

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 @@ -28,6 +28,7 @@ EXCLUDE_ARGS=(
--exclude "libcusolver.so.*"
--exclude "libcusparse.so.*"
--exclude "libnvJitLink.so.*"
--exclude "librapids_logger.so"
vyasr marked this conversation as resolved.
Show resolved Hide resolved
--exclude "libucp.so.*"
)

Expand Down
2 changes: 1 addition & 1 deletion conda/environments/all_cuda-118_arch-aarch64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ dependencies:
- pytest==7.*
- rapids-build-backend>=0.3.0,<0.4.0.dev0
- rapids-dask-dependency==25.4.*,>=0.0.0a0
- rapids-logger==0.1.*,>=0.0.0a0
- recommonmark
- rmm==25.4.*,>=0.0.0a0
- scikit-build-core>=0.10.0
- scikit-learn
- scipy
- spdlog>=1.14.1,<1.15
- sphinx-copybutton
- sphinx-markdown-tables
- sysroot_linux-aarch64==2.28
Expand Down
2 changes: 1 addition & 1 deletion conda/environments/all_cuda-118_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ dependencies:
- pytest==7.*
- rapids-build-backend>=0.3.0,<0.4.0.dev0
- rapids-dask-dependency==25.4.*,>=0.0.0a0
- rapids-logger==0.1.*,>=0.0.0a0
- recommonmark
- rmm==25.4.*,>=0.0.0a0
- scikit-build-core>=0.10.0
- scikit-learn
- scipy
- spdlog>=1.14.1,<1.15
- sphinx-copybutton
- sphinx-markdown-tables
- sysroot_linux-64==2.28
Expand Down
2 changes: 1 addition & 1 deletion conda/environments/all_cuda-128_arch-aarch64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ dependencies:
- pytest==7.*
- rapids-build-backend>=0.3.0,<0.4.0.dev0
- rapids-dask-dependency==25.4.*,>=0.0.0a0
- rapids-logger==0.1.*,>=0.0.0a0
- recommonmark
- rmm==25.4.*,>=0.0.0a0
- scikit-build-core>=0.10.0
- scikit-learn
- scipy
- spdlog>=1.14.1,<1.15
- sphinx-copybutton
- sphinx-markdown-tables
- sysroot_linux-aarch64==2.28
Expand Down
2 changes: 1 addition & 1 deletion conda/environments/all_cuda-128_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ dependencies:
- pytest==7.*
- rapids-build-backend>=0.3.0,<0.4.0.dev0
- rapids-dask-dependency==25.4.*,>=0.0.0a0
- rapids-logger==0.1.*,>=0.0.0a0
- recommonmark
- rmm==25.4.*,>=0.0.0a0
- scikit-build-core>=0.10.0
- scikit-learn
- scipy
- spdlog>=1.14.1,<1.15
- sphinx-copybutton
- sphinx-markdown-tables
- sysroot_linux-64==2.28
Expand Down
6 changes: 0 additions & 6 deletions conda/recipes/libraft/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,3 @@ cuda11_cuda_profiler_api_host_version:

cuda11_cuda_profiler_api_run_version:
- ">=11.4.240,<12"

spdlog_version:
- ">=1.14.1,<1.15"

fmt_version:
- ">=11.0.2,<12"
4 changes: 2 additions & 2 deletions conda/recipes/libraft/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ outputs:
- cuda-cudart-dev
{% endif %}
- librmm ={{ minor_version }}
- rapids-logger =0.1
run:
- {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }}
{% if cuda_major == "11" %}
Expand All @@ -71,8 +72,7 @@ outputs:
- cuda-cudart
{% endif %}
- librmm ={{ minor_version }}
- spdlog {{ spdlog_version }}
- fmt {{ fmt_version }}
- rapids-logger =0.1
about:
home: https://rapids.ai/
license: Apache-2.0
Expand Down
23 changes: 9 additions & 14 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ include(cmake/modules/ConfigureCUDA.cmake)
rapids_cpm_init()

include(${rapids-cmake-dir}/cpm/rapids_logger.cmake)
rapids_cpm_rapids_logger()
rapids_make_logger(raft LOGGER_HEADER_DIR include/raft/core EXPORT_SET raft-exports)
rapids_cpm_rapids_logger(BUILD_EXPORT_SET raft-exports INSTALL_EXPORT_SET raft-exports)
create_logger_macros(RAFT "raft::default_logger()" include/raft/core)

# CCCL before rmm/cuco so we get the right version of CCCL
include(cmake/thirdparty/get_cccl.cmake)
Expand All @@ -194,13 +194,14 @@ add_library(raft INTERFACE)
add_library(raft::raft ALIAS raft)

target_include_directories(
raft INTERFACE "$<BUILD_INTERFACE:${RAFT_SOURCE_DIR}/include>" "$<INSTALL_INTERFACE:include>"
raft INTERFACE "$<BUILD_INTERFACE:${RAFT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${RAFT_BINARY_DIR}/include>" "$<INSTALL_INTERFACE:include>"
)

# Keep RAFT as lightweight as possible. Only CUDA libs and rmm should be used in global target.
target_link_libraries(
raft INTERFACE rmm::rmm rmm::rmm_logger spdlog::spdlog_header_only cuco::cuco
nvidia::cutlass::cutlass CCCL::CCCL raft_logger
raft INTERFACE rapids_logger::rapids_logger rmm::rmm cuco::cuco nvidia::cutlass::cutlass
CCCL::CCCL
)

target_compile_features(raft INTERFACE cxx_std_17 $<BUILD_INTERFACE:cuda_std_17>)
Expand All @@ -209,7 +210,7 @@ target_compile_options(
--expt-relaxed-constexpr>
)
target_compile_definitions(
raft INTERFACE "RAFT_LOG_ACTIVE_LEVEL=RAFT_LOG_LEVEL_${LIBRAFT_LOGGING_LEVEL}"
raft INTERFACE "RAFT_LOG_ACTIVE_LEVEL=RAPIDS_LOGGER_LOG_LEVEL_${LIBRAFT_LOGGING_LEVEL}"
)

set(RAFT_CUSOLVER_DEPENDENCY CUDA::cusolver${_ctk_static_suffix})
Expand Down Expand Up @@ -311,13 +312,11 @@ if(RAFT_COMPILE_LIBRARY)
"$<$<COMPILE_LANGUAGE:CUDA>:${RAFT_CUDA_FLAGS}>"
)

# Make sure not to add the rmm logger twice since it will be brought in as an interface source by
# the rmm::rmm_logger_impl target.
add_library(raft_lib SHARED $<FILTER:$<TARGET_OBJECTS:raft_objs>,EXCLUDE,rmm.*logger>)
add_library(raft_lib SHARED $<TARGET_OBJECTS:raft_objs>)

set(_raft_lib_targets raft_lib)
if(NOT RAFT_COMPILE_DYNAMIC_ONLY)
add_library(raft_lib_static STATIC $<FILTER:$<TARGET_OBJECTS:raft_objs>,EXCLUDE,rmm.*logger>)
add_library(raft_lib_static STATIC $<TARGET_OBJECTS:raft_objs>)
list(APPEND _raft_lib_targets raft_lib_static)
endif()

Expand All @@ -344,10 +343,6 @@ if(RAFT_COMPILE_LIBRARY)
# ensure CUDA symbols aren't relocated to the middle of the debug build binaries
target_link_options(${target} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/fatbin.ld")
endforeach()
target_link_libraries(raft_lib PRIVATE rmm::rmm_logger_impl raft_logger_impl)
if(NOT RAFT_COMPILE_DYNAMIC_ONLY)
target_link_libraries(raft_lib_static PRIVATE rmm::rmm_logger_impl raft_logger_impl)
endif()
endif()

if(TARGET raft_lib AND (NOT TARGET raft::raft_lib))
Expand Down
4 changes: 0 additions & 4 deletions cpp/bench/prims/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ function(ConfigureBench)
PRIVATE raft::raft
raft_internal
$<$<BOOL:${ConfigureBench_LIB}>:raft::compiled>
$<$<NOT:$<BOOL:${ConfigureBench_LIB}>>:bench_rmm_logger>
${RAFT_CTK_MATH_DEPENDENCIES}
benchmark::benchmark
Threads::Threads
Expand Down Expand Up @@ -74,9 +73,6 @@ function(ConfigureBench)

endfunction()

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

if(BUILD_PRIMS_BENCH)
ConfigureBench(NAME CORE_BENCH PATH core/bitset.cu core/copy.cu main.cpp)

Expand Down
24 changes: 0 additions & 24 deletions cpp/cmake/thirdparty/get_spdlog.cmake

This file was deleted.

1 change: 0 additions & 1 deletion cpp/include/raft/cluster/detail/kmeans_balanced.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <raft/cluster/kmeans_balanced_types.hpp>
#include <raft/common/nvtx.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
5 changes: 3 additions & 2 deletions cpp/include/raft/cluster/kmeans_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
* limitations under the License.
*/
#pragma once
#include <raft/core/logger.hpp>
#include <raft/distance/distance_types.hpp>
#include <raft/random/rng_state.hpp>

#include <rapids_logger/logger.hpp>

namespace raft::cluster {

/** Base structure for parameters that are common to all k-means algorithms */
Expand Down Expand Up @@ -82,7 +83,7 @@ struct KMeansParams : kmeans_base_params {
/**
* verbosity level.
*/
level_enum verbosity = level_enum::info;
rapids_logger::level_enum verbosity = rapids_logger::level_enum::info;

/**
* Seed to the random number generator.
Expand Down
31 changes: 0 additions & 31 deletions cpp/include/raft/core/logger-macros.hpp

This file was deleted.

78 changes: 78 additions & 0 deletions cpp/include/raft/core/logger.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright (c) 2025, 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.
*/

#pragma once

#include <raft/core/logger_macros.hpp>

#include <rapids_logger/logger.hpp>

#include <sstream>

namespace raft {

/**
* @brief Returns the default sink for the global logger.
*
* If the environment variable `RAFT_DEBUG_LOG_FILE` is defined, the default sink is a sink to that
* file. Otherwise, the default is to dump to stderr.
*
* @return sink_ptr The sink to use
*/
inline rapids_logger::sink_ptr default_sink()
{
auto* filename = std::getenv("RAFT_DEBUG_LOG_FILE");
if (filename != nullptr) {
return std::make_shared<rapids_logger::basic_file_sink_mt>(filename, true);
}
return std::make_shared<rapids_logger::stderr_sink_mt>();
}

/**
* @brief Returns the default log pattern for the global logger.
*
* @return std::string The default log pattern.
*/
inline std::string default_pattern() { return "[%6t][%H:%M:%S:%f][%-6l] %v"; }

/**
* @brief Get the default logger.
*
* @return logger& The default logger
*/
inline rapids_logger::logger& default_logger()
{
static rapids_logger::logger logger_ = [] {
rapids_logger::logger logger_{"RAFT", {default_sink()}};
logger_.set_pattern(default_pattern());
return logger_;
}();
return logger_;
}

} // namespace raft

#if (RAFT_LOG_ACTIVE_LEVEL <= RAPIDS_LOGGER_LOG_LEVEL_TRACE)
#define RAFT_LOG_TRACE_VEC(ptr, len) \
do { \
std::stringstream ss; \
ss << raft::detail::format("%s:%d ", __FILE__, __LINE__); \
print_vector(#ptr, ptr, len, ss); \
raft::default_logger().log(RAPIDS_LOGGER_LOG_LEVEL_TRACE, ss.str().c_str()); \
} while (0)
#else
#define RAFT_LOG_TRACE_VEC(ptr, len) void(0)
#endif
1 change: 0 additions & 1 deletion cpp/include/raft/neighbors/detail/ivf_flat_build.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#pragma once

#include <raft/cluster/kmeans_balanced.cuh>
#include <raft/core/logger-macros.hpp>
#include <raft/core/logger.hpp>
#include <raft/core/mdarray.hpp>
#include <raft/core/nvtx.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#pragma once

#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
6 changes: 0 additions & 6 deletions cpp/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ function(ConfigureTest)
${RAFT_CTK_MATH_DEPENDENCIES}
$<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX>
$<TARGET_NAME_IF_EXISTS:conda_env>
raft_test_logger
)
set_target_properties(
${TEST_NAME}
Expand Down Expand Up @@ -88,10 +87,6 @@ function(ConfigureTest)
)
endfunction()

# Create an object library for the logger so that we don't have to recompile it.
add_library(raft_test_logger OBJECT)
target_link_libraries(raft_test_logger PRIVATE raft_logger_impl)

# ##################################################################################################
# test sources ##################################################################################
# ##################################################################################################
Expand All @@ -104,7 +99,6 @@ if(BUILD_TESTS)
core/bitset.cu
core/device_resources_manager.cpp
core/device_setter.cpp
core/logger.cpp
core/math_device.cu
core/math_host.cpp
core/operators_device.cu
Expand Down
Loading