Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 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
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ if (! hasArg --configure-only) && (completeBuild || hasArg libcuml || hasArg pri
MSG="${MSG}<br/>parallel setting: $PARALLEL_LEVEL"
MSG="${MSG}<br/>parallel build time: $compile_total seconds"
if [[ -f "${LIBCUML_BUILD_DIR}/libcuml++.so" ]]; then
LIBCUML_FS=$(ls -lh ${LIBCUML_BUILD_DIR}/libcuml++.so | awk '{print $5}')
LIBCUML_FS=$(stat -c %s ${LIBCUML_BUILD_DIR}/libcuml++.so | awk '{printf "%.2f MB", $1/1024/1024}')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice change

MSG="${MSG}<br/>libcuml++.so size: $LIBCUML_FS"
fi
BMR_DIR=${RAPIDS_ARTIFACTS_DIR:-"${LIBCUML_BUILD_DIR}"}
Expand Down
2 changes: 0 additions & 2 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ include(cmake/modules/ConfigureCUDA.cmake)
##############################################################################
# - Set options based on user defined one -----------------------------------
set(CUML_USE_RAFT_NN OFF)
set(CUML_RAFT_COMPILED OFF)
set(LINK_TREELITE OFF)
set(LINK_CUFFT OFF)
include(cmake/modules/ConfigureAlgorithms.cmake)
Expand Down Expand Up @@ -661,7 +660,6 @@ if(BUILD_CUML_CPP_LIBRARY)
# because cumlprims_mg and cuML inherit their CUDA libs from the raft::raft
# INTERFACE target.
list(APPEND ${_cuml_cpp_libs_var_name}
$<$<BOOL:${CUML_RAFT_COMPILED}>:${RAFT_COMPILED_LIB}>
$<TARGET_NAME_IF_EXISTS:cumlprims_mg::cumlprims_mg>
)

Expand Down
7 changes: 0 additions & 7 deletions cpp/cmake/modules/ConfigureAlgorithms.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

if(CUML_ALGORITHMS STREQUAL "ALL")
set(CUML_USE_RAFT_NN ON)
set(CUML_RAFT_COMPILED ON)
set(LINK_TREELITE ON)
set(LINK_CUFFT ON)
set(LINK_CUVS ON)
Expand All @@ -33,7 +32,6 @@ else()
set(BUILD_CUML_BENCH OFF)
set(BUILD_CUML_EXAMPLES OFF)
set(CUML_USE_RAFT_NN OFF)
set(CUML_RAFT_COMPILED OFF)

foreach(algo ${CUML_ALGORITHMS})
string(TOLOWER ${algo} lower_algo)
Expand Down Expand Up @@ -108,7 +106,6 @@ else()

if(knn_algo)
set(CUML_USE_RAFT_NN ON)
set(CUML_RAFT_COMPILED ON)
endif()

if(randomforest_algo)
Expand All @@ -120,10 +117,6 @@ else()
set(metrics_algo ON)
endif()

if(metrics_algo)
set(CUML_RAFT_COMPILED ON)
endif()

if(dbscan_algo OR hdbscan_algo OR kmeans_algo OR knn_algo
OR metrics_algo OR tsne_algo OR umap_algo)
set(LINK_CUVS ON)
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 @@ -41,6 +41,7 @@ function(find_and_configure_raft)
set(RAFT_NVTX ${PKG_NVTX})

message(VERBOSE "CUML: raft FIND_PACKAGE_ARGUMENTS COMPONENTS ${RAFT_COMPONENTS}")
# set(CPM_raft_SOURCE /raid/dgala/raft)
Comment thread
divyegala marked this conversation as resolved.
Outdated

rapids_cpm_find(raft ${PKG_VERSION}
GLOBAL_TARGETS raft::raft
Expand Down Expand Up @@ -79,7 +80,6 @@ find_and_configure_raft(VERSION ${CUML_MIN_VERSION_raft}
# force local raft clone in build directory
# even if it's already installed.
CLONE_ON_PIN ${CUML_RAFT_CLONE_ON_PIN}
COMPILE_LIBRARY ${CUML_RAFT_COMPILED}
USE_RAFT_STATIC ${CUML_USE_RAFT_STATIC}
NVTX ${NVTX}
)
10 changes: 2 additions & 8 deletions cpp/src/dbscan/vertexdeg/algo.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,8 @@ void launcher(const raft::handle_t& handle,
if (metric == cuvs::distance::DistanceType::CosineExpanded) {
rmm::device_uvector<value_t> rowNorms(m, stream);

raft::linalg::rowNorm(rowNorms.data(),
data.x,
k,
m,
raft::linalg::NormType::L2Norm,
true,
stream,
[] __device__(value_t in) { return sqrtf(in); });
raft::linalg::rowNorm<raft::linalg::NormType::L2Norm, true>(
rowNorms.data(), data.x, k, m, stream, [] __device__(value_t in) { return sqrtf(in); });

/* Cast away constness because the output matrix for normalization cannot be of const type.
* Input matrix will be modified due to normalization.
Expand Down
22 changes: 11 additions & 11 deletions cpp/src/genetic/fitness.cuh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2024, NVIDIA CORPORATION.
* Copyright (c) 2021-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.
Expand Down Expand Up @@ -79,7 +79,7 @@ void weightedPearson(const raft::handle_t& h,
math_t N = (math_t)n_samples;

// Sum of weights
raft::stats::sum(dWS.data(), W, (uint64_t)1, n_samples, false, stream);
raft::stats::sum<false>(dWS.data(), W, (uint64_t)1, n_samples, stream);
math_t WS = dWS.value(stream);

// Find y_mu
Expand All @@ -94,7 +94,7 @@ void weightedPearson(const raft::handle_t& h,
[N, WS] __device__(math_t y, math_t w) { return N * w * y / WS; },
stream);

raft::stats::mean(y_mu.data(), y_tmp.data(), (uint64_t)1, n_samples, false, false, stream);
raft::stats::mean<false>(y_mu.data(), y_tmp.data(), (uint64_t)1, n_samples, false, stream);

// Find x_mu
raft::linalg::matrixVectorOp(
Expand All @@ -108,7 +108,7 @@ void weightedPearson(const raft::handle_t& h,
[N, WS] __device__(math_t x, math_t w) { return N * w * x / WS; },
stream);

raft::stats::mean(x_mu.data(), x_tmp.data(), n_progs, n_samples, false, false, stream);
raft::stats::mean<false>(x_mu.data(), x_tmp.data(), n_progs, n_samples, false, stream);

// Find y_diff
raft::stats::meanCenter(
Expand Down Expand Up @@ -169,7 +169,7 @@ void weightedPearson(const raft::handle_t& h,
[] __device__(math_t c, math_t xd) { return c / xd; },
stream);

raft::stats::mean(out, corr.data(), n_progs, n_samples, false, false, stream);
raft::stats::mean<false>(out, corr.data(), n_progs, n_samples, false, stream);
}

struct rank_functor {
Expand Down Expand Up @@ -261,7 +261,7 @@ void meanAbsoluteError(const raft::handle_t& h,
math_t N = (math_t)n_samples;

// Weight Sum
raft::stats::sum(dWS.data(), W, (uint64_t)1, n_samples, false, stream);
raft::stats::sum<false>(dWS.data(), W, (uint64_t)1, n_samples, stream);
math_t WS = dWS.value(stream);

// Compute absolute differences
Expand All @@ -278,7 +278,7 @@ void meanAbsoluteError(const raft::handle_t& h,
stream);

// Average along rows
raft::stats::mean(out, error.data(), n_progs, n_samples, false, false, stream);
raft::stats::mean<false>(out, error.data(), n_progs, n_samples, false, stream);
}

template <typename math_t = float>
Expand All @@ -296,7 +296,7 @@ void meanSquareError(const raft::handle_t& h,
math_t N = (math_t)n_samples;

// Weight Sum
raft::stats::sum(dWS.data(), W, (uint64_t)1, n_samples, false, stream);
raft::stats::sum<false>(dWS.data(), W, (uint64_t)1, n_samples, stream);
math_t WS = dWS.value(stream);

// Compute square differences
Expand All @@ -315,7 +315,7 @@ void meanSquareError(const raft::handle_t& h,
stream);

// Add up row values per column
raft::stats::mean(out, error.data(), n_progs, n_samples, false, false, stream);
raft::stats::mean<false>(out, error.data(), n_progs, n_samples, false, stream);
}

template <typename math_t = float>
Expand Down Expand Up @@ -352,7 +352,7 @@ void logLoss(const raft::handle_t& h,
math_t N = (math_t)n_samples;

// Weight Sum
raft::stats::sum(dWS.data(), W, (uint64_t)1, n_samples, false, stream);
raft::stats::sum<false>(dWS.data(), W, (uint64_t)1, n_samples, stream);
math_t WS = dWS.value(stream);

// Compute logistic loss as described in
Expand Down Expand Up @@ -383,7 +383,7 @@ void logLoss(const raft::handle_t& h,
stream);

// Take average along rows
raft::stats::mean(out, error.data(), n_progs, n_samples, false, false, stream);
raft::stats::mean<false>(out, error.data(), n_progs, n_samples, false, stream);
}

} // namespace genetic
Expand Down
26 changes: 11 additions & 15 deletions cpp/src/glm/preprocess.cuh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2024, NVIDIA CORPORATION.
* Copyright (c) 2018-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.
Expand Down Expand Up @@ -93,31 +93,27 @@ void preProcessData(const raft::handle_t& handle,
norm2_input);
} else {
if (sample_weight != nullptr) {
raft::stats::weightedMean(
mu_input, input, sample_weight, n_cols, n_rows, false, false, stream);
raft::stats::weightedMean<false, false>(
mu_input, input, sample_weight, n_cols, n_rows, stream);
} else {
raft::stats::mean(mu_input, input, n_cols, n_rows, false, false, stream);
raft::stats::mean<false>(mu_input, input, n_cols, n_rows, false, stream);
}
raft::stats::meanCenter(input, input, mu_input, n_cols, n_rows, false, true, stream);
if (normalize) {
raft::linalg::colNorm(norm2_input,
input,
n_cols,
n_rows,
raft::linalg::L2Norm,
false,
stream,
[] __device__(math_t v) { return raft::sqrt(v); });
raft::linalg::colNorm<raft::linalg::NormType::L2Norm, false>(
norm2_input, input, n_cols, n_rows, stream, [] __device__(math_t v) {
return raft::sqrt(v);
});
raft::matrix::matrixVectorBinaryDivSkipZero(
input, norm2_input, n_rows, n_cols, false, true, stream, true);
}
}

if (sample_weight != nullptr) {
raft::stats::weightedMean(
mu_labels, labels, sample_weight, (size_t)1, n_rows, true, false, stream);
raft::stats::weightedMean<true, false>(
mu_labels, labels, sample_weight, (size_t)1, n_rows, stream);
} else {
raft::stats::mean(mu_labels, labels, (size_t)1, n_rows, false, false, stream);
raft::stats::mean<false>(mu_labels, labels, (size_t)1, n_rows, false, stream);
}
raft::stats::meanCenter(labels, labels, mu_labels, (size_t)1, n_rows, false, true, stream);
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/glm/qn/glm_base.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ inline void linearBwd(const raft::handle_t& handle,

// TODO can this be fused somehow?
Gweights.assign_gemm(handle, 1.0 / X.m, dZ, false, X, false, beta, stream);
raft::stats::mean(Gbias.data, dZ.data, dZ.m, dZ.n, false, true, stream);
raft::stats::mean<true>(Gbias.data, dZ.data, dZ.m, dZ.n, false, stream);
} else {
G.assign_gemm(handle, 1.0 / X.m, dZ, false, X, false, beta, stream);
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/glm/qn/mg/glm_base_mg.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ inline void linearBwdMG(const raft::handle_t& handle,
// TODO can this be fused somehow?
Gweights.assign_gemm(handle, 1.0 / n_samples, dZ, false, X, false, beta / n_ranks, stream);

raft::stats::mean(Gbias.data, dZ.data, dZ.m, dZ.n, false, true, stream);
raft::stats::mean<true>(Gbias.data, dZ.data, dZ.m, dZ.n, false, stream);
T bias_factor = 1.0 * dZ.n / n_samples;
raft::linalg::multiplyScalar(Gbias.data, Gbias.data, bias_factor, dZ.m, stream);

Expand Down
12 changes: 10 additions & 2 deletions cpp/src/glm/qn/mg/standardization.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ void vars(const raft::handle_t& handle,
zero_vec.fill(0., stream);

// get sum of squares on every column
raft::stats::vars(var_vector, input_data, zero.data(), D, num_rows, false, !col_major, stream);
if (col_major) {
raft::stats::vars<false>(var_vector, input_data, zero.data(), D, num_rows, false, stream);
} else {
raft::stats::vars<true>(var_vector, input_data, zero.data(), D, num_rows, false, stream);
}
T weight = n_samples < 1 ? T(0) : T(1) * num_rows / T(n_samples - 1);
raft::linalg::multiplyScalar(var_vector, var_vector, weight, D, stream);
comm.allreduce(var_vector, var_vector, D, raft::comms::op_t::SUM, stream);
Expand Down Expand Up @@ -107,7 +111,11 @@ void mean_stddev(const raft::handle_t& handle,
auto stream = handle.get_stream();
auto& comm = handle.get_comms();

raft::stats::sum(mean_vector, input_data, D, num_rows, !col_major, stream);
if (col_major) {
raft::stats::sum<false>(mean_vector, input_data, D, num_rows, stream);
} else {
raft::stats::sum<true>(mean_vector, input_data, D, num_rows, stream);
}
T weight = T(1) / T(n_samples);
raft::linalg::multiplyScalar(mean_vector, mean_vector, weight, D, stream);
comm.allreduce(mean_vector, mean_vector, D, raft::comms::op_t::SUM, stream);
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/glm/qn/simple_mat/dense.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2024, NVIDIA CORPORATION.
* Copyright (c) 2018-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.
Expand Down Expand Up @@ -323,8 +323,8 @@ inline T nrm2(const SimpleVec<T>& u, T* tmp_dev, cudaStream_t stream)
template <typename T>
inline T nrm1(const SimpleVec<T>& u, T* tmp_dev, cudaStream_t stream)
{
raft::linalg::rowNorm(
tmp_dev, u.data, u.len, 1, raft::linalg::L1Norm, true, stream, raft::Nop<T>());
raft::linalg::rowNorm<raft::linalg::NormType::L1Norm, true>(
tmp_dev, u.data, u.len, 1, stream, raft::Nop<T>());
T tmp_host;
raft::update_host(&tmp_host, tmp_dev, 1, stream);
raft::interruptible::synchronize(stream);
Expand Down
13 changes: 5 additions & 8 deletions cpp/src/hdbscan/detail/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ void normalize(value_t* data, value_idx n, size_t m, cudaStream_t stream)
rmm::device_uvector<value_t> sums(m, stream);

// Compute row sums
raft::linalg::rowNorm<value_t, size_t>(
sums.data(), data, (size_t)n, m, raft::linalg::L1Norm, true, stream);
raft::linalg::rowNorm<raft::linalg::NormType::L1Norm, true, value_t, size_t>(
sums.data(), data, (size_t)n, m, stream);

// Divide vector by row sums (modify in place)
raft::linalg::matrixVectorOp(
Expand Down Expand Up @@ -229,18 +229,15 @@ void softmax(const raft::handle_t& handle, value_t* data, value_idx n, size_t m)
raft::make_device_vector_view<const value_t, value_idx>(linf_norm.data(), (int)m);
auto linf_norm_view = raft::make_device_vector_view<value_t, value_idx>(linf_norm.data(), (int)m);

raft::linalg::norm(handle,
data_const_view,
linf_norm_view,
raft::linalg::LinfNorm,
raft::linalg::Apply::ALONG_ROWS);
raft::linalg::norm<raft::linalg::NormType::LinfNorm, raft::Apply::ALONG_ROWS>(
handle, data_const_view, linf_norm_view);

raft::linalg::matrix_vector_op(
handle,
data_const_view,
linf_norm_const_view,
data_view,
raft::linalg::Apply::ALONG_COLUMNS,
raft::Apply::ALONG_COLUMNS,
[] __device__(value_t mat_in, value_t vec_in) { return exp(mat_in - vec_in); });
}

Expand Down
15 changes: 7 additions & 8 deletions cpp/src/pca/pca.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,12 @@ void truncCompExpVars(const raft::handle_t& handle,
// Compute the scalar noise_vars defined as (pseudocode)
// (n_components < min(n_cols, n_rows)) ? explained_var_all[n_components:].mean() : 0
if (prms.n_components < prms.n_cols && prms.n_components < prms.n_rows) {
raft::stats::mean(noise_vars,
explained_var_all.data() + prms.n_components,
std::size_t{1},
prms.n_cols - prms.n_components,
false,
true,
stream);
raft::stats::mean<true>(noise_vars,
explained_var_all.data() + prms.n_components,
std::size_t{1},
prms.n_cols - prms.n_components,
false,
stream);
} else {
raft::matrix::setValue(noise_vars, noise_vars, math_t{0}, 1, stream);
}
Expand Down Expand Up @@ -123,7 +122,7 @@ void pcaFit(const raft::handle_t& handle,
auto n_components = prms.n_components;
if (n_components > prms.n_cols) n_components = prms.n_cols;

raft::stats::mean(mu, input, prms.n_cols, prms.n_rows, false, false, stream);
raft::stats::mean<false>(mu, input, prms.n_cols, prms.n_rows, false, stream);

auto len = prms.n_cols * prms.n_cols;
rmm::device_uvector<math_t> cov(len, stream);
Expand Down
13 changes: 6 additions & 7 deletions cpp/src/pca/pca_mg.cu
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,12 @@ void fit_impl(raft::handle_t& handle,
// Compute the scalar noise_vars defined as (pseudocode)
// (n_components < min(n_cols, n_rows)) ? explained_var_all[n_components:].mean() : 0
if (prms.n_components < prms.n_cols && prms.n_components < prms.n_rows) {
raft::stats::mean(noise_vars,
explained_var_all.data() + prms.n_components,
std::size_t{1},
prms.n_cols - prms.n_components,
false,
true,
stream);
raft::stats::mean<true>(noise_vars,
explained_var_all.data() + prms.n_components,
std::size_t{1},
prms.n_cols - prms.n_components,
false,
stream);
} else {
raft::matrix::setValue(noise_vars, noise_vars, T{0}, 1, stream);
}
Expand Down
Loading
Loading