Skip to content

Commit

Permalink
Update for raft logger changes (#6187)
Browse files Browse the repository at this point in the history
This PR updates cuml to use raft's updated logger implementation using [rapids-logger](https://github.com/rapidsai/rapids-logger).

This PR requires rapidsai/cuvs#540 (cuml requires both raft and cuvs updates).

Contributes to rapidsai/build-planning#104

Authors:
  - Vyas Ramasubramani (https://github.com/vyasr)

Approvers:
  - Bradley Dice (https://github.com/bdice)

URL: #6187
  • Loading branch information
vyasr authored Dec 31, 2024
1 parent 7731ba2 commit 261edb8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
3 changes: 2 additions & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,8 @@ if(BUILD_CUML_CPP_LIBRARY)
# These are always private:
list(APPEND _cuml_cpp_private_libs
raft::raft
rmm::rmm_logger_impl
raft::raft_logger_impl
$<TARGET_NAME_IF_EXISTS:GPUTreeShap::GPUTreeShap>
$<$<BOOL:${LINK_CUFFT}>:CUDA::cufft${_ctk_fft_static_suffix}>
${TREELITE_LIBS}
Expand Down Expand Up @@ -629,7 +631,6 @@ if(BUILD_CUML_CPP_LIBRARY)
PUBLIC rmm::rmm rmm::rmm_logger ${CUVS_LIB}
${_cuml_cpp_public_libs}
PRIVATE ${_cuml_cpp_private_libs}
rmm::rmm_logger_impl
)

# If we export the libdmlc symbols, they can lead to weird crashes with other
Expand Down
2 changes: 1 addition & 1 deletion cpp/bench/sg/kmeans.cu
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ std::vector<Params> getInputs()
p.kmeans.init = ML::kmeans::KMeansParams::InitMethod(0);
p.kmeans.max_iter = 300;
p.kmeans.tol = 1e-4;
p.kmeans.verbosity = RAFT_LEVEL_INFO;
p.kmeans.verbosity = raft::level_enum::info;
p.kmeans.metric = cuvs::distance::DistanceType::L2Expanded;
p.kmeans.rng_state = raft::random::RngState(p.blobs.seed);
p.kmeans.inertia_check = true;
Expand Down
5 changes: 4 additions & 1 deletion cpp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ function(ConfigureTest)
$<$<BOOL:${LINK_CUFFT}>:CUDA::cufft${_ctk_static_suffix_cufft}>
rmm::rmm
rmm::rmm_logger
rmm::rmm_logger_impl
raft::raft
raft::raft_logger
test_logger_impls
GTest::gtest
GTest::gtest_main
GTest::gmock
Expand Down Expand Up @@ -107,6 +108,8 @@ function(ConfigureTest)

endfunction()

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

##############################################################################
# - build ml_test executable -------------------------------------------------
Expand Down
6 changes: 5 additions & 1 deletion python/cuml/cuml/cluster/kmeans.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ IF GPUBUILD == 1:
from cuml.metrics.distance_type cimport DistanceType
from cuml.cluster.kmeans_utils cimport params as KMeansParams
from cuml.cluster.kmeans_utils cimport KMeansPlusPlus, Random, Array
from cuml.cluster cimport kmeans_utils

# Avoid potential future conflicts with cuml's level enum
ctypedef kmeans_utils.level_enum raft_level_enum

from cuml.internals.array import CumlArray
from cuml.common.array_descriptor import CumlArrayDescriptor
Expand Down Expand Up @@ -205,7 +209,7 @@ class KMeans(UniversalBase,
params.init = self._params_init
params.max_iter = <int>self.max_iter
params.tol = <double>self.tol
params.verbosity = <int>self.verbose
params.verbosity = <raft_level_enum>(<int>self.verbose)
params.rng_state.seed = self.random_state
params.metric = DistanceType.L2Expanded # distance metric as squared L2: @todo - support other metrics # noqa: E501
params.batch_samples = <int>self.max_samples_per_batch
Expand Down
14 changes: 13 additions & 1 deletion python/cuml/cuml/cluster/kmeans_utils.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,26 @@ cdef extern from "cuml/cluster/kmeans.hpp" namespace \
"cuvs::cluster::kmeans::params":
enum InitMethod:
KMeansPlusPlus, Random, Array

cdef extern from "raft/core/logger.hpp" namespace "raft":
cdef enum class level_enum:
trace
debug
info
warn
error
critical
off
n_levels

cdef extern from "cuvs/cluster/kmeans.hpp" namespace \
"cuvs::cluster::kmeans":
cdef struct params:
int n_clusters,
InitMethod init
int max_iter,
double tol,
int verbosity,
level_enum verbosity,
RngState rng_state,
DistanceType metric,
int n_init,
Expand Down

0 comments on commit 261edb8

Please sign in to comment.