Skip to content

[FEA] Multi-node Out of Core Streaming KMeans API#2066

Merged
rapids-bot[bot] merged 234 commits into
NVIDIA:mainfrom
tarang-jain:mnmg-streaming
Jul 13, 2026
Merged

[FEA] Multi-node Out of Core Streaming KMeans API#2066
rapids-bot[bot] merged 234 commits into
NVIDIA:mainfrom
tarang-jain:mnmg-streaming

Conversation

@tarang-jain

@tarang-jain tarang-jain commented May 7, 2026

Copy link
Copy Markdown
Contributor

Merge after #2015 and #2017

Allows a stream of input matrices per worker, that are further batched using the streaming_batch_size parameter. Reasoning: We should be able to supply dask partitions (on host) directly without having to concatenate them into one consolidated matrix.

As a part of this PR, we also unify the multi-GPU implementations into one (earlier the out of core implementation was separate).
Tests: We get rid of the separate out of core test file. The single MG testing unit is taking care of both out of core and on device matrices.

@viclafargue viclafargue left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The SNMG batched KMeans C/Python API was merged before and unfortunately now calls the single-GPU path after this PR. We should fix this.

@tarang-jain tarang-jain requested a review from a team as a code owner July 10, 2026 16:32
@tarang-jain

Copy link
Copy Markdown
Contributor Author

/ok to test 78a4278

@viclafargue viclafargue left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks a lot!

@tarang-jain

Copy link
Copy Markdown
Contributor Author

/merge

@lowener lowener requested a review from KyleFromNVIDIA July 10, 2026 21:02
@tarang-jain

Copy link
Copy Markdown
Contributor Author

/ok to test 2eed544

recluster_params.n_init = 1;

auto weight_opt = std::make_optional(raft::make_const_mdspan(weight.view()));
cuvs::cluster::kmeans::fit(handle,

@viclafargue viclafargue Jul 13, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
cuvs::cluster::kmeans::fit(handle,
cuvs::cluster::kmeans::detail::kmeans_fit(handle,

Worker needlessly emits the following warning :

Multi-GPU handle detected on single-GPU kmeans::fit() entry; falling back to single-GPU. Use cuvs::cluster::kmeans::mg::fit(...) for multi-GPU.

We need to fix this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think there is anything wrong with that warning. Yes it is triggered unnecessarily here by our own initialization implementation, but I am not in the favor of calling the detail namespace API. We should stick to calling public functions wherever possible.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

From DM discussions, it looks like calling cuvs::cluster::kmeans::detail::kmeans_fit directly may unnecessarily increase binary size. We should maybe come back at this later since the warning is a bit odd. But I will approve the PR for now to get the PR unstucked.

* The batch size is controlled by params.streaming_batch_size.
*
* Multi-GPU dispatch is selected automatically based on the handle state:
* - If `raft::resource::is_multi_gpu(handle)` (cuVS SNMG): the full dataset X

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@viclafargue I brought back this dispatch. So #2319 is not needed anymore.

Comment thread cpp/include/cuvs/cluster/kmeans.hpp Outdated
* @}
*/

namespace mg {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why are we declaring a separate public namespace for mg at all? The whole idea behind consolidating namespaces was for the user to have an easier experience by configuring the appropriate resources type to determine if they want mg operation. Please don't create separate namespaces for mg in the public APIs.

Victor did thag originally and I asked him to remove it.

@tarang-jain

Copy link
Copy Markdown
Contributor Author

/ok to test ee6c302

@tarang-jain

Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot rapids-bot Bot merged commit ad9e2d2 into NVIDIA:main Jul 13, 2026
85 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Unstructured Data Processing Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Introduces a breaking change feature request New feature or request

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

8 participants