-
Notifications
You must be signed in to change notification settings - Fork 242
[FEA] Multi-node Out of Core Streaming KMeans API #2066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 173 commits
66d7fd3
07707af
efc270f
0a09e6f
99a5730
a077406
d659875
ec2e8b7
03a6473
42a8d9d
86af2fa
d4e4e2c
0819af5
e0f079c
c2f7390
b9c3102
e3956c1
986d78a
7197b71
84ab315
47d4b94
a8e1d26
384d054
455b286
5462809
6ba759c
e76eaac
afbefdf
e62a63c
e4f08bf
6e4a8f0
4a8a85c
bbf2a9f
410092c
c515c1e
e8e63ab
30c457c
ab96623
269f23c
80a22ca
ac06b05
855624a
0a6748d
7055272
0569340
8cac63a
f6df4ae
9fc74b1
dec3dc4
0d030a2
b1c034e
a482495
8ecfdc1
1e1525e
ec22e07
d2e410d
b791c38
a05a006
73293cf
880c7b9
e2035ec
e28c200
55bbdad
9a9b8ee
a800b27
3db8582
c048352
2f968f8
affe85a
c6dea64
7dfab3e
7a383da
ce6c4b5
5a06a44
419619a
2d716ae
066092b
bbdd66d
12d682c
9e5e55c
28cda6a
bfb5290
add9db1
6c08a7b
acbcd5a
af606bc
41c66b8
f664c2c
5430f42
b2ab5bd
bbdf521
10e6def
2040145
1828462
5c5b8c8
05da5f3
90435c1
db41338
6c2c03d
7f6d664
f8270e2
bbf0302
a14a6bc
7b54a42
d86b8b4
6e11f67
9f5b6e5
aaef638
920a460
548d7db
9f3a486
c93f248
51fbf6c
d327569
b5e66a3
a636188
d3cafed
1b547f4
72cfd43
4d25e95
81155e6
85522aa
00336b5
6585866
aa6f28e
178a7e7
713bc7c
c576d8f
a401a0e
8102596
00d0adb
caefd53
8f6f83d
d88a991
1b57b74
7bac418
9851017
f572877
edaa7e7
588bb6a
ad180ed
72cc34b
ed50703
28f6036
a811c56
95f334c
d176314
1db9e02
089e970
6cc895c
4abe6f2
ebf188a
785e4a3
9a526c8
f08e581
51efb42
3e3cac7
7ffae6d
447e136
50d0359
b1e7521
f8a3503
272a9d5
1f9fd9e
ed705c6
c8135e5
cf5e831
8b6eab2
100f7d6
46d18d1
db23a72
1e7c119
116a6cf
ae284be
d15cb28
653aac1
92588ba
ef60e3c
8831789
3f800a1
32be863
d0fa3a9
0b969c4
040e82b
d65287d
3321926
de57f46
1a6bbb5
e627af4
fd19b43
993b813
bd3e1de
40c77ca
079c216
7a38f62
6ada5f6
8ce1ade
53ca72b
7cb1397
edcc1fc
a743386
2f15953
87e8819
c856300
2270ab6
61808e4
a0949e1
20fee2e
defb785
36fcf36
8dd17f3
1b42f14
59eb36e
33ee038
ccd5e43
f0236cc
21864d2
4da8077
a0edd32
c8db7ff
76b9913
fe98618
b4872c5
07b5a39
543bef5
531c9a6
78a4278
484d102
31ea620
2eed544
26b10c2
b1565c5
c1f661b
ee6c302
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |
|
|
||
| #include <cuvs/core/export.hpp> | ||
| #include <optional> | ||
| #include <vector> | ||
|
|
||
| namespace CUVS_EXPORT cuvs { | ||
| namespace cluster { | ||
|
|
@@ -1607,6 +1608,196 @@ void cluster_cost( | |
| * @} | ||
| */ | ||
|
|
||
| namespace mg { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One compatibility question: the public header now declares cuvs::cluster::kmeans::mg::fit unconditionally, while cpp/CMakeLists.txt only compiles kmeans_fit_mg_float.cu and kmeans_fit_mg_double.cu under BUILD_MG_ALGOS. If a non-MG build installs this header, callers can compile against mg::fit but fail at link time. Would it be better to guard those declarations or provide stubs with a clear error?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough! I'll add the guarding macro in the header itself.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am also thinking about removing the ::mg namespace and rather naming the API
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #2066 (comment) was the discussion about this.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the multi GPU implementation brings in a new API which takes a vector of mdspans and we dont want that API for a single GPU resource. |
||
| /** | ||
| * @defgroup kmeans_mg Multi-GPU / out-of-core k-means fit | ||
| * @{ | ||
| */ | ||
|
|
||
| /** | ||
| * @brief Multi-GPU k-means fit with one or more local data | ||
| * partitions per rank. | ||
| * | ||
| * Each rank supplies its local training data as a vector of partitions. The | ||
| * implementation streams every partition through Lloyd iterations using | ||
| * `params.streaming_batch_size`. | ||
|
tarang-jain marked this conversation as resolved.
Outdated
|
||
| * | ||
| * The active backend is selected by the resources attached to | ||
| * `handle`: | ||
| * - When `raft::resource::is_multi_gpu(handle)` is true (SNMG clique), the | ||
| * call must be issued from inside an OpenMP region with one thread per | ||
| * rank in the clique. | ||
| * - Otherwise, multi-process NCCL comms must be initialized on the handle | ||
| * (`raft::resource::comms_initialized(handle)`); each process supplies its | ||
| * own local partitions. | ||
| * | ||
| * @param[in] handle The raft handle. Must have NCCL comms or | ||
| * a SNMG clique initialized. | ||
| * @param[in] params K-means parameters. The streaming batch | ||
| * size is read from | ||
| * `params.streaming_batch_size`. | ||
| * @param[in] X_parts Per-partition local data on this rank. | ||
| * Each entry is [n_rows_i x n_features]. | ||
| * @param[in] sample_weight_parts Optional per-partition row weights with | ||
| * one vector per data partition. | ||
| * @param[inout] centroids Device matrix [n_clusters x n_features]. | ||
| * On entry, used as the initial centers | ||
| * when `params.init == InitMethod::Array`. | ||
| * On return, holds the converged | ||
| * centroids. | ||
| * @param[out] inertia Host scalar receiving the final | ||
| * clustering cost. | ||
| * @param[out] n_iter Host scalar receiving the iteration | ||
| * count at which the run terminated. | ||
| */ | ||
| void fit( | ||
| raft::resources const& handle, | ||
| const cuvs::cluster::kmeans::params& params, | ||
| const std::vector<raft::device_matrix_view<const float, int>>& X_parts, | ||
| const std::optional<std::vector<raft::device_vector_view<const float, int>>>& sample_weight_parts, | ||
| raft::device_matrix_view<float, int> centroids, | ||
| raft::host_scalar_view<float> inertia, | ||
| raft::host_scalar_view<int> n_iter); | ||
|
|
||
| /** | ||
| * @brief Multi-GPU k-means fit. | ||
| */ | ||
| void fit(raft::resources const& handle, | ||
| const cuvs::cluster::kmeans::params& params, | ||
| const std::vector<raft::device_matrix_view<const float, int64_t>>& X_parts, | ||
| const std::optional<std::vector<raft::device_vector_view<const float, int64_t>>>& | ||
| sample_weight_parts, | ||
| raft::device_matrix_view<float, int64_t> centroids, | ||
| raft::host_scalar_view<float> inertia, | ||
| raft::host_scalar_view<int64_t> n_iter); | ||
|
|
||
| /** | ||
| * @brief Multi-GPU k-means fit. | ||
| */ | ||
| void fit(raft::resources const& handle, | ||
| const cuvs::cluster::kmeans::params& params, | ||
| const std::vector<raft::device_matrix_view<const double, int>>& X_parts, | ||
| const std::optional<std::vector<raft::device_vector_view<const double, int>>>& | ||
| sample_weight_parts, | ||
| raft::device_matrix_view<double, int> centroids, | ||
| raft::host_scalar_view<double> inertia, | ||
| raft::host_scalar_view<int> n_iter); | ||
|
|
||
| /** | ||
| * @brief Multi-GPU k-means fit. | ||
| */ | ||
| void fit(raft::resources const& handle, | ||
| const cuvs::cluster::kmeans::params& params, | ||
| const std::vector<raft::device_matrix_view<const double, int64_t>>& X_parts, | ||
| const std::optional<std::vector<raft::device_vector_view<const double, int64_t>>>& | ||
| sample_weight_parts, | ||
| raft::device_matrix_view<double, int64_t> centroids, | ||
| raft::host_scalar_view<double> inertia, | ||
| raft::host_scalar_view<int64_t> n_iter); | ||
|
|
||
| /** | ||
| * @brief Multi-GPU / out-of-core k-means fit. | ||
| */ | ||
| void fit(raft::resources const& handle, | ||
| const cuvs::cluster::kmeans::params& params, | ||
| const std::vector<raft::host_matrix_view<const float, int64_t>>& X_parts, | ||
| const std::optional<std::vector<raft::host_vector_view<const float, int64_t>>>& | ||
| sample_weight_parts, | ||
| raft::device_matrix_view<float, int64_t> centroids, | ||
| raft::host_scalar_view<float> inertia, | ||
| raft::host_scalar_view<int64_t> n_iter); | ||
|
|
||
| /** | ||
| * @brief Multi-GPU / out-of-core k-means fit. | ||
| */ | ||
| void fit(raft::resources const& handle, | ||
| const cuvs::cluster::kmeans::params& params, | ||
| const std::vector<raft::host_matrix_view<const double, int64_t>>& X_parts, | ||
| const std::optional<std::vector<raft::host_vector_view<const double, int64_t>>>& | ||
| sample_weight_parts, | ||
| raft::device_matrix_view<double, int64_t> centroids, | ||
| raft::host_scalar_view<double> inertia, | ||
| raft::host_scalar_view<int64_t> n_iter); | ||
|
|
||
| /** | ||
| * @brief Multi-GPU k-means fit, single mdspan per rank. | ||
| * | ||
| * Convenience overload for the common case where each rank has exactly one | ||
| * local partition. The mdspan is wrapped in a one-element vector and routed | ||
| * through the vector-of-partitions overload above. See that overload's | ||
| * documentation for backend selection and handle requirements. | ||
| */ | ||
| void fit(raft::resources const& handle, | ||
| const cuvs::cluster::kmeans::params& params, | ||
| raft::device_matrix_view<const float, int> X, | ||
| std::optional<raft::device_vector_view<const float, int>> sample_weight, | ||
| raft::device_matrix_view<float, int> centroids, | ||
| raft::host_scalar_view<float> inertia, | ||
| raft::host_scalar_view<int> n_iter); | ||
|
|
||
| /** | ||
| * @brief Multi-GPU k-means fit, single mdspan per rank. | ||
| */ | ||
| void fit(raft::resources const& handle, | ||
| const cuvs::cluster::kmeans::params& params, | ||
| raft::device_matrix_view<const float, int64_t> X, | ||
| std::optional<raft::device_vector_view<const float, int64_t>> sample_weight, | ||
| raft::device_matrix_view<float, int64_t> centroids, | ||
| raft::host_scalar_view<float> inertia, | ||
| raft::host_scalar_view<int64_t> n_iter); | ||
|
|
||
| /** | ||
| * @brief Multi-GPU k-means fit, single mdspan per rank. | ||
| */ | ||
| void fit(raft::resources const& handle, | ||
| const cuvs::cluster::kmeans::params& params, | ||
| raft::device_matrix_view<const double, int> X, | ||
| std::optional<raft::device_vector_view<const double, int>> sample_weight, | ||
| raft::device_matrix_view<double, int> centroids, | ||
| raft::host_scalar_view<double> inertia, | ||
| raft::host_scalar_view<int> n_iter); | ||
|
|
||
| /** | ||
| * @brief Multi-GPU k-means fit, single mdspan per rank. | ||
| */ | ||
| void fit(raft::resources const& handle, | ||
| const cuvs::cluster::kmeans::params& params, | ||
| raft::device_matrix_view<const double, int64_t> X, | ||
| std::optional<raft::device_vector_view<const double, int64_t>> sample_weight, | ||
| raft::device_matrix_view<double, int64_t> centroids, | ||
| raft::host_scalar_view<double> inertia, | ||
| raft::host_scalar_view<int64_t> n_iter); | ||
|
|
||
| /** | ||
| * @brief Multi-GPU / out-of-core k-means fit, single mdspan per rank. | ||
| * | ||
| * Dispatches to the SNMG-clique (batched per-rank) backend when the handle | ||
| * carries an SNMG clique, and to the NCCL multi-process backend otherwise. | ||
| */ | ||
| void fit(raft::resources const& handle, | ||
| const cuvs::cluster::kmeans::params& params, | ||
| raft::host_matrix_view<const float, int64_t> X, | ||
| std::optional<raft::host_vector_view<const float, int64_t>> sample_weight, | ||
| raft::device_matrix_view<float, int64_t> centroids, | ||
| raft::host_scalar_view<float> inertia, | ||
| raft::host_scalar_view<int64_t> n_iter); | ||
|
|
||
| /** | ||
| * @brief Multi-GPU / out-of-core k-means fit, single mdspan per rank. | ||
| */ | ||
| void fit(raft::resources const& handle, | ||
| const cuvs::cluster::kmeans::params& params, | ||
| raft::host_matrix_view<const double, int64_t> X, | ||
| std::optional<raft::host_vector_view<const double, int64_t>> sample_weight, | ||
| raft::device_matrix_view<double, int64_t> centroids, | ||
| raft::host_scalar_view<double> inertia, | ||
| raft::host_scalar_view<int64_t> n_iter); | ||
|
|
||
| /** | ||
| * @} | ||
| */ | ||
| } // namespace mg | ||
|
|
||
| namespace helpers { | ||
| /** | ||
| * @defgroup kmeans_helpers k-means API helpers | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.