From 18f0d9c97af117c2ed91f481d350294a3ed0c3b6 Mon Sep 17 00:00:00 2001 From: tarangj Date: Mon, 20 Jul 2026 10:27:51 -0700 Subject: [PATCH 1/3] rename param --- c/include/cuvs/cluster/kmeans.h | 8 ++-- c/src/cluster/kmeans.cpp | 8 ++-- c/src/cluster/mg_kmeans.cpp | 2 +- c/tests/cluster/kmeans_c.cu | 6 +-- c/tests/cluster/kmeans_mg_c.cu | 2 +- cpp/include/cuvs/cluster/kmeans.hpp | 16 +++---- cpp/src/cluster/detail/kmeans.cuh | 30 ++++++------ cpp/src/cluster/detail/kmeans_mg.cuh | 22 ++++----- .../cluster/detail/kmeans_mg_batched_init.cuh | 2 +- cpp/tests/cluster/kmeans.cu | 24 +++++----- cpp/tests/cluster/kmeans_mg.cu | 18 +++---- cpp/tests/cluster/kmeans_mnmg.cu | 48 +++++++++---------- fern/pages/c_api/c-api-cluster-kmeans.md | 10 ++-- fern/pages/cluster/kmeans.md | 8 ++-- fern/pages/cpp_api/cpp-api-cluster-kmeans.md | 10 ++-- .../python_api/python-api-cluster-kmeans.md | 18 +++---- python/cuvs/cuvs/cluster/kmeans/kmeans.pxd | 4 +- python/cuvs/cuvs/cluster/kmeans/kmeans.pyx | 22 ++++----- python/cuvs/cuvs/cluster/mg/kmeans/kmeans.pyx | 2 +- python/cuvs/cuvs/tests/test_kmeans.py | 8 ++-- python/cuvs/cuvs/tests/test_mg_kmeans.py | 2 +- rust/cuvs-sys/src/bindings.rs | 8 ++-- 22 files changed, 139 insertions(+), 139 deletions(-) diff --git a/c/include/cuvs/cluster/kmeans.h b/c/include/cuvs/cluster/kmeans.h index 9a3882cb4c..b402ead432 100644 --- a/c/include/cuvs/cluster/kmeans.h +++ b/c/include/cuvs/cluster/kmeans.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -112,7 +112,7 @@ struct cuvsKMeansParams { * Number of samples to process per GPU batch for the batched (host-data) API. * When set to 0, defaults to n_samples (process all at once). */ - int64_t streaming_batch_size; + int64_t device_buffer_samples; /** * Number of samples to draw for KMeansPlusPlus initialization. @@ -191,7 +191,7 @@ struct cuvsKMeansParams { * Number of samples to process per GPU batch for the batched (host-data) API. * When set to 0, defaults to n_samples (process all at once). */ - int64_t streaming_batch_size; + int64_t device_buffer_samples; /** * Number of samples to draw for KMeansPlusPlus initialization. @@ -268,7 +268,7 @@ typedef enum { CUVS_KMEANS_TYPE_KMEANS = 0, CUVS_KMEANS_TYPE_KMEANS_BALANCED = 1 * * X may reside on either host (CPU) or device (GPU) memory. * When X is on the host the data is streamed to the GPU in - * batches controlled by params->streaming_batch_size. + * batches controlled by params->device_buffer_samples. * * @note In cuVS 26.08 (next ABI major version) this signature will be * replaced by cuvsKMeansFit_v2. diff --git a/c/src/cluster/kmeans.cpp b/c/src/cluster/kmeans.cpp index 8e46764ce4..f65e86f4f1 100644 --- a/c/src/cluster/kmeans.cpp +++ b/c/src/cluster/kmeans.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -31,7 +31,7 @@ cuvs::cluster::kmeans::params convert_params(const ParamsT& params) kmeans_params.batch_samples = params.batch_samples; kmeans_params.batch_centroids = params.batch_centroids; kmeans_params.init_size = params.init_size; - kmeans_params.streaming_batch_size = params.streaming_batch_size; + kmeans_params.device_buffer_samples = params.device_buffer_samples; return kmeans_params; } @@ -243,7 +243,7 @@ extern "C" cuvsError_t cuvsKMeansParamsCreate(cuvsKMeansParams_t* params) .inertia_check = false, .hierarchical = false, .hierarchical_n_iters = static_cast(cpp_balanced_params.n_iters), - .streaming_batch_size = cpp_params.streaming_batch_size, + .device_buffer_samples = cpp_params.device_buffer_samples, .init_size = cpp_params.init_size}; }); } @@ -315,7 +315,7 @@ extern "C" cuvsError_t cuvsKMeansParamsCreate_v2(cuvsKMeansParams_v2_t* params) .batch_centroids = cpp_params.batch_centroids, .hierarchical = false, .hierarchical_n_iters = static_cast(cpp_balanced_params.n_iters), - .streaming_batch_size = cpp_params.streaming_batch_size, + .device_buffer_samples = cpp_params.device_buffer_samples, .init_size = cpp_params.init_size}; }); } diff --git a/c/src/cluster/mg_kmeans.cpp b/c/src/cluster/mg_kmeans.cpp index 1f1b51ff00..066f5336bb 100644 --- a/c/src/cluster/mg_kmeans.cpp +++ b/c/src/cluster/mg_kmeans.cpp @@ -37,7 +37,7 @@ cuvs::cluster::kmeans::params convert_params(const ParamsT& params) kmeans_params.batch_samples = params.batch_samples; kmeans_params.batch_centroids = params.batch_centroids; kmeans_params.init_size = params.init_size; - kmeans_params.streaming_batch_size = params.streaming_batch_size; + kmeans_params.device_buffer_samples = params.device_buffer_samples; return kmeans_params; } diff --git a/c/tests/cluster/kmeans_c.cu b/c/tests/cluster/kmeans_c.cu index 3c87d035d3..4e840ae18e 100644 --- a/c/tests/cluster/kmeans_c.cu +++ b/c/tests/cluster/kmeans_c.cu @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -128,7 +128,7 @@ void test_fit_predict() params->max_iter = 100; params->tol = 1e-6; params->init = Array; - params->streaming_batch_size = 0; + params->device_buffer_samples = 0; DLManagedTensor dataset_t{}; cuvs::core::to_dlpack( @@ -195,7 +195,7 @@ void test_fit_host() params->max_iter = 100; params->tol = 1e-6; params->init = Array; - params->streaming_batch_size = 4; // force at least 2 streamed batches + params->device_buffer_samples = 4; // force at least 2 streamed batches DLManagedTensor dataset_t{}; cuvs::core::to_dlpack( diff --git a/c/tests/cluster/kmeans_mg_c.cu b/c/tests/cluster/kmeans_mg_c.cu index 40322e8057..194b1f0da3 100644 --- a/c/tests/cluster/kmeans_mg_c.cu +++ b/c/tests/cluster/kmeans_mg_c.cu @@ -77,7 +77,7 @@ void test_mg_fit_host() params->max_iter = 100; params->tol = 1e-6; params->init = Array; - params->streaming_batch_size = 4; // force at least 2 streamed batches + params->device_buffer_samples = 4; // force at least 2 streamed batches DLManagedTensor dataset_t{}; cuvs::core::to_dlpack(raft::make_host_matrix_view( diff --git a/cpp/include/cuvs/cluster/kmeans.hpp b/cpp/include/cuvs/cluster/kmeans.hpp index 74ad6d09d4..0c161e3bba 100644 --- a/cpp/include/cuvs/cluster/kmeans.hpp +++ b/cpp/include/cuvs/cluster/kmeans.hpp @@ -113,7 +113,7 @@ struct params : base_params { * Default tile is [batch_samples x n_clusters] i.e. when batch_centroids is 0 * then don't tile the centroids * - * NB: These parameters are unrelated to streaming_batch_size, which controls how many + * NB: These parameters are unrelated to device_buffer_samples, which controls how many * samples to transfer from host to device per batch when processing out-of-core * data. */ @@ -154,7 +154,7 @@ struct params : base_params { * count. This is is ignored by device-data overloads. * Default: 0 (process all data at once). */ - int64_t streaming_batch_size = 0; + int64_t device_buffer_samples = 0; }; /** @@ -199,7 +199,7 @@ enum class kmeans_type { KMeans = 0, KMeansBalanced = 1 }; * * This overload supports out-of-core computation where the dataset resides * on the host. Data is processed in batches, streaming from host to - * device. The batch size is controlled by `params.streaming_batch_size`. + * device. The batch size is controlled by `params.device_buffer_samples`. * * Multi-GPU dispatch is selected automatically based on the handle state: * - If `raft::resource::is_multi_gpu(handle)` (cuVS SNMG): the full dataset X @@ -221,7 +221,7 @@ enum class kmeans_type { KMeans = 0, KMeansBalanced = 1 }; * raft::resources handle; * cuvs::cluster::kmeans::params params; * params.n_clusters = 100; - * params.streaming_batch_size = 100000; + * params.device_buffer_samples = 100000; * float inertia; * int64_t n_iter; * @@ -245,7 +245,7 @@ enum class kmeans_type { KMeans = 0, KMeansBalanced = 1 }; * @param[in] handle The raft handle. When a multi-GPU resource is * attached, multi-GPU dispatch is used automatically. * @param[in] params Parameters for KMeans model. Batch size is read from - * params.streaming_batch_size. + * params.device_buffer_samples. * @param[in] X Training instances on HOST memory. The data must * be in row-major format. * [dim = n_samples x n_features] @@ -1648,8 +1648,8 @@ void cluster_cost( * * Each rank supplies its local training data as a vector of partitions. For * host-resident partitions the implementation streams each partition using - * `params.streaming_batch_size` (per rank). For device-resident partitions - * `streaming_batch_size` is ignored and each local partition is processed in full. + * `params.device_buffer_samples` (per rank). For device-resident partitions + * `device_buffer_samples` is ignored and each local partition is processed in full. * * The active backend is selected by the resources attached to * `handle`: @@ -1665,7 +1665,7 @@ void cluster_cost( * @param[in] params K-means parameters. For host-resident * partitions the per-rank streaming batch * size is read from - * `params.streaming_batch_size`; it is + * `params.device_buffer_samples`; it is * ignored for device-resident partitions. * @param[in] X_parts Per-partition local data on this rank. * Each entry is [n_rows_i x n_features]. diff --git a/cpp/src/cluster/detail/kmeans.cuh b/cpp/src/cluster/detail/kmeans.cuh index b1608407bc..e3ffb4a439 100644 --- a/cpp/src/cluster/detail/kmeans.cuh +++ b/cpp/src/cluster/detail/kmeans.cuh @@ -588,9 +588,9 @@ void kmeans_fit( raft::default_logger().set_level(pams.verbosity); - IndexT streaming_batch_size = static_cast(pams.streaming_batch_size); - if (streaming_batch_size <= 0 || streaming_batch_size > static_cast(n_samples)) { - streaming_batch_size = static_cast(n_samples); + IndexT device_buffer_samples = static_cast(pams.device_buffer_samples); + if (device_buffer_samples <= 0 || device_buffer_samples > static_cast(n_samples)) { + device_buffer_samples = static_cast(n_samples); } constexpr bool data_on_device = raft::is_device_mdspan_v; @@ -606,13 +606,13 @@ void kmeans_fit( rmm::device_uvector local_workspace(0, stream); rmm::device_uvector& ws = workspace.has_value() ? workspace->get() : local_workspace; - if (data_on_device && streaming_batch_size != static_cast(n_samples)) { + if (data_on_device && device_buffer_samples != static_cast(n_samples)) { RAFT_LOG_WARN( - "KMeans: streaming_batch_size (%zu) ignored when data resides on device; using n_samples " + "KMeans: device_buffer_samples (%zu) ignored when data resides on device; using n_samples " "(%zu)", - static_cast(streaming_batch_size), + static_cast(device_buffer_samples), static_cast(n_samples)); - streaming_batch_size = static_cast(n_samples); + device_buffer_samples = static_cast(n_samples); } // Preallocate the host-side KMeans++ init sample buffer. @@ -685,26 +685,26 @@ void kmeans_fit( DataT* new_centroids_ptr = new_centroids_buf.data(); auto minClusterAndDistance = raft::make_device_vector, IndexT>( - handle, streaming_batch_size); - auto L2NormBatch = raft::make_device_vector(handle, streaming_batch_size); - auto batch_weights_buf = raft::make_device_vector(handle, streaming_batch_size); + handle, device_buffer_samples); + auto L2NormBatch = raft::make_device_vector(handle, device_buffer_samples); + auto batch_weights_buf = raft::make_device_vector(handle, device_buffer_samples); rmm::device_uvector L2NormBuf_OR_DistBuf(0, stream); auto centroid_sums = raft::make_device_matrix(handle, n_clusters, n_features); auto weight_per_cluster = raft::make_device_vector(handle, n_clusters); auto clustering_cost = raft::make_device_scalar(handle, DataT{0}); - rmm::device_uvector batch_workspace(streaming_batch_size, stream); + rmm::device_uvector batch_workspace(device_buffer_samples, stream); auto data_batches = cuvs::spatial::knn::detail::utils::make_batch_load_iterator( - handle, X.data_handle(), n_samples, n_features, streaming_batch_size, stream); + handle, X.data_handle(), n_samples, n_features, device_buffer_samples, stream); // Host-path weight batches: only materialized when weights are provided and // the data resides on host std::optional> weight_batches; if constexpr (!data_on_device) { if (weight_ptr != nullptr) { weight_batches = cuvs::spatial::knn::detail::utils::make_batch_load_iterator( - handle, weight_ptr, n_samples, IndexT{1}, streaming_batch_size, stream); + handle, weight_ptr, n_samples, IndexT{1}, device_buffer_samples, stream); } else { raft::matrix::fill(handle, batch_weights_buf.view(), DataT{1}); } @@ -759,11 +759,11 @@ void kmeans_fit( }; RAFT_LOG_DEBUG( - "KMeans.fit: n_samples=%zu, n_features=%zu, n_clusters=%d, streaming_batch_size=%zu", + "KMeans.fit: n_samples=%zu, n_features=%zu, n_clusters=%d, device_buffer_samples=%zu", static_cast(n_samples), static_cast(n_features), n_clusters, - static_cast(streaming_batch_size)); + static_cast(device_buffer_samples)); bool need_compute_norms = metric == cuvs::distance::DistanceType::L2Expanded || metric == cuvs::distance::DistanceType::L2SqrtExpanded; diff --git a/cpp/src/cluster/detail/kmeans_mg.cuh b/cpp/src/cluster/detail/kmeans_mg.cuh index c83b3fd22f..dbe2c23039 100644 --- a/cpp/src/cluster/detail/kmeans_mg.cuh +++ b/cpp/src/cluster/detail/kmeans_mg.cuh @@ -188,18 +188,18 @@ void mnmg_fit( static_cast(n_features), static_cast(n_clusters)); - IndexT streaming_batch_size = static_cast(params.streaming_batch_size); - if (streaming_batch_size <= 0 || streaming_batch_size > max_part_rows) { - streaming_batch_size = std::max(max_part_rows, IndexT{1}); + IndexT device_buffer_samples = static_cast(params.device_buffer_samples); + if (device_buffer_samples <= 0 || device_buffer_samples > max_part_rows) { + device_buffer_samples = std::max(max_part_rows, IndexT{1}); } - if (data_on_device && streaming_batch_size < max_part_rows) { + if (data_on_device && device_buffer_samples < max_part_rows) { RAFT_LOG_WARN( - "MNMG KMeans: streaming_batch_size (%zu) ignored when partitions reside on device; using " + "MNMG KMeans: device_buffer_samples (%zu) ignored when partitions reside on device; using " "max partition size (%zu)", - static_cast(streaming_batch_size), + static_cast(device_buffer_samples), static_cast(max_part_rows)); - streaming_batch_size = max_part_rows; + device_buffer_samples = max_part_rows; } auto rank_centroids_arr = @@ -212,7 +212,7 @@ void mnmg_fit( auto clustering_cost = raft::make_device_vector(dev_res, 1); auto batch_clustering_cost = raft::make_device_vector(dev_res, 1); auto sqrd_norm_error_dev = raft::make_device_scalar(dev_res, DataT{0}); - IndexT alloc_batch_size = streaming_batch_size; + IndexT alloc_batch_size = device_buffer_samples; auto batch_weights = raft::make_device_vector(dev_res, alloc_batch_size); auto minClusterAndDistance = raft::make_device_vector, IndexT>(dev_res, alloc_batch_size); @@ -363,7 +363,7 @@ void mnmg_fit( init_centroids_for_mg_batched(dev_res, iter_params, - streaming_batch_size, + device_buffer_samples, X_parts, n_features, input_centroids_const, @@ -404,7 +404,7 @@ void mnmg_fit( data_batch_iterator_t data_batches(dev_res, X_part, - static_cast(streaming_batch_size), + static_cast(device_buffer_samples), stream, rmm::mr::get_current_device_resource_ref(), true); @@ -532,7 +532,7 @@ void mnmg_fit( data_batch_iterator_t data_batches(dev_res, X_part, - static_cast(streaming_batch_size), + static_cast(device_buffer_samples), stream, rmm::mr::get_current_device_resource_ref(), true); diff --git a/cpp/src/cluster/detail/kmeans_mg_batched_init.cuh b/cpp/src/cluster/detail/kmeans_mg_batched_init.cuh index b6cb021d2c..c8ae3f464f 100644 --- a/cpp/src/cluster/detail/kmeans_mg_batched_init.cuh +++ b/cpp/src/cluster/detail/kmeans_mg_batched_init.cuh @@ -247,7 +247,7 @@ template void init_centroids_for_mg_batched( raft::resources const& handle, const cuvs::cluster::kmeans::params& params, - IndexT /*streaming_batch_size*/, + IndexT /*device_buffer_samples*/, const std::vector< raft::mdspan, raft::row_major, Accessor>>& X_parts, IndexT n_features, diff --git a/cpp/tests/cluster/kmeans.cu b/cpp/tests/cluster/kmeans.cu index 0b5d1b8fc9..804922a93d 100644 --- a/cpp/tests/cluster/kmeans.cu +++ b/cpp/tests/cluster/kmeans.cu @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -339,7 +339,7 @@ struct KmeansBatchedInputs { int n_clusters; T tol; bool weighted; - int streaming_batch_size; + int device_buffer_samples; }; template @@ -416,7 +416,7 @@ class KmeansFitBatchedTest : public ::testing::TestWithParam(&ref_n_iter)); cuvs::cluster::kmeans::params batched_params = params; - batched_params.streaming_batch_size = testparams.streaming_batch_size; + batched_params.device_buffer_samples = testparams.device_buffer_samples; std::optional> h_sw = std::nullopt; auto h_sample_weight = raft::make_host_vector(testparams.weighted ? n_samples : 0); @@ -496,15 +496,15 @@ class KmeansFitBatchedTest : public ::testing::TestWithParam(handle, n_clusters, n_features); T inertia = 0; diff --git a/cpp/tests/cluster/kmeans_mg.cu b/cpp/tests/cluster/kmeans_mg.cu index 0830dec040..85bf238d33 100644 --- a/cpp/tests/cluster/kmeans_mg.cu +++ b/cpp/tests/cluster/kmeans_mg.cu @@ -38,7 +38,7 @@ struct KmeansSNMGInputs { int n_clusters; T tol; kmeans_weight_mode weight_mode; - int streaming_batch_size; + int device_buffer_samples; int n_init; cuvs::cluster::kmeans::params::InitMethod init = cuvs::cluster::kmeans::params::Array; int max_iter = 20; @@ -105,13 +105,13 @@ class KmeansSNMGTest : public ::testing::TestWithParam> { } cuvs::cluster::kmeans::params snmg_params; - snmg_params.n_clusters = n_clusters; - snmg_params.tol = testparams_.tol; - snmg_params.max_iter = testparams_.max_iter; - snmg_params.n_init = testparams_.n_init; - snmg_params.rng_state.seed = 42; - snmg_params.init = testparams_.init; - snmg_params.streaming_batch_size = testparams_.streaming_batch_size; + snmg_params.n_clusters = n_clusters; + snmg_params.tol = testparams_.tol; + snmg_params.max_iter = testparams_.max_iter; + snmg_params.n_init = testparams_.n_init; + snmg_params.rng_state.seed = 42; + snmg_params.init = testparams_.init; + snmg_params.device_buffer_samples = testparams_.device_buffer_samples; T snmg_inertia = T{0}; int64_t snmg_n_iter = 0; @@ -277,7 +277,7 @@ class KmeansSNMGTest : public ::testing::TestWithParam> { // SNMG float test inputs // ============================================================================ const std::vector> snmg_inputsf = { - // n_row, n_col, n_clusters, tol, weight_mode, streaming_batch_size, n_init[, init] + // n_row, n_col, n_clusters, tol, weight_mode, device_buffer_samples, n_init[, init] {1000, 32, 5, 0.0001f, kmeans_weight_mode::none, 1000, 1}, {1000, 32, 5, 0.0001f, kmeans_weight_mode::uniform, 1000, 1}, {1000, 32, 5, 0.0001f, kmeans_weight_mode::none, 128, 1}, diff --git a/cpp/tests/cluster/kmeans_mnmg.cu b/cpp/tests/cluster/kmeans_mnmg.cu index 39feeef1b6..3db41ee03f 100644 --- a/cpp/tests/cluster/kmeans_mnmg.cu +++ b/cpp/tests/cluster/kmeans_mnmg.cu @@ -278,7 +278,7 @@ struct KmeansMGNcclInputs { int n_clusters; T tol; kmeans_weight_mode weight_mode; - int64_t streaming_batch_size; + int64_t device_buffer_samples; int n_init; int partitions_per_rank; cuvs::cluster::kmeans::params::InitMethod init = cuvs::cluster::kmeans::params::Array; @@ -359,13 +359,13 @@ class KmeansMGNcclTest : public ::testing::TestWithParam> } cuvs::cluster::kmeans::params kp; - kp.n_clusters = n_clusters; - kp.tol = testparams_.tol; - kp.max_iter = testparams_.max_iter; - kp.n_init = testparams_.n_init; - kp.rng_state.seed = 42; - kp.init = testparams_.init; - kp.streaming_batch_size = testparams_.streaming_batch_size; + kp.n_clusters = n_clusters; + kp.tol = testparams_.tol; + kp.max_iter = testparams_.max_iter; + kp.n_init = testparams_.n_init; + kp.rng_state.seed = 42; + kp.init = testparams_.init; + kp.device_buffer_samples = testparams_.device_buffer_samples; std::vector h_mg_centroids; T mg_inertia = T{0}; @@ -414,13 +414,13 @@ class KmeansMGNcclTest : public ::testing::TestWithParam> } cuvs::cluster::kmeans::params skp; - skp.n_clusters = n_clusters; - skp.tol = testparams_.tol; - skp.max_iter = testparams_.max_iter; - skp.n_init = testparams_.n_init; - skp.rng_state.seed = 42; - skp.init = testparams_.init; - skp.streaming_batch_size = testparams_.streaming_batch_size; + skp.n_clusters = n_clusters; + skp.tol = testparams_.tol; + skp.max_iter = testparams_.max_iter; + skp.n_init = testparams_.n_init; + skp.rng_state.seed = 42; + skp.init = testparams_.init; + skp.device_buffer_samples = testparams_.device_buffer_samples; T sg_inertia = T{0}; int sg_n_iter = 0; @@ -521,7 +521,7 @@ class KmeansMGNcclTest : public ::testing::TestWithParam> // NCCL float test inputs // ============================================================================ const std::vector> mg_nccl_inputsf = { - // n_row, n_col, n_clusters, tol, weight_mode, streaming_batch_size, n_init, + // n_row, n_col, n_clusters, tol, weight_mode, device_buffer_samples, n_init, // partitions_per_rank[, init[, max_iter]] {1000, 32, 5, 0.0001f, kmeans_weight_mode::none, 1000, 1, 1}, {1000, 32, 5, 0.0001f, kmeans_weight_mode::none, 1000, 1, 2}, @@ -706,14 +706,14 @@ class KmeansMGOversamplingTest : public ::testing::Test { double oversampling_factor = 1.0) { cuvs::cluster::kmeans::params kp; - kp.n_clusters = n_clusters; - kp.tol = T(1e-4); - kp.max_iter = 30; - kp.n_init = 1; - kp.rng_state.seed = 42; - kp.init = cuvs::cluster::kmeans::params::KMeansPlusPlus; - kp.streaming_batch_size = n_samples; - kp.oversampling_factor = oversampling_factor; + kp.n_clusters = n_clusters; + kp.tol = T(1e-4); + kp.max_iter = 30; + kp.n_init = 1; + kp.rng_state.seed = 42; + kp.init = cuvs::cluster::kmeans::params::KMeansPlusPlus; + kp.device_buffer_samples = n_samples; + kp.oversampling_factor = oversampling_factor; std::vector h_centroids; const int actual_threads = run_mg_fit_omp(device_ids_, diff --git a/fern/pages/c_api/c-api-cluster-kmeans.md b/fern/pages/c_api/c-api-cluster-kmeans.md index 2af8b259bc..51c55122ba 100644 --- a/fern/pages/c_api/c-api-cluster-kmeans.md +++ b/fern/pages/c_api/c-api-cluster-kmeans.md @@ -47,7 +47,7 @@ struct cuvsKMeansParams { bool inertia_check; bool hierarchical; int hierarchical_n_iters; - int64_t streaming_batch_size; + int64_t device_buffer_samples; int64_t init_size; cuvsDistanceType metric; }; @@ -68,7 +68,7 @@ struct cuvsKMeansParams { | `inertia_check` | `bool` | Deprecated, ignored. Kept for ABI compatibility. | | `hierarchical` | `bool` | Whether to use hierarchical (balanced) kmeans or not | | `hierarchical_n_iters` | `int` | For hierarchical k-means , defines the number of training iterations | -| `streaming_batch_size` | `int64_t` | Number of samples to process per GPU batch for the batched (host-data) API. When set to 0, defaults to n_samples (process all at once). | +| `device_buffer_samples` | `int64_t` | Number of samples to process per GPU batch for the batched (host-data) API. When set to 0, defaults to n_samples (process all at once). | | `init_size` | `int64_t` | Number of samples to draw for KMeansPlusPlus initialization. When set to 0, uses heuristic min(3 * n_clusters, n_samples) for host data, or n_samples for device data. | | `metric` | [`cuvsDistanceType`](/api-reference/c-api-distance-distance#cuvsdistancetype) | | @@ -89,7 +89,7 @@ struct cuvsKMeansParams_v2 { int batch_centroids; bool hierarchical; int hierarchical_n_iters; - int64_t streaming_batch_size; + int64_t device_buffer_samples; int64_t init_size; cuvsDistanceType metric; }; @@ -109,7 +109,7 @@ struct cuvsKMeansParams_v2 { | `batch_centroids` | `int` | if 0 then batch_centroids = n_clusters | | `hierarchical` | `bool` | Whether to use hierarchical (balanced) kmeans or not | | `hierarchical_n_iters` | `int` | For hierarchical k-means , defines the number of training iterations | -| `streaming_batch_size` | `int64_t` | Number of samples to process per GPU batch for the batched (host-data) API. When set to 0, defaults to n_samples (process all at once). | +| `device_buffer_samples` | `int64_t` | Number of samples to process per GPU batch for the batched (host-data) API. When set to 0, defaults to n_samples (process all at once). | | `init_size` | `int64_t` | Number of samples to draw for KMeansPlusPlus initialization. When set to 0, uses heuristic min(3 * n_clusters, n_samples) for host data, or n_samples for device data. | | `metric` | [`cuvsDistanceType`](/api-reference/c-api-distance-distance#cuvsdistancetype) | | @@ -233,7 +233,7 @@ int* n_iter); Initial centroids are chosen with k-means++ algorithm. Empty clusters are reinitialized by choosing new centroids with k-means++ algorithm. -X may reside on either host (CPU) or device (GPU) memory. When X is on the host the data is streamed to the GPU in batches controlled by params->streaming_batch_size. +X may reside on either host (CPU) or device (GPU) memory. When X is on the host the data is streamed to the GPU in batches controlled by params->device_buffer_samples. **Note:** In cuVS 26.08 (next ABI major version) this signature will be
replaced by cuvsKMeansFit_v2. diff --git a/fern/pages/cluster/kmeans.md b/fern/pages/cluster/kmeans.md index 58c438f64a..0c3186b99e 100644 --- a/fern/pages/cluster/kmeans.md +++ b/fern/pages/cluster/kmeans.md @@ -366,7 +366,7 @@ Balanced K-Means encourages more even cluster sizes. It is useful when clusters | `batch_samples` | `32768` | Number of samples per tile for the nearest-centroid computation. Lower values reduce temporary memory. | | `batch_centroids` | `0` | Number of centroids per tile. `0` means all centroids. Lower values reduce temporary memory. | | `init_size` | `0` | Number of rows sampled for k-means++ initialization on host-data paths. `0` uses the default heuristic. | -| `streaming_batch_size` | `0` | Number of host rows streamed to the GPU per batch. `0` processes all host rows at once. | +| `device_buffer_samples` | `0` | Number of host rows streamed to the GPU per batch. `0` processes all host rows at once. | | `hierarchical` | `false` | Enables hierarchical, balanced K-Means in C and Python. | | `hierarchical_n_iters` | implementation default | Number of training iterations for hierarchical K-Means. | @@ -380,7 +380,7 @@ Tune `max_iter` and `tol` together. If `n_iter` often reaches `max_iter`, increa Use `batch_samples` and `batch_centroids` to control device memory for device-resident data. Smaller tiles reduce temporary memory but add more tiled work. -Use `streaming_batch_size` when fitting host-resident datasets that do not fit on the GPU. Smaller batches reduce GPU memory pressure, while larger batches reduce transfer and launch overhead. +Use `device_buffer_samples` when fitting host-resident datasets that do not fit on the GPU. Smaller batches reduce GPU memory pressure, while larger batches reduce transfer and launch overhead. Use balanced K-Means when cluster size matters. This is often useful when clusters are later used as work partitions, batches, or coarse groups for another algorithm. @@ -484,7 +484,7 @@ $$ ### Host streaming fit -For host-resident data, NVIDIA cuVS can stream rows to the GPU in batches. If `streaming_batch_size = 0`, then `S = N`; otherwise `S = streaming_batch_size`. +For host-resident data, NVIDIA cuVS can stream rows to the GPU in batches. If `device_buffer_samples = 0`, then `S = N`; otherwise `S = device_buffer_samples`. $$ \begin{aligned} @@ -498,7 +498,7 @@ $$ \end{aligned} $$ -Use a smaller `streaming_batch_size` when the host-data fit path runs out of GPU memory. Use a larger value when GPU memory is available and transfer overhead dominates. +Use a smaller `device_buffer_samples` when the host-data fit path runs out of GPU memory. Use a larger value when GPU memory is available and transfer overhead dominates. ### Prediction diff --git a/fern/pages/cpp_api/cpp-api-cluster-kmeans.md b/fern/pages/cpp_api/cpp-api-cluster-kmeans.md index cbb5a73de7..67e63f5c21 100644 --- a/fern/pages/cpp_api/cpp-api-cluster-kmeans.md +++ b/fern/pages/cpp_api/cpp-api-cluster-kmeans.md @@ -45,7 +45,7 @@ struct params : base_params { int batch_samples; int batch_centroids; int64_t init_size; - int64_t streaming_batch_size; + int64_t device_buffer_samples; }; ``` @@ -61,10 +61,10 @@ struct params : base_params { | `rng_state` | `raft::random::RngState` | Seed to the random number generator. | | `n_init` | `int` | Number of instance k-means algorithm will be run with different seeds. | | `oversampling_factor` | `double` | Oversampling factor for use in the k-means\|\| algorithm | -| `batch_samples` | `int` | batch_samples and batch_centroids are used to tile 1NN computation which is useful to optimize/control the memory footprint
Default tile is [batch_samples x n_clusters] i.e. when batch_centroids is 0 then don't tile the centroids

NB: These parameters are unrelated to streaming_batch_size, which controls how many samples to transfer from host to device per batch when processing out-of-core data. | +| `batch_samples` | `int` | batch_samples and batch_centroids are used to tile 1NN computation which is useful to optimize/control the memory footprint
Default tile is [batch_samples x n_clusters] i.e. when batch_centroids is 0 then don't tile the centroids

NB: These parameters are unrelated to device_buffer_samples, which controls how many samples to transfer from host to device per batch when processing out-of-core data. | | `batch_centroids` | `int` | if 0 then batch_centroids = n_clusters | | `init_size` | `int64_t` | Number of samples to randomly draw for the KMeansPlusPlus initialization step. A random subset of this size is used for centroid seeding.

Only applies when dataset is on host; for device data the full dataset is always used for seeding and this parameter is ignored.

When set to 0 (default) with host data uses `min(3 * n_clusters, n_samples)` as a default.

In Batched multi-GPU host-data fits, the effective KMeansPlusPlus initialization sample is materialized on device on every rank. Every rank must have enough GPU memory for this sample, and rank 0 must also have enough GPU memory for the seeding workspace.

Default: 0. | -| `streaming_batch_size` | `int64_t` | Number of samples to process per GPU batch when fitting with host data. When set to 0, defaults to n_samples (process all at once). Only used by the batched (host-data) code path and ignored by device-data overloads.

In multi-GPU mode, this is a per-rank batch size. Each rank processes up to this many local samples per batch, clamped to that rank's local sample count.
Default: 0 (process all data at once). | +| `device_buffer_samples` | `int64_t` | Number of samples to process per GPU batch when fitting with host data. When set to 0, defaults to n_samples (process all at once). Only used by the batched (host-data) code path and ignored by device-data overloads.

In multi-GPU mode, this is a per-rank batch size. Each rank processes up to this many local samples per batch, clamped to that rank's local sample count.
Default: 0 (process all data at once). | ### cluster::kmeans::balanced_params @@ -128,7 +128,7 @@ raft::host_scalar_view n_iter); TODO: Evaluate replacing the extent type with int64_t. Reference issue: https://github.com/rapidsai/cuvs/issues/1961 -This overload supports out-of-core computation where the dataset resides on the host. Data is processed in GPU-sized batches, streaming from host to device. The batch size is controlled by params.streaming_batch_size. In multi-GPU mode, this is a per-rank batch size. +This overload supports out-of-core computation where the dataset resides on the host. Data is processed in GPU-sized batches, streaming from host to device. The batch size is controlled by params.device_buffer_samples. In multi-GPU mode, this is a per-rank batch size. Multi-GPU dispatch is selected automatically based on the handle state: @@ -143,7 +143,7 @@ With `params.init == InitMethod::KMeansPlusPlus` in multi-GPU mode, the effectiv | Name | Direction | Type | Description | | --- | --- | --- | --- | | `handle` | in | `raft::resources const&` | The raft handle. When a multi-GPU resource is attached, multi-GPU dispatch is used automatically. | -| `params` | in | [`const cuvs::cluster::kmeans::params&`](/api-reference/cpp-api-cluster-kmeans#cluster-kmeans-params) | Parameters for KMeans model. Batch size is read from params.streaming_batch_size. | +| `params` | in | [`const cuvs::cluster::kmeans::params&`](/api-reference/cpp-api-cluster-kmeans#cluster-kmeans-params) | Parameters for KMeans model. Batch size is read from params.device_buffer_samples. | | `X` | in | `raft::host_matrix_view` | Training instances on HOST memory. The data must be in row-major format. [dim = n_samples x n_features] | | `sample_weight` | in | `std::optional>` | Optional weights for each observation in X (on host). [len = n_samples] | | `centroids` | inout | `raft::device_matrix_view` | [in] When init is InitMethod::Array, use centroids as the initial cluster centers. [out] The generated centroids from the kmeans algorithm are stored at the address pointed by 'centroids'. [dim = n_clusters x n_features] | diff --git a/fern/pages/python_api/python-api-cluster-kmeans.md b/fern/pages/python_api/python-api-cluster-kmeans.md index 076aee0505..e887787e8b 100644 --- a/fern/pages/python_api/python-api-cluster-kmeans.md +++ b/fern/pages/python_api/python-api-cluster-kmeans.md @@ -29,14 +29,14 @@ Hyper-parameters for the kmeans algorithm | `batch_centroids` | `int` | Number of centroids to process in each batch. If 0, uses n_clusters. | | `inertia_check` | `bool` | Deprecated and ignored. Will be removed in a future release. Inertia-based convergence checking always runs. | | `init_size` | `int` | Number of samples to draw for KMeansPlusPlus initialization with host (out-of-core) data. When set to 0, uses the heuristic min(3 * n_clusters, n_samples). Default: 0. | -| `streaming_batch_size` | `int` | Number of samples to process per GPU batch when fitting with host (numpy) data. When set to 0, defaults to n_samples (process all at once). Only used by the batched (host-data) code path. Reducing streaming_batch_size can help reduce GPU memory pressure but increases overhead as the number of times centroid adjustments are computed increases.

Default: 0 (process all data at once). | +| `device_buffer_samples` | `int` | Number of samples to process per GPU batch when fitting with host (numpy) data. When set to 0, defaults to n_samples (process all at once). Only used by the batched (host-data) code path. Reducing device_buffer_samples can help reduce GPU memory pressure but increases overhead as the number of times centroid adjustments are computed increases.

Default: 0 (process all data at once). | | `hierarchical` | `bool` | Whether to use hierarchical (balanced) kmeans or not | | `hierarchical_n_iters` | `int` | For hierarchical k-means , defines the number of training iterations | **Constructor** ```python -def __init__(self, *, metric=None, n_clusters=None, init_method=None, max_iter=None, tol=None, n_init=None, oversampling_factor=None, batch_samples=None, batch_centroids=None, inertia_check=None, init_size=None, streaming_batch_size=None, hierarchical=None, hierarchical_n_iters=None) +def __init__(self, *, metric=None, n_clusters=None, init_method=None, max_iter=None, tol=None, n_init=None, oversampling_factor=None, batch_samples=None, batch_centroids=None, inertia_check=None, init_size=None, device_buffer_samples=None, hierarchical=None, hierarchical_n_iters=None) ``` **Members** @@ -53,7 +53,7 @@ def __init__(self, *, metric=None, n_clusters=None, init_method=None, max_iter=N | `batch_samples` | property | | `batch_centroids` | property | | `init_size` | property | -| `streaming_batch_size` | property | +| `device_buffer_samples` | property | | `hierarchical` | property | | `hierarchical_n_iters` | property | @@ -117,10 +117,10 @@ def batch_centroids(self) def init_size(self) ``` -### streaming_batch_size +### device_buffer_samples ```python -def streaming_batch_size(self) +def device_buffer_samples(self) ``` ### hierarchical @@ -198,14 +198,14 @@ Find clusters with the k-means algorithm When X is a device array (CUDA array interface), standard on-device k-means is used. When X is a host array (numpy ndarray or ``__array_interface__``), data is streamed to the GPU in batches -controlled by ``params.streaming_batch_size``. For large host datasets, consider -reducing ``streaming_batch_size`` to reduce GPU memory usage. +controlled by ``params.device_buffer_samples``. For large host datasets, consider +reducing ``device_buffer_samples`` to reduce GPU memory usage. **Parameters** | Name | Type | Description | | --- | --- | --- | -| `params` | `KMeansParams` | Parameters to use to fit KMeans model. For host data, ``params.streaming_batch_size`` controls how many samples are sent to the GPU per batch. | +| `params` | `KMeansParams` | Parameters to use to fit KMeans model. For host data, ``params.device_buffer_samples`` controls how many samples are sent to the GPU per batch. | | `X` | `array-like` | Training instances, shape (m, k). Accepts both device arrays (cupy / CUDA array interface) and host arrays (numpy). | | `centroids` | `Optional writable CUDA array interface compliant matrix` | shape (n_clusters, k) | | `sample_weights` | `Optional weights per observation. Must reside on` | the same memory space as X (device or host).
default: None | @@ -244,7 +244,7 @@ Host-data (batched) example: ```python >>> import numpy as np >>> X_host = np.random.random((10_000_000, 128)).astype(np.float32) ->>> params = KMeansParams(n_clusters=1000, streaming_batch_size=1_000_000) +>>> params = KMeansParams(n_clusters=1000, device_buffer_samples=1_000_000) >>> centroids, inertia, n_iter = fit(params, X_host) ``` diff --git a/python/cuvs/cuvs/cluster/kmeans/kmeans.pxd b/python/cuvs/cuvs/cluster/kmeans/kmeans.pxd index 5e6cbfe9ca..7f9d87735f 100644 --- a/python/cuvs/cuvs/cluster/kmeans/kmeans.pxd +++ b/python/cuvs/cuvs/cluster/kmeans/kmeans.pxd @@ -40,7 +40,7 @@ cdef extern from "cuvs/cluster/kmeans.h" nogil: bool inertia_check, bool hierarchical, int hierarchical_n_iters, - int64_t streaming_batch_size, + int64_t device_buffer_samples, int64_t init_size ctypedef struct cuvsKMeansParams_v2: @@ -55,7 +55,7 @@ cdef extern from "cuvs/cluster/kmeans.h" nogil: int batch_centroids, bool hierarchical, int hierarchical_n_iters, - int64_t streaming_batch_size, + int64_t device_buffer_samples, int64_t init_size ctypedef cuvsKMeansParams* cuvsKMeansParams_t diff --git a/python/cuvs/cuvs/cluster/kmeans/kmeans.pyx b/python/cuvs/cuvs/cluster/kmeans/kmeans.pyx index 2a2859a6b2..66f8919dbc 100644 --- a/python/cuvs/cuvs/cluster/kmeans/kmeans.pyx +++ b/python/cuvs/cuvs/cluster/kmeans/kmeans.pyx @@ -85,11 +85,11 @@ cdef class KMeansParams: Number of samples to draw for KMeansPlusPlus initialization with host (out-of-core) data. When set to 0, uses the heuristic min(3 * n_clusters, n_samples). Default: 0. - streaming_batch_size : int + device_buffer_samples : int Number of samples to process per GPU batch when fitting with host (numpy) data. When set to 0, defaults to n_samples (process all at once). Only used by the batched (host-data) code path. Reducing - streaming_batch_size can help reduce GPU memory pressure but increases + device_buffer_samples can help reduce GPU memory pressure but increases overhead as the number of times centroid adjustments are computed increases. @@ -118,7 +118,7 @@ cdef class KMeansParams: batch_centroids=None, inertia_check=None, init_size=None, - streaming_batch_size=None, + device_buffer_samples=None, hierarchical=None, hierarchical_n_iters=None): if metric is not None: @@ -148,8 +148,8 @@ cdef class KMeansParams: ) if init_size is not None: self.params.init_size = init_size - if streaming_batch_size is not None: - self.params.streaming_batch_size = streaming_batch_size + if device_buffer_samples is not None: + self.params.device_buffer_samples = device_buffer_samples if hierarchical is not None: self.params.hierarchical = hierarchical if hierarchical_n_iters is not None: @@ -199,8 +199,8 @@ cdef class KMeansParams: return self.params.init_size @property - def streaming_batch_size(self): - return self.params.streaming_batch_size + def device_buffer_samples(self): + return self.params.device_buffer_samples @property def hierarchical(self): @@ -225,15 +225,15 @@ def fit( When X is a device array (CUDA array interface), standard on-device k-means is used. When X is a host array (numpy ndarray or ``__array_interface__``), data is streamed to the GPU in batches - controlled by ``params.streaming_batch_size``. For large host datasets, consider - reducing ``streaming_batch_size`` to reduce GPU memory usage. + controlled by ``params.device_buffer_samples``. For large host datasets, consider + reducing ``device_buffer_samples`` to reduce GPU memory usage. Parameters ---------- params : KMeansParams Parameters to use to fit KMeans model. For host data, - ``params.streaming_batch_size`` controls how many samples are sent to the + ``params.device_buffer_samples`` controls how many samples are sent to the GPU per batch. X : array-like Training instances, shape (m, k). Accepts both device arrays @@ -275,7 +275,7 @@ def fit( >>> import numpy as np >>> X_host = np.random.random((10_000_000, 128)).astype(np.float32) - >>> params = KMeansParams(n_clusters=1000, streaming_batch_size=1_000_000) + >>> params = KMeansParams(n_clusters=1000, device_buffer_samples=1_000_000) >>> centroids, inertia, n_iter = fit(params, X_host) """ diff --git a/python/cuvs/cuvs/cluster/mg/kmeans/kmeans.pyx b/python/cuvs/cuvs/cluster/mg/kmeans/kmeans.pyx index ed1223271d..15bf44f2d7 100644 --- a/python/cuvs/cuvs/cluster/mg/kmeans/kmeans.pyx +++ b/python/cuvs/cuvs/cluster/mg/kmeans/kmeans.pyx @@ -151,7 +151,7 @@ def fit( params_v2.batch_centroids = params.params.batch_centroids params_v2.hierarchical = params.params.hierarchical params_v2.hierarchical_n_iters = params.params.hierarchical_n_iters - params_v2.streaming_batch_size = params.params.streaming_batch_size + params_v2.device_buffer_samples = params.params.device_buffer_samples params_v2.init_size = params.params.init_size with cuda_interruptible(): diff --git a/python/cuvs/cuvs/tests/test_kmeans.py b/python/cuvs/cuvs/tests/test_kmeans.py index 210ae06b80..e6428e9d3a 100644 --- a/python/cuvs/cuvs/tests/test_kmeans.py +++ b/python/cuvs/cuvs/tests/test_kmeans.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # @@ -79,11 +79,11 @@ def test_cluster_cost(n_rows, n_cols, n_clusters, dtype): @pytest.mark.parametrize("n_rows", [1000, 5000]) @pytest.mark.parametrize("n_cols", [10, 100]) @pytest.mark.parametrize("n_clusters", [8, 16]) -@pytest.mark.parametrize("streaming_batch_size", [0, 100, 239, 500]) +@pytest.mark.parametrize("device_buffer_samples", [0, 100, 239, 500]) @pytest.mark.parametrize("dtype", [np.float64]) @pytest.mark.parametrize("weighted", [False, True]) def test_fit_host_matches_fit_device( - n_rows, n_cols, n_clusters, streaming_batch_size, dtype, weighted + n_rows, n_cols, n_clusters, device_buffer_samples, dtype, weighted ): """ Test that fit() with host (numpy) data produces the same centroids as @@ -122,7 +122,7 @@ def test_fit_host_matches_fit_device( init_method="Array", max_iter=20, tol=1e-10, - streaming_batch_size=streaming_batch_size, + device_buffer_samples=device_buffer_samples, ) centroids_batched, inertia_batched, _ = fit( params_host, diff --git a/python/cuvs/cuvs/tests/test_mg_kmeans.py b/python/cuvs/cuvs/tests/test_mg_kmeans.py index 228abc5f67..53885964ba 100644 --- a/python/cuvs/cuvs/tests/test_mg_kmeans.py +++ b/python/cuvs/cuvs/tests/test_mg_kmeans.py @@ -110,7 +110,7 @@ def test_mg_kmeans_fit_options(dtype, init_method, weighted): tol=1e-10, n_init=3 if init_method == "Random" else 1, init_size=X.shape[0], - streaming_batch_size=37, + device_buffer_samples=37, ) centroids = initial_centroids.copy() if init_method == "Array" else None diff --git a/rust/cuvs-sys/src/bindings.rs b/rust/cuvs-sys/src/bindings.rs index 171af6f422..cc118260bc 100644 --- a/rust/cuvs-sys/src/bindings.rs +++ b/rust/cuvs-sys/src/bindings.rs @@ -404,7 +404,7 @@ pub struct cuvsKMeansParams { #[doc = " For hierarchical k-means , defines the number of training iterations"] pub hierarchical_n_iters: ::std::os::raw::c_int, #[doc = " Number of samples to process per GPU batch for the batched (host-data) API.\n When set to 0, defaults to n_samples (process all at once)."] - pub streaming_batch_size: i64, + pub device_buffer_samples: i64, } #[allow(clippy::unnecessary_operation, clippy::identity_op)] const _: () = { @@ -434,8 +434,8 @@ const _: () = { [::std::mem::offset_of!(cuvsKMeansParams, hierarchical) - 49usize]; ["Offset of field: cuvsKMeansParams::hierarchical_n_iters"] [::std::mem::offset_of!(cuvsKMeansParams, hierarchical_n_iters) - 52usize]; - ["Offset of field: cuvsKMeansParams::streaming_batch_size"] - [::std::mem::offset_of!(cuvsKMeansParams, streaming_batch_size) - 56usize]; + ["Offset of field: cuvsKMeansParams::device_buffer_samples"] + [::std::mem::offset_of!(cuvsKMeansParams, device_buffer_samples) - 56usize]; }; pub type cuvsKMeansParams_t = *mut cuvsKMeansParams; unsafe extern "C" { @@ -457,7 +457,7 @@ pub enum cuvsKMeansType { } unsafe extern "C" { #[must_use] - #[doc = " @brief Find clusters with k-means algorithm.\n\n Initial centroids are chosen with k-means++ algorithm. Empty\n clusters are reinitialized by choosing new centroids with\n k-means++ algorithm.\n\n X may reside on either host (CPU) or device (GPU) memory.\n When X is on the host the data is streamed to the GPU in\n batches controlled by params->streaming_batch_size.\n\n @param[in] res opaque C handle\n @param[in] params Parameters for KMeans model.\n @param[in] X Training instances to cluster. The data must\n be in row-major format. May be on host or\n device memory.\n [dim = n_samples x n_features]\n @param[in] sample_weight Optional weights for each observation in X.\n Must be on the same memory space as X.\n [len = n_samples]\n @param[inout] centroids [in] When init is InitMethod::Array, use\n centroids as the initial cluster centers.\n [out] The generated centroids from the\n kmeans algorithm are stored at the address\n pointed by 'centroids'. Must be on device.\n [dim = n_clusters x n_features]\n @param[out] inertia Sum of squared distances of samples to their\n closest cluster center.\n @param[out] n_iter Number of iterations run."] + #[doc = " @brief Find clusters with k-means algorithm.\n\n Initial centroids are chosen with k-means++ algorithm. Empty\n clusters are reinitialized by choosing new centroids with\n k-means++ algorithm.\n\n X may reside on either host (CPU) or device (GPU) memory.\n When X is on the host the data is streamed to the GPU in\n batches controlled by params->device_buffer_samples.\n\n @param[in] res opaque C handle\n @param[in] params Parameters for KMeans model.\n @param[in] X Training instances to cluster. The data must\n be in row-major format. May be on host or\n device memory.\n [dim = n_samples x n_features]\n @param[in] sample_weight Optional weights for each observation in X.\n Must be on the same memory space as X.\n [len = n_samples]\n @param[inout] centroids [in] When init is InitMethod::Array, use\n centroids as the initial cluster centers.\n [out] The generated centroids from the\n kmeans algorithm are stored at the address\n pointed by 'centroids'. Must be on device.\n [dim = n_clusters x n_features]\n @param[out] inertia Sum of squared distances of samples to their\n closest cluster center.\n @param[out] n_iter Number of iterations run."] pub fn cuvsKMeansFit( res: cuvsResources_t, params: cuvsKMeansParams_t, From 80a239edc3e43507c79701d10265937856711e91 Mon Sep 17 00:00:00 2001 From: tarangj Date: Mon, 20 Jul 2026 10:45:45 -0700 Subject: [PATCH 2/3] update docs --- c/include/cuvs/cluster/kmeans.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/include/cuvs/cluster/kmeans.h b/c/include/cuvs/cluster/kmeans.h index b402ead432..b0ff98a015 100644 --- a/c/include/cuvs/cluster/kmeans.h +++ b/c/include/cuvs/cluster/kmeans.h @@ -267,7 +267,7 @@ typedef enum { CUVS_KMEANS_TYPE_KMEANS = 0, CUVS_KMEANS_TYPE_KMEANS_BALANCED = 1 * k-means++ algorithm. * * X may reside on either host (CPU) or device (GPU) memory. - * When X is on the host the data is streamed to the GPU in + * When X is on the host the data is buffered to the GPU in * batches controlled by params->device_buffer_samples. * * @note In cuVS 26.08 (next ABI major version) this signature will be From 6971e470abe85be3996f9f4e3e5ef3445356c8aa Mon Sep 17 00:00:00 2001 From: tarangj Date: Mon, 20 Jul 2026 12:05:53 -0700 Subject: [PATCH 3/3] fix style --- .github/workflows/check-c-abi.yaml | 2 +- .github/workflows/publish-rust.yaml | 2 +- .github/workflows/store-c-abi-baseline.yaml | 2 +- .github/workflows/update-c-abi-baseline.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check-c-abi.yaml b/.github/workflows/check-c-abi.yaml index a594c48f44..3711da7baa 100644 --- a/.github/workflows/check-c-abi.yaml +++ b/.github/workflows/check-c-abi.yaml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout PR branch - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 with: fetch-depth: 0 persist-credentials: false diff --git a/.github/workflows/publish-rust.yaml b/.github/workflows/publish-rust.yaml index d702fd5375..8b21ff7a13 100644 --- a/.github/workflows/publish-rust.yaml +++ b/.github/workflows/publish-rust.yaml @@ -21,7 +21,7 @@ jobs: container: image: "rapidsai/ci-conda:26.08-cuda${{ matrix.cuda_version }}-ubuntu24.04-py3.13" steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 with: persist-credentials: false - name: Check if release build diff --git a/.github/workflows/store-c-abi-baseline.yaml b/.github/workflows/store-c-abi-baseline.yaml index 9fb27dc56d..9b16020bd0 100644 --- a/.github/workflows/store-c-abi-baseline.yaml +++ b/.github/workflows/store-c-abi-baseline.yaml @@ -18,7 +18,7 @@ jobs: contents: write steps: - name: Checkout repository - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 with: persist-credentials: false diff --git a/.github/workflows/update-c-abi-baseline.yaml b/.github/workflows/update-c-abi-baseline.yaml index 893eec8832..171198329a 100644 --- a/.github/workflows/update-c-abi-baseline.yaml +++ b/.github/workflows/update-c-abi-baseline.yaml @@ -17,7 +17,7 @@ jobs: contents: read steps: - name: Checkout main branch - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 with: persist-credentials: false