Skip to content

Commit a84501d

Browse files
committed
limit iterations
1 parent 1098a78 commit a84501d

3 files changed

Lines changed: 7 additions & 8 deletions

File tree

cpp/src/cluster/detail/kmeans_common.cuh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -548,10 +548,8 @@ void compute_centroid_adjustments(
548548
// Materialize the (possibly lazy) labels iterator into a device buffer so
549549
// we can read it on host without disturbing the original sequence.
550550
rmm::device_uvector<IndexT> mat_labels(static_cast<std::size_t>(n_samples), stream);
551-
thrust::copy_n(raft::resource::get_thrust_policy(handle),
552-
cluster_labels,
553-
n_samples,
554-
mat_labels.data());
551+
thrust::copy_n(
552+
raft::resource::get_thrust_policy(handle), cluster_labels, n_samples, mat_labels.data());
555553

556554
const std::size_t n_X_elems =
557555
static_cast<std::size_t>(n_samples) * static_cast<std::size_t>(n_features);

cpp/src/cluster/detail/minClusterDistanceCompute.cu

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,7 @@ void minClusterAndDistanceCompute(
154154
// whether outputs are bitwise identical across the K runs.
155155
{
156156
static std::atomic<bool> s_self_test_done{false};
157-
if (!s_self_test_done.exchange(true)) {
158-
runFusedNNDeterminismSelfTest<DataT, IndexT>(handle);
159-
}
157+
if (!s_self_test_done.exchange(true)) { runFusedNNDeterminismSelfTest<DataT, IndexT>(handle); }
160158
}
161159

162160
// ----- Nondeterminism diagnostic: fingerprint INPUTS (X, centroids, L2NormX) -----

cpp/tests/cluster/kmeans.cu

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,9 @@ class KmeansFitBatchedTest : public ::testing::TestWithParam<KmeansBatchedInputs
381381
params.tol = testparams.tol;
382382
params.rng_state.seed = 1;
383383
params.oversampling_factor = 0;
384+
// Limit the number of iterations to ensure same number of iterations for reference and batched
385+
// code paths.
386+
params.max_iter = 3;
384387

385388
auto stream = raft::resource::get_cuda_stream(handle);
386389

@@ -656,7 +659,7 @@ const std::vector<KmeansBatchedInputs<float>> batched_inputsf2 = {
656659
{1000, 64, 5, 0.0001f, false, 500},
657660
{1000, 100, 20, 0.0001f, true, 30},
658661
{1000, 10, 20, 0.0001f, false, 30},
659-
{10000, 16, 10, 0.001f, true, 1000},
662+
{10000, 16, 10, 0.0001f, true, 1000},
660663
{10000, 96, 10, 0.0001f, false, 10000},
661664
};
662665

0 commit comments

Comments
 (0)