From edd54501e1e0d3ca84de7523e19162f508d57673 Mon Sep 17 00:00:00 2001 From: divyegala Date: Tue, 2 Dec 2025 06:07:03 -0800 Subject: [PATCH 01/17] build passing --- c/src/core/detail/interop.hpp | 2 +- cpp/cmake/thirdparty/get_raft.cmake | 4 +- cpp/include/cuvs/cluster/kmeans.hpp | 45 +++++++++++-------- cpp/include/cuvs/neighbors/common.hpp | 4 +- cpp/include/cuvs/neighbors/ivf_pq.hpp | 14 +++--- .../cuvs/neighbors/knn_merge_parts.hpp | 6 +-- cpp/src/cluster/detail/kmeans.cuh | 6 +-- cpp/src/cluster/detail/kmeans_auto_find_k.cuh | 19 ++++---- cpp/src/cluster/detail/single_linkage.cuh | 2 +- cpp/src/cluster/kmeans_fit_double.cu | 8 ++-- cpp/src/cluster/kmeans_fit_float.cu | 8 ++-- cpp/src/cluster/kmeans_fit_mg_double.cu | 10 ++--- cpp/src/cluster/kmeans_fit_mg_float.cu | 10 ++--- cpp/src/cluster/kmeans_impl_fit_predict.cuh | 20 +++++++-- cpp/src/cluster/kmeans_mg.hpp | 18 ++++---- cpp/src/cluster/kmeans_predict_double.cu | 8 ++-- cpp/src/cluster/kmeans_predict_float.cu | 9 ++-- cpp/src/neighbors/cagra.cuh | 31 ++++++------- cpp/src/neighbors/detail/cagra/add_nodes.cuh | 2 +- .../neighbors/detail/cagra/cagra_build.cuh | 35 +++++++-------- .../neighbors/detail/cagra/cagra_merge.cuh | 4 +- cpp/src/neighbors/detail/cagra/graph_core.cuh | 20 ++++----- cpp/src/neighbors/detail/knn_brute_force.cuh | 4 +- cpp/src/neighbors/detail/nn_descent.cuh | 12 ++--- cpp/src/neighbors/detail/sparse_knn.cuh | 4 +- .../neighbors/detail/vamana/greedy_search.cuh | 6 +-- .../neighbors/detail/vamana/robust_prune.cuh | 6 +-- .../neighbors/detail/vamana/vamana_build.cuh | 12 ++--- .../detail/vamana/vamana_structs.cuh | 6 +-- .../iface/iface_cagra_float_uint32_t.cu | 16 +++---- .../iface/iface_cagra_half_uint32_t.cu | 16 +++---- .../iface/iface_cagra_int8_t_uint32_t.cu | 16 +++---- .../iface/iface_cagra_uint8_t_uint32_t.cu | 16 +++---- .../iface/iface_flat_float_int64_t.cu | 16 +++---- .../iface/iface_flat_half_int64_t.cu | 14 +++--- .../iface/iface_flat_int8_t_int64_t.cu | 16 +++---- .../iface/iface_flat_uint8_t_int64_t.cu | 16 +++---- .../neighbors/iface/iface_pq_float_int64_t.cu | 16 +++---- .../neighbors/iface/iface_pq_half_int64_t.cu | 16 +++---- .../iface/iface_pq_int8_t_int64_t.cu | 16 +++---- .../iface/iface_pq_uint8_t_int64_t.cu | 16 +++---- .../detail/ivf_pq_process_and_fill_codes.cu | 2 +- cpp/src/neighbors/ivf_pq/ivf_pq_build.cuh | 2 +- .../neighbors/ivf_pq/ivf_pq_build_common.cu | 8 ++-- .../ivf_pq/ivf_pq_process_and_fill_codes.cuh | 13 +++--- .../ivf_pq_process_and_fill_codes_impl.cuh | 13 +++--- cpp/src/neighbors/knn_merge_parts.cu | 8 ++-- cpp/src/neighbors/scann/detail/scann_avq.cuh | 24 +++++----- .../neighbors/scann/detail/scann_build.cuh | 6 +-- .../neighbors/scann/detail/scann_quantize.cuh | 6 +-- .../scann/detail/scann_serialize.cuh | 4 +- cpp/src/neighbors/scann/scann.cuh | 6 +-- cpp/src/neighbors/vamana.cuh | 6 +-- cpp/src/sparse/cluster/cluster_solvers.cuh | 11 ++--- cpp/tests/cluster/kmeans.cu | 4 +- 55 files changed, 327 insertions(+), 311 deletions(-) diff --git a/c/src/core/detail/interop.hpp b/c/src/core/detail/interop.hpp index 3b94feb78d..5974d1aa15 100644 --- a/c/src/core/detail/interop.hpp +++ b/c/src/core/detail/interop.hpp @@ -129,7 +129,7 @@ inline MdspanType from_dlpack(DLManagedTensor* managed_tensor) "ndim mismatch between return mdspan and DLTensor"); // auto exts = typename MdspanType::extents_type{tensor.shape}; - std::array shape{}; + cuda::std::array shape{}; for (int64_t i = 0; i < tensor.ndim; ++i) { shape[i] = tensor.shape[i]; } diff --git a/cpp/cmake/thirdparty/get_raft.cmake b/cpp/cmake/thirdparty/get_raft.cmake index 492ae6cba1..35f5dd31d1 100644 --- a/cpp/cmake/thirdparty/get_raft.cmake +++ b/cpp/cmake/thirdparty/get_raft.cmake @@ -55,8 +55,8 @@ endfunction() # To use a different RAFT locally, set the CMake variable # CPM_raft_SOURCE=/path/to/local/raft find_and_configure_raft(VERSION ${RAFT_VERSION}.00 - FORK ${RAFT_FORK} - PINNED_TAG ${RAFT_PINNED_TAG} + FORK bdice + PINNED_TAG cccl-mdspan ENABLE_MNMG_DEPENDENCIES OFF ENABLE_NVTX OFF BUILD_STATIC_DEPS ${CUVS_STATIC_RAPIDS_LIBRARIES} diff --git a/cpp/include/cuvs/cluster/kmeans.hpp b/cpp/include/cuvs/cluster/kmeans.hpp index c87e006315..a8aa6b9807 100644 --- a/cpp/include/cuvs/cluster/kmeans.hpp +++ b/cpp/include/cuvs/cluster/kmeans.hpp @@ -181,8 +181,8 @@ void fit(raft::resources const& handle, raft::device_matrix_view X, std::optional> sample_weight, raft::device_matrix_view centroids, - raft::host_scalar_view inertia, - raft::host_scalar_view n_iter); + raft::host_scalar_view inertia, + raft::host_scalar_view n_iter); /** * @brief Find clusters with k-means algorithm. @@ -232,8 +232,8 @@ void fit(raft::resources const& handle, raft::device_matrix_view X, std::optional> sample_weight, raft::device_matrix_view centroids, - raft::host_scalar_view inertia, - raft::host_scalar_view n_iter); + raft::host_scalar_view inertia, + raft::host_scalar_view n_iter); /** * @brief Find clusters with k-means algorithm. @@ -282,8 +282,8 @@ void fit(raft::resources const& handle, raft::device_matrix_view X, std::optional> sample_weight, raft::device_matrix_view centroids, - raft::host_scalar_view inertia, - raft::host_scalar_view n_iter); + raft::host_scalar_view inertia, + raft::host_scalar_view n_iter); /** * @brief Find clusters with k-means algorithm. @@ -333,8 +333,8 @@ void fit(raft::resources const& handle, raft::device_matrix_view X, std::optional> sample_weight, raft::device_matrix_view centroids, - raft::host_scalar_view inertia, - raft::host_scalar_view n_iter); + raft::host_scalar_view inertia, + raft::host_scalar_view n_iter); /** * @brief Find clusters with k-means algorithm. @@ -383,8 +383,8 @@ void fit(raft::resources const& handle, raft::device_matrix_view X, std::optional> sample_weight, raft::device_matrix_view centroids, - raft::host_scalar_view inertia, - raft::host_scalar_view n_iter); + raft::host_scalar_view inertia, + raft::host_scalar_view n_iter); /** * @brief Find balanced clusters with k-means algorithm. @@ -581,6 +581,15 @@ void predict(raft::resources const& handle, bool normalize_weight, raft::host_scalar_view inertia); +void predict(raft::resources const& handle, + const kmeans::params& params, + raft::device_matrix_view X, + std::optional> sample_weight, + raft::device_matrix_view centroids, + raft::device_vector_view labels, + bool normalize_weight, + raft::host_scalar_view inertia); + /** * @brief Predict the closest cluster each sample in X belongs to. * @@ -632,10 +641,10 @@ void predict(raft::resources const& handle, */ void predict(raft::resources const& handle, const kmeans::params& params, - raft::device_matrix_view X, - std::optional> sample_weight, - raft::device_matrix_view centroids, - raft::device_vector_view labels, + raft::device_matrix_view X, + std::optional> sample_weight, + raft::device_matrix_view centroids, + raft::device_vector_view labels, bool normalize_weight, raft::host_scalar_view inertia); @@ -748,10 +757,10 @@ void predict(raft::resources const& handle, */ void predict(raft::resources const& handle, const kmeans::params& params, - raft::device_matrix_view X, - std::optional> sample_weight, - raft::device_matrix_view centroids, - raft::device_vector_view labels, + raft::device_matrix_view X, + std::optional> sample_weight, + raft::device_matrix_view centroids, + raft::device_vector_view labels, bool normalize_weight, raft::host_scalar_view inertia); diff --git a/cpp/include/cuvs/neighbors/common.hpp b/cpp/include/cuvs/neighbors/common.hpp index 749561896f..4f697b3604 100644 --- a/cpp/include/cuvs/neighbors/common.hpp +++ b/cpp/include/cuvs/neighbors/common.hpp @@ -248,7 +248,7 @@ auto make_strided_dataset(const raft::resources& res, const SrcT& src, uint32_t } // Something is wrong: have to make a copy and produce an owning dataset auto out_layout = - raft::make_strided_layout(src.extents(), std::array{required_stride, 1}); + raft::make_strided_layout(src.extents(), cuda::std::array{required_stride, 1}); auto out_array = raft::make_device_matrix(res, src.extent(0), required_stride); @@ -310,7 +310,7 @@ auto make_strided_dataset( const bool stride_matches = required_stride == src_stride; auto out_layout = - raft::make_strided_layout(src.extents(), std::array{required_stride, 1}); + raft::make_strided_layout(src.extents(), cuda::std::array{required_stride, 1}); using out_mdarray_type = raft::device_matrix; using out_layout_type = typename out_mdarray_type::layout_type; diff --git a/cpp/include/cuvs/neighbors/ivf_pq.hpp b/cpp/include/cuvs/neighbors/ivf_pq.hpp index 6836757cea..cfb344b04c 100644 --- a/cpp/include/cuvs/neighbors/ivf_pq.hpp +++ b/cpp/include/cuvs/neighbors/ivf_pq.hpp @@ -269,10 +269,8 @@ constexpr typename list_spec::list_extents list_spec:: { // how many elems of pq_dim fit into one kIndexGroupVecLen-byte chunk auto pq_chunk = (kIndexGroupVecLen * 8u) / pq_bits; - return raft::make_extents(raft::div_rounding_up_safe(n_rows, kIndexGroupSize), - raft::div_rounding_up_safe(pq_dim, pq_chunk), - kIndexGroupSize, - kIndexGroupVecLen); + return list_extents{raft::div_rounding_up_safe(n_rows, kIndexGroupSize), + raft::div_rounding_up_safe(pq_dim, pq_chunk)}; } template @@ -335,8 +333,8 @@ struct index : cuvs::neighbors::index { static_assert(!raft::is_narrowing_v, "IdxT must be able to represent all values of uint32_t"); - using pq_centers_extents = std::experimental:: - extents; + using pq_centers_extents = + raft::extents; public: index(const index&) = delete; @@ -2875,7 +2873,7 @@ void make_rotation_matrix(raft::resources const& res, */ void set_centers(raft::resources const& res, index* index, - raft::device_matrix_view cluster_centers); + raft::device_matrix_view cluster_centers); /** * @brief Public helper API for fetching a trained index's IVF centroids @@ -2896,7 +2894,7 @@ void set_centers(raft::resources const& res, */ void extract_centers(raft::resources const& res, const index& index, - raft::device_matrix_view cluster_centers); + raft::device_matrix_view cluster_centers); /** @copydoc extract_centers */ void extract_centers(raft::resources const& res, diff --git a/cpp/include/cuvs/neighbors/knn_merge_parts.hpp b/cpp/include/cuvs/neighbors/knn_merge_parts.hpp index 01551987fc..7581a28c7c 100644 --- a/cpp/include/cuvs/neighbors/knn_merge_parts.hpp +++ b/cpp/include/cuvs/neighbors/knn_merge_parts.hpp @@ -27,17 +27,17 @@ void knn_merge_parts(raft::resources const& res, raft::device_matrix_view inV, raft::device_matrix_view outK, raft::device_matrix_view outV, - raft::device_vector_view translations); + raft::device_vector_view translations); void knn_merge_parts(raft::resources const& res, raft::device_matrix_view inK, raft::device_matrix_view inV, raft::device_matrix_view outK, raft::device_matrix_view outV, - raft::device_vector_view translations); + raft::device_vector_view translations); void knn_merge_parts(raft::resources const& res, raft::device_matrix_view inK, raft::device_matrix_view inV, raft::device_matrix_view outK, raft::device_matrix_view outV, - raft::device_vector_view translations); + raft::device_vector_view translations); } // namespace cuvs::neighbors diff --git a/cpp/src/cluster/detail/kmeans.cuh b/cpp/src/cluster/detail/kmeans.cuh index c3096945b4..7dc3fdd963 100644 --- a/cpp/src/cluster/detail/kmeans.cuh +++ b/cpp/src/cluster/detail/kmeans.cuh @@ -1117,9 +1117,9 @@ void kmeans_predict(raft::resources const& handle, template void kmeans_transform(raft::resources const& handle, const cuvs::cluster::kmeans::params& pams, - raft::device_matrix_view X, - raft::device_matrix_view centroids, - raft::device_matrix_view X_new) + raft::device_matrix_view X, + raft::device_matrix_view centroids, + raft::device_matrix_view X_new) { raft::common::nvtx::range fun_scope("kmeans_transform"); raft::default_logger().set_level(pams.verbosity); diff --git a/cpp/src/cluster/detail/kmeans_auto_find_k.cuh b/cpp/src/cluster/detail/kmeans_auto_find_k.cuh index ae94db341d..594a63e8da 100644 --- a/cpp/src/cluster/detail/kmeans_auto_find_k.cuh +++ b/cpp/src/cluster/detail/kmeans_auto_find_k.cuh @@ -25,8 +25,8 @@ void compute_dispersion(raft::resources const& handle, raft::device_matrix_view X, cuvs::cluster::kmeans::params& params, raft::device_matrix_view centroids_view, - raft::device_vector_view labels, - raft::device_vector_view clusterSizes, + raft::device_vector_view labels, + raft::device_vector_view clusterSizes, rmm::device_uvector& workspace, raft::host_vector_view clusterDispertionView, raft::host_vector_view resultsView, @@ -109,12 +109,15 @@ void find_k(raft::resources const& handle, auto centroids_view = raft::make_device_matrix_view(centroids.data_handle(), left, d); + auto labels_view = raft::make_device_vector_view(labels.data_handle(), n); + auto clusterSizes_view = + raft::make_device_vector_view(clusterSizes.data_handle(), kmax); compute_dispersion(handle, X, params, centroids_view, - labels.view(), - clusterSizes.view(), + labels_view, + clusterSizes_view, workspace, clusterDispertionView, resultsView, @@ -133,8 +136,8 @@ void find_k(raft::resources const& handle, X, params, centroids_view, - labels.view(), - clusterSizes.view(), + labels_view, + clusterSizes_view, workspace, clusterDispertionView, resultsView, @@ -159,8 +162,8 @@ void find_k(raft::resources const& handle, X, params, centroids_view, - labels.view(), - clusterSizes.view(), + labels_view, + clusterSizes_view, workspace, clusterDispertionView, resultsView, diff --git a/cpp/src/cluster/detail/single_linkage.cuh b/cpp/src/cluster/detail/single_linkage.cuh index b095e7e73c..f8d4615c75 100644 --- a/cpp/src/cluster/detail/single_linkage.cuh +++ b/cpp/src/cluster/detail/single_linkage.cuh @@ -43,7 +43,7 @@ namespace cuvs::cluster::agglomerative::detail { template >> + typename Accessor = raft::device_accessor>> void build_mr_linkage( raft::resources const& handle, raft::mdspan, raft::row_major, Accessor> X, diff --git a/cpp/src/cluster/kmeans_fit_double.cu b/cpp/src/cluster/kmeans_fit_double.cu index 0bf06d5f31..43f457a29a 100644 --- a/cpp/src/cluster/kmeans_fit_double.cu +++ b/cpp/src/cluster/kmeans_fit_double.cu @@ -44,8 +44,8 @@ void fit(raft::resources const& handle, raft::device_matrix_view X, std::optional> sample_weight, raft::device_matrix_view centroids, - raft::host_scalar_view inertia, - raft::host_scalar_view n_iter) + raft::host_scalar_view inertia, + raft::host_scalar_view n_iter) { cuvs::cluster::kmeans::fit( handle, params, X, sample_weight, centroids, inertia, n_iter); @@ -56,8 +56,8 @@ void fit(raft::resources const& handle, raft::device_matrix_view X, std::optional> sample_weight, raft::device_matrix_view centroids, - raft::host_scalar_view inertia, - raft::host_scalar_view n_iter) + raft::host_scalar_view inertia, + raft::host_scalar_view n_iter) { cuvs::cluster::kmeans::fit( handle, params, X, sample_weight, centroids, inertia, n_iter); diff --git a/cpp/src/cluster/kmeans_fit_float.cu b/cpp/src/cluster/kmeans_fit_float.cu index 2511814427..5624151943 100644 --- a/cpp/src/cluster/kmeans_fit_float.cu +++ b/cpp/src/cluster/kmeans_fit_float.cu @@ -44,8 +44,8 @@ void fit(raft::resources const& handle, raft::device_matrix_view X, std::optional> sample_weight, raft::device_matrix_view centroids, - raft::host_scalar_view inertia, - raft::host_scalar_view n_iter) + raft::host_scalar_view inertia, + raft::host_scalar_view n_iter) { cuvs::cluster::kmeans::fit( handle, params, X, sample_weight, centroids, inertia, n_iter); @@ -56,8 +56,8 @@ void fit(raft::resources const& handle, raft::device_matrix_view X, std::optional> sample_weight, raft::device_matrix_view centroids, - raft::host_scalar_view inertia, - raft::host_scalar_view n_iter) + raft::host_scalar_view inertia, + raft::host_scalar_view n_iter) { cuvs::cluster::kmeans::fit( handle, params, X, sample_weight, centroids, inertia, n_iter); diff --git a/cpp/src/cluster/kmeans_fit_mg_double.cu b/cpp/src/cluster/kmeans_fit_mg_double.cu index 73e40742e9..bd7f8453c1 100644 --- a/cpp/src/cluster/kmeans_fit_mg_double.cu +++ b/cpp/src/cluster/kmeans_fit_mg_double.cu @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -14,8 +14,8 @@ void fit(raft::resources const& handle, raft::device_matrix_view X, std::optional> sample_weight, raft::device_matrix_view centroids, - raft::host_scalar_view inertia, - raft::host_scalar_view n_iter) + raft::host_scalar_view inertia, + raft::host_scalar_view n_iter) { rmm::device_uvector workspace(0, raft::resource::get_cuda_stream(handle)); @@ -28,8 +28,8 @@ void fit(raft::resources const& handle, raft::device_matrix_view X, std::optional> sample_weight, raft::device_matrix_view centroids, - raft::host_scalar_view inertia, - raft::host_scalar_view n_iter) + raft::host_scalar_view inertia, + raft::host_scalar_view n_iter) { rmm::device_uvector workspace(0, raft::resource::get_cuda_stream(handle)); diff --git a/cpp/src/cluster/kmeans_fit_mg_float.cu b/cpp/src/cluster/kmeans_fit_mg_float.cu index 4352e8859c..ae7c5722b7 100644 --- a/cpp/src/cluster/kmeans_fit_mg_float.cu +++ b/cpp/src/cluster/kmeans_fit_mg_float.cu @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -14,8 +14,8 @@ void fit(raft::resources const& handle, raft::device_matrix_view X, std::optional> sample_weight, raft::device_matrix_view centroids, - raft::host_scalar_view inertia, - raft::host_scalar_view n_iter) + raft::host_scalar_view inertia, + raft::host_scalar_view n_iter) { rmm::device_uvector workspace(0, raft::resource::get_cuda_stream(handle)); @@ -28,8 +28,8 @@ void fit(raft::resources const& handle, raft::device_matrix_view X, std::optional> sample_weight, raft::device_matrix_view centroids, - raft::host_scalar_view inertia, - raft::host_scalar_view n_iter) + raft::host_scalar_view inertia, + raft::host_scalar_view n_iter) { rmm::device_uvector workspace(0, raft::resource::get_cuda_stream(handle)); diff --git a/cpp/src/cluster/kmeans_impl_fit_predict.cuh b/cpp/src/cluster/kmeans_impl_fit_predict.cuh index 6489934a03..e350b7d6ed 100644 --- a/cpp/src/cluster/kmeans_impl_fit_predict.cuh +++ b/cpp/src/cluster/kmeans_impl_fit_predict.cuh @@ -26,12 +26,24 @@ void fit_predict(raft::resources const& handle, raft::make_device_matrix(handle, pams.n_clusters, n_features); cuvs::cluster::kmeans::fit( handle, pams, X, sample_weight, centroids_matrix.view(), inertia, n_iter); - cuvs::cluster::kmeans::predict( - handle, pams, X, sample_weight, centroids_matrix.view(), labels, true, inertia); + cuvs::cluster::kmeans::predict(handle, + pams, + X, + sample_weight, + raft::make_const_mdspan(centroids_matrix.view()), + labels, + true, + inertia); } else { cuvs::cluster::kmeans::fit(handle, pams, X, sample_weight, centroids.value(), inertia, n_iter); - cuvs::cluster::kmeans::predict( - handle, pams, X, sample_weight, centroids.value(), labels, true, inertia); + cuvs::cluster::kmeans::predict(handle, + pams, + X, + sample_weight, + raft::make_const_mdspan(centroids.value()), + labels, + true, + inertia); } } diff --git a/cpp/src/cluster/kmeans_mg.hpp b/cpp/src/cluster/kmeans_mg.hpp index 7281b28fec..77cceff962 100644 --- a/cpp/src/cluster/kmeans_mg.hpp +++ b/cpp/src/cluster/kmeans_mg.hpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #pragma once @@ -35,30 +35,30 @@ void fit(raft::resources const& handle, raft::device_matrix_view X, std::optional> sample_weight, raft::device_matrix_view centroids, - raft::host_scalar_view inertia, - raft::host_scalar_view n_iter); + raft::host_scalar_view inertia, + raft::host_scalar_view n_iter); void fit(raft::resources const& handle, const cuvs::cluster::kmeans::params& params, raft::device_matrix_view X, std::optional> sample_weight, raft::device_matrix_view centroids, - raft::host_scalar_view inertia, - raft::host_scalar_view n_iter); + raft::host_scalar_view inertia, + raft::host_scalar_view n_iter); void fit(raft::resources const& handle, const cuvs::cluster::kmeans::params& params, raft::device_matrix_view X, std::optional> sample_weight, raft::device_matrix_view centroids, - raft::host_scalar_view inertia, - raft::host_scalar_view n_iter); + raft::host_scalar_view inertia, + raft::host_scalar_view n_iter); void fit(raft::resources const& handle, const cuvs::cluster::kmeans::params& params, raft::device_matrix_view X, std::optional> sample_weight, raft::device_matrix_view centroids, - raft::host_scalar_view inertia, - raft::host_scalar_view n_iter); + raft::host_scalar_view inertia, + raft::host_scalar_view n_iter); } // namespace cuvs::cluster::kmeans::mg diff --git a/cpp/src/cluster/kmeans_predict_double.cu b/cpp/src/cluster/kmeans_predict_double.cu index 8d65d6fb4f..52d120a232 100644 --- a/cpp/src/cluster/kmeans_predict_double.cu +++ b/cpp/src/cluster/kmeans_predict_double.cu @@ -41,10 +41,10 @@ void predict(raft::resources const& handle, void predict(raft::resources const& handle, const kmeans::params& params, - raft::device_matrix_view X, - std::optional> sample_weight, - raft::device_matrix_view centroids, - raft::device_vector_view labels, + raft::device_matrix_view X, + std::optional> sample_weight, + raft::device_matrix_view centroids, + raft::device_vector_view labels, bool normalize_weight, raft::host_scalar_view inertia) diff --git a/cpp/src/cluster/kmeans_predict_float.cu b/cpp/src/cluster/kmeans_predict_float.cu index 0e5180fc05..30812aa141 100644 --- a/cpp/src/cluster/kmeans_predict_float.cu +++ b/cpp/src/cluster/kmeans_predict_float.cu @@ -38,12 +38,13 @@ void predict(raft::resources const& handle, cuvs::cluster::kmeans::predict( handle, params, X, sample_weight, centroids, labels, normalize_weight, inertia); } + void predict(raft::resources const& handle, const kmeans::params& params, - raft::device_matrix_view X, - std::optional> sample_weight, - raft::device_matrix_view centroids, - raft::device_vector_view labels, + raft::device_matrix_view X, + std::optional> sample_weight, + raft::device_matrix_view centroids, + raft::device_vector_view labels, bool normalize_weight, raft::host_scalar_view inertia) diff --git a/cpp/src/neighbors/cagra.cuh b/cpp/src/neighbors/cagra.cuh index cf65ef7c4d..81d181acbd 100644 --- a/cpp/src/neighbors/cagra.cuh +++ b/cpp/src/neighbors/cagra.cuh @@ -163,7 +163,7 @@ void build_knn_graph( */ template , + typename accessor = raft::host_device_accessor, raft::memory_type::device>> void build_knn_graph( raft::resources const& res, @@ -206,13 +206,12 @@ void build_knn_graph( * @param[in,out] knn_graph a matrix view (host or device) of the input knn graph [n_rows, * knn_graph_degree] */ -template < - typename DataT, - typename IdxT = uint32_t, - typename d_accessor = raft::host_device_accessor, - raft::memory_type::device>, - typename g_accessor = - raft::host_device_accessor, raft::memory_type::host>> +template , + raft::memory_type::device>, + typename g_accessor = + raft::host_device_accessor, raft::memory_type::host>> void sort_knn_graph( raft::resources const& res, cuvs::distance::DistanceType metric, @@ -222,8 +221,7 @@ void sort_knn_graph( using internal_IdxT = typename std::make_unsigned::type; using g_accessor_internal = - raft::host_device_accessor, - g_accessor::mem_type>; + raft::host_device_accessor, g_accessor::mem_type>; auto knn_graph_internal = raft::mdspan, raft::row_major, g_accessor_internal>( reinterpret_cast(knn_graph.data_handle()), @@ -251,10 +249,9 @@ void sort_knn_graph( * knn_graph_degree] * @param[out] new_graph a host matrix view of the optimized knn graph [n_rows, graph_degree] */ -template < - typename IdxT = uint32_t, - typename g_accessor = - raft::host_device_accessor, raft::memory_type::host>> +template , raft::memory_type::host>> void optimize( raft::resources const& res, raft::mdspan, raft::row_major, g_accessor> knn_graph, @@ -265,9 +262,9 @@ void optimize( } template , - raft::memory_type::host>> + typename IdxT = uint32_t, + typename Accessor = + raft::host_device_accessor, raft::memory_type::host>> index build( raft::resources const& res, const index_params& params, diff --git a/cpp/src/neighbors/detail/cagra/add_nodes.cuh b/cpp/src/neighbors/detail/cagra/add_nodes.cuh index 9d70f7848c..5a8de8454b 100644 --- a/cpp/src/neighbors/detail/cagra/add_nodes.cuh +++ b/cpp/src/neighbors/detail/cagra/add_nodes.cuh @@ -464,7 +464,7 @@ void extend_core( using out_owning_type = owning_dataset; auto out_layout = raft::make_strided_layout(updated_dataset_view.extents(), - std::array{stride, 1}); + cuda::std::array{stride, 1}); index.update_dataset(handle, out_owning_type{std::move(updated_dataset), out_layout}); } diff --git a/cpp/src/neighbors/detail/cagra/cagra_build.cuh b/cpp/src/neighbors/detail/cagra/cagra_build.cuh index 5f7389493a..675ce34c57 100644 --- a/cpp/src/neighbors/detail/cagra/cagra_build.cuh +++ b/cpp/src/neighbors/detail/cagra/cagra_build.cuh @@ -1597,13 +1597,11 @@ void build_knn_graph( size_t previous_batch_offset = 0; for (const auto& batch : vec_batches) { - // Map int64_t to uint32_t because ivf_pq requires the latter. - // TODO(tfeher): remove this mapping once ivf_pq accepts mdspan with int64_t index type - auto queries_view = raft::make_device_matrix_view( + auto queries_view = raft::make_device_matrix_view( batch.data(), batch.size(), batch.row_width()); - auto neighbors_view = raft::make_device_matrix_view( + auto neighbors_view = raft::make_device_matrix_view( neighbors.data_handle(), batch.size(), neighbors.extent(1)); - auto distances_view = raft::make_device_matrix_view( + auto distances_view = raft::make_device_matrix_view( distances.data_handle(), batch.size(), distances.extent(1)); cuvs::neighbors::ivf_pq::search( @@ -1664,7 +1662,7 @@ void build_knn_graph( gpu_top_k); } } else { - auto neighbor_candidates_view = raft::make_device_matrix_view( + auto neighbor_candidates_view = raft::make_device_matrix_view( neighbors.data_handle(), batch.size(), gpu_top_k); auto refined_neighbors_view = raft::make_device_matrix_view( refined_neighbors.data_handle(), batch.size(), top_k); @@ -1744,8 +1742,7 @@ void build_knn_graph( using internal_IdxT = typename std::make_unsigned::type; using g_accessor = typename decltype(nn_descent_idx.graph())::accessor_type; using g_accessor_internal = - raft::host_device_accessor, - g_accessor::mem_type>; + raft::host_device_accessor, g_accessor::mem_type>; auto knn_graph_internal = raft::mdspan, raft::row_major, g_accessor_internal>( @@ -1757,10 +1754,9 @@ void build_knn_graph( res, build_params.metric, dataset, knn_graph_internal); } -template < - typename IdxT = uint32_t, - typename g_accessor = - raft::host_device_accessor, raft::memory_type::host>> +template , raft::memory_type::host>> void optimize( raft::resources const& res, raft::mdspan, raft::row_major, g_accessor> knn_graph, @@ -1775,8 +1771,7 @@ void optimize( new_graph.extent(1)); using g_accessor_internal = - raft::host_device_accessor, - raft::memory_type::host>; + raft::host_device_accessor, raft::memory_type::host>; auto knn_graph_internal = raft::mdspan, raft::row_major, g_accessor_internal>( reinterpret_cast(knn_graph.data_handle()), @@ -1834,9 +1829,9 @@ struct mmap_owner { }; template , - raft::memory_type::host>> + typename IdxT = uint32_t, + typename Accessor = + raft::host_device_accessor, raft::memory_type::host>> auto iterative_build_graph( raft::resources const& res, const index_params& params, @@ -2020,9 +2015,9 @@ auto iterative_build_graph( } template , - raft::memory_type::host>> + typename IdxT = uint32_t, + typename Accessor = + raft::host_device_accessor, raft::memory_type::host>> index build( raft::resources const& res, const index_params& params, diff --git a/cpp/src/neighbors/detail/cagra/cagra_merge.cuh b/cpp/src/neighbors/detail/cagra/cagra_merge.cuh index 78c28ac16b..144b7ada56 100644 --- a/cpp/src/neighbors/detail/cagra/cagra_merge.cuh +++ b/cpp/src/neighbors/detail/cagra/cagra_merge.cuh @@ -100,7 +100,7 @@ index merge(raft::resources const& handle, using container_policy_t = typename matrix_t::container_policy_type; using owning_t = owning_dataset; auto out_layout = raft::make_strided_layout(updated_dataset.view().extents(), - std::array{stride, 1}); + cuda::std::array{stride, 1}); merged_index.update_dataset(handle, owning_t{std::move(updated_dataset), out_layout}); } RAFT_LOG_DEBUG("cagra merge: using device memory for merged dataset"); @@ -122,7 +122,7 @@ index merge(raft::resources const& handle, using container_policy_t = typename matrix_t::container_policy_type; using owning_t = owning_dataset; auto out_layout = raft::make_strided_layout(updated_dataset.view().extents(), - std::array{stride, 1}); + cuda::std::array{stride, 1}); merged_index.update_dataset(handle, owning_t{std::move(updated_dataset), out_layout}); } return merged_index; diff --git a/cpp/src/neighbors/detail/cagra/graph_core.cuh b/cpp/src/neighbors/detail/cagra/graph_core.cuh index f8091c9e51..e2e775116d 100644 --- a/cpp/src/neighbors/detail/cagra/graph_core.cuh +++ b/cpp/src/neighbors/detail/cagra/graph_core.cuh @@ -489,13 +489,12 @@ void shift_array(T* array, uint64_t num) } } // namespace -template < - typename DataT, - typename IdxT = uint32_t, - typename d_accessor = raft::host_device_accessor, - raft::memory_type::device>, - typename g_accessor = - raft::host_device_accessor, raft::memory_type::host>> +template , + raft::memory_type::device>, + typename g_accessor = + raft::host_device_accessor, raft::memory_type::host>> void sort_knn_graph( raft::resources const& res, const cuvs::distance::DistanceType metric, @@ -1157,10 +1156,9 @@ void count_2hop_detours(raft::host_matrix_view k } } -template < - typename IdxT = uint32_t, - typename g_accessor = - raft::host_device_accessor, raft::memory_type::host>> +template , raft::memory_type::host>> void optimize( raft::resources const& res, raft::mdspan, raft::row_major, g_accessor> knn_graph, diff --git a/cpp/src/neighbors/detail/knn_brute_force.cuh b/cpp/src/neighbors/detail/knn_brute_force.cuh index 118d377e7d..6dca237107 100644 --- a/cpp/src/neighbors/detail/knn_brute_force.cuh +++ b/cpp/src/neighbors/detail/knn_brute_force.cuh @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2023-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -519,7 +519,7 @@ void brute_force_knn_impl( raft::make_device_matrix_view(out_I, n, input.size() * k), raft::make_device_matrix_view(res_D, n, k), raft::make_device_matrix_view(res_I, n, k), - raft::make_device_vector_view(trans.data(), input.size())); + raft::make_device_vector_view(trans.data(), input.size())); } }; diff --git a/cpp/src/neighbors/detail/nn_descent.cuh b/cpp/src/neighbors/detail/nn_descent.cuh index db26fbe6d9..d32a022521 100644 --- a/cpp/src/neighbors/detail/nn_descent.cuh +++ b/cpp/src/neighbors/detail/nn_descent.cuh @@ -1298,9 +1298,9 @@ void GNND::build(Data_t* data, } template , - raft::memory_type::host>> + typename IdxT = uint32_t, + typename Accessor = + raft::host_device_accessor, raft::memory_type::host>> void build(raft::resources const& res, const index_params& params, raft::mdspan, raft::row_major, Accessor> dataset, @@ -1344,9 +1344,9 @@ void build(raft::resources const& res, } template , - raft::memory_type::host>> + typename IdxT = uint32_t, + typename Accessor = + raft::host_device_accessor, raft::memory_type::host>> index build( raft::resources const& res, const index_params& params, diff --git a/cpp/src/neighbors/detail/sparse_knn.cuh b/cpp/src/neighbors/detail/sparse_knn.cuh index 8432928193..f24b1d586c 100644 --- a/cpp/src/neighbors/detail/sparse_knn.cuh +++ b/cpp/src/neighbors/detail/sparse_knn.cuh @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2020-2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -335,7 +335,7 @@ class sparse_knn_t { raft::make_device_matrix_view(merge_buffer_indices, rows, 2 * k), raft::make_device_matrix_view(out_dists, rows, k), raft::make_device_matrix_view(out_indices, rows, k), - raft::make_device_vector_view(trans.data(), id_ranges.size())); + raft::make_device_vector_view(trans.data(), id_ranges.size())); } void perform_k_selection(csr_batcher_t idx_batcher, diff --git a/cpp/src/neighbors/detail/vamana/greedy_search.cuh b/cpp/src/neighbors/detail/vamana/greedy_search.cuh index 9248cf90b0..717e389c32 100644 --- a/cpp/src/neighbors/detail/vamana/greedy_search.cuh +++ b/cpp/src/neighbors/detail/vamana/greedy_search.cuh @@ -82,9 +82,9 @@ __global__ void SortPairsKernel(void* query_list_ptr, int num_queries, int topk) **********************************************************************************************/ template , - raft::memory_type::host>> + typename IdxT = uint32_t, + typename Accessor = + raft::host_device_accessor, raft::memory_type::host>> __global__ void GreedySearchKernel( raft::device_matrix_view graph, raft::mdspan, raft::row_major, Accessor> dataset, diff --git a/cpp/src/neighbors/detail/vamana/robust_prune.cuh b/cpp/src/neighbors/detail/vamana/robust_prune.cuh index 1515cd246f..9fe3c01a8c 100644 --- a/cpp/src/neighbors/detail/vamana/robust_prune.cuh +++ b/cpp/src/neighbors/detail/vamana/robust_prune.cuh @@ -51,9 +51,9 @@ namespace { **********************************************************************************************/ template , - raft::memory_type::host>> + typename IdxT = uint32_t, + typename Accessor = + raft::host_device_accessor, raft::memory_type::host>> __global__ void RobustPruneKernel( raft::device_matrix_view graph, raft::mdspan, raft::row_major, Accessor> dataset, diff --git a/cpp/src/neighbors/detail/vamana/vamana_build.cuh b/cpp/src/neighbors/detail/vamana/vamana_build.cuh index caf08d770c..9468bcc5c4 100644 --- a/cpp/src/neighbors/detail/vamana/vamana_build.cuh +++ b/cpp/src/neighbors/detail/vamana/vamana_build.cuh @@ -94,9 +94,9 @@ __global__ void print_queryIds(void* query_list_ptr) *******************************************************************************************/ template , - raft::memory_type::host>> + typename IdxT = uint32_t, + typename Accessor = + raft::host_device_accessor, raft::memory_type::host>> void batched_insert_vamana( raft::resources const& res, const index_params& params, @@ -567,9 +567,9 @@ auto quantize_all_vectors(raft::resources const& res, } template , - raft::memory_type::host>> + typename IdxT = uint64_t, + typename Accessor = + raft::host_device_accessor, raft::memory_type::host>> index build( raft::resources const& res, const index_params& params, diff --git a/cpp/src/neighbors/detail/vamana/vamana_structs.cuh b/cpp/src/neighbors/detail/vamana/vamana_structs.cuh index c14e77812a..f413020879 100644 --- a/cpp/src/neighbors/detail/vamana/vamana_structs.cuh +++ b/cpp/src/neighbors/detail/vamana/vamana_structs.cuh @@ -440,9 +440,9 @@ __global__ void populate_reverse_list_struct(QueryCandidates* revers // Recompute distances of reverse list. Allows us to avoid keeping distances during sort template , - raft::memory_type::host>> + typename IdxT = uint32_t, + typename Accessor = + raft::host_device_accessor, raft::memory_type::host>> __global__ void recompute_reverse_dists( QueryCandidates* reverse_list, raft::mdspan, raft::row_major, Accessor> dataset, diff --git a/cpp/src/neighbors/iface/iface_cagra_float_uint32_t.cu b/cpp/src/neighbors/iface/iface_cagra_float_uint32_t.cu index 10d0d51067..4817452ca3 100644 --- a/cpp/src/neighbors/iface/iface_cagra_float_uint32_t.cu +++ b/cpp/src/neighbors/iface/iface_cagra_float_uint32_t.cu @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -17,14 +17,14 @@ namespace cuvs::neighbors { #define CUVS_INST_MG_CAGRA(T, IdxT) \ - using T_ha = raft::host_device_accessor, \ + using T_ha = \ + raft::host_device_accessor, raft::memory_type::device>; \ + using T_da = \ + raft::host_device_accessor, raft::memory_type::host>; \ + using IdxT_ha = raft::host_device_accessor, \ raft::memory_type::device>; \ - using T_da = raft::host_device_accessor, \ - raft::memory_type::host>; \ - using IdxT_ha = raft::host_device_accessor, \ - raft::memory_type::device>; \ - using IdxT_da = raft::host_device_accessor, \ - raft::memory_type::host>; \ + using IdxT_da = \ + raft::host_device_accessor, raft::memory_type::host>; \ \ template void build( \ const raft::resources& handle, \ diff --git a/cpp/src/neighbors/iface/iface_cagra_half_uint32_t.cu b/cpp/src/neighbors/iface/iface_cagra_half_uint32_t.cu index 4e6773f887..2c0c6d050b 100644 --- a/cpp/src/neighbors/iface/iface_cagra_half_uint32_t.cu +++ b/cpp/src/neighbors/iface/iface_cagra_half_uint32_t.cu @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -17,14 +17,14 @@ namespace cuvs::neighbors { #define CUVS_INST_MG_CAGRA(T, IdxT) \ - using T_ha = raft::host_device_accessor, \ + using T_ha = \ + raft::host_device_accessor, raft::memory_type::device>; \ + using T_da = \ + raft::host_device_accessor, raft::memory_type::host>; \ + using IdxT_ha = raft::host_device_accessor, \ raft::memory_type::device>; \ - using T_da = raft::host_device_accessor, \ - raft::memory_type::host>; \ - using IdxT_ha = raft::host_device_accessor, \ - raft::memory_type::device>; \ - using IdxT_da = raft::host_device_accessor, \ - raft::memory_type::host>; \ + using IdxT_da = \ + raft::host_device_accessor, raft::memory_type::host>; \ \ template void build( \ const raft::resources& handle, \ diff --git a/cpp/src/neighbors/iface/iface_cagra_int8_t_uint32_t.cu b/cpp/src/neighbors/iface/iface_cagra_int8_t_uint32_t.cu index 877536a25f..2cea26f515 100644 --- a/cpp/src/neighbors/iface/iface_cagra_int8_t_uint32_t.cu +++ b/cpp/src/neighbors/iface/iface_cagra_int8_t_uint32_t.cu @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -17,14 +17,14 @@ namespace cuvs::neighbors { #define CUVS_INST_MG_CAGRA(T, IdxT) \ - using T_ha = raft::host_device_accessor, \ + using T_ha = \ + raft::host_device_accessor, raft::memory_type::device>; \ + using T_da = \ + raft::host_device_accessor, raft::memory_type::host>; \ + using IdxT_ha = raft::host_device_accessor, \ raft::memory_type::device>; \ - using T_da = raft::host_device_accessor, \ - raft::memory_type::host>; \ - using IdxT_ha = raft::host_device_accessor, \ - raft::memory_type::device>; \ - using IdxT_da = raft::host_device_accessor, \ - raft::memory_type::host>; \ + using IdxT_da = \ + raft::host_device_accessor, raft::memory_type::host>; \ \ template void build( \ const raft::resources& handle, \ diff --git a/cpp/src/neighbors/iface/iface_cagra_uint8_t_uint32_t.cu b/cpp/src/neighbors/iface/iface_cagra_uint8_t_uint32_t.cu index bb15489849..a8d719ab80 100644 --- a/cpp/src/neighbors/iface/iface_cagra_uint8_t_uint32_t.cu +++ b/cpp/src/neighbors/iface/iface_cagra_uint8_t_uint32_t.cu @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -17,14 +17,14 @@ namespace cuvs::neighbors { #define CUVS_INST_MG_CAGRA(T, IdxT) \ - using T_ha = raft::host_device_accessor, \ + using T_ha = \ + raft::host_device_accessor, raft::memory_type::device>; \ + using T_da = \ + raft::host_device_accessor, raft::memory_type::host>; \ + using IdxT_ha = raft::host_device_accessor, \ raft::memory_type::device>; \ - using T_da = raft::host_device_accessor, \ - raft::memory_type::host>; \ - using IdxT_ha = raft::host_device_accessor, \ - raft::memory_type::device>; \ - using IdxT_da = raft::host_device_accessor, \ - raft::memory_type::host>; \ + using IdxT_da = \ + raft::host_device_accessor, raft::memory_type::host>; \ \ template void build( \ const raft::resources& handle, \ diff --git a/cpp/src/neighbors/iface/iface_flat_float_int64_t.cu b/cpp/src/neighbors/iface/iface_flat_float_int64_t.cu index 26dc7e24ab..d497a4cbd0 100644 --- a/cpp/src/neighbors/iface/iface_flat_float_int64_t.cu +++ b/cpp/src/neighbors/iface/iface_flat_float_int64_t.cu @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -17,14 +17,14 @@ namespace cuvs::neighbors { #define CUVS_INST_MG_FLAT(T, IdxT) \ - using T_ha = raft::host_device_accessor, \ + using T_ha = \ + raft::host_device_accessor, raft::memory_type::device>; \ + using T_da = \ + raft::host_device_accessor, raft::memory_type::host>; \ + using IdxT_ha = raft::host_device_accessor, \ raft::memory_type::device>; \ - using T_da = raft::host_device_accessor, \ - raft::memory_type::host>; \ - using IdxT_ha = raft::host_device_accessor, \ - raft::memory_type::device>; \ - using IdxT_da = raft::host_device_accessor, \ - raft::memory_type::host>; \ + using IdxT_da = \ + raft::host_device_accessor, raft::memory_type::host>; \ \ template void build( \ const raft::resources& handle, \ diff --git a/cpp/src/neighbors/iface/iface_flat_half_int64_t.cu b/cpp/src/neighbors/iface/iface_flat_half_int64_t.cu index 5b0e8d8af7..76e8debf3c 100644 --- a/cpp/src/neighbors/iface/iface_flat_half_int64_t.cu +++ b/cpp/src/neighbors/iface/iface_flat_half_int64_t.cu @@ -17,14 +17,14 @@ namespace cuvs::neighbors { #define CUVS_INST_MG_FLAT(T, IdxT) \ - using T_ha = raft::host_device_accessor, \ + using T_ha = \ + raft::host_device_accessor, raft::memory_type::device>; \ + using T_da = \ + raft::host_device_accessor, raft::memory_type::host>; \ + using IdxT_ha = raft::host_device_accessor, \ raft::memory_type::device>; \ - using T_da = raft::host_device_accessor, \ - raft::memory_type::host>; \ - using IdxT_ha = raft::host_device_accessor, \ - raft::memory_type::device>; \ - using IdxT_da = raft::host_device_accessor, \ - raft::memory_type::host>; \ + using IdxT_da = \ + raft::host_device_accessor, raft::memory_type::host>; \ \ template void build( \ const raft::resources& handle, \ diff --git a/cpp/src/neighbors/iface/iface_flat_int8_t_int64_t.cu b/cpp/src/neighbors/iface/iface_flat_int8_t_int64_t.cu index 408f71a9e0..eb6f740fcc 100644 --- a/cpp/src/neighbors/iface/iface_flat_int8_t_int64_t.cu +++ b/cpp/src/neighbors/iface/iface_flat_int8_t_int64_t.cu @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -17,14 +17,14 @@ namespace cuvs::neighbors { #define CUVS_INST_MG_FLAT(T, IdxT) \ - using T_ha = raft::host_device_accessor, \ + using T_ha = \ + raft::host_device_accessor, raft::memory_type::device>; \ + using T_da = \ + raft::host_device_accessor, raft::memory_type::host>; \ + using IdxT_ha = raft::host_device_accessor, \ raft::memory_type::device>; \ - using T_da = raft::host_device_accessor, \ - raft::memory_type::host>; \ - using IdxT_ha = raft::host_device_accessor, \ - raft::memory_type::device>; \ - using IdxT_da = raft::host_device_accessor, \ - raft::memory_type::host>; \ + using IdxT_da = \ + raft::host_device_accessor, raft::memory_type::host>; \ \ template void build( \ const raft::resources& handle, \ diff --git a/cpp/src/neighbors/iface/iface_flat_uint8_t_int64_t.cu b/cpp/src/neighbors/iface/iface_flat_uint8_t_int64_t.cu index e820f5bdb2..392b5b306f 100644 --- a/cpp/src/neighbors/iface/iface_flat_uint8_t_int64_t.cu +++ b/cpp/src/neighbors/iface/iface_flat_uint8_t_int64_t.cu @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -17,14 +17,14 @@ namespace cuvs::neighbors { #define CUVS_INST_MG_FLAT(T, IdxT) \ - using T_ha = raft::host_device_accessor, \ + using T_ha = \ + raft::host_device_accessor, raft::memory_type::device>; \ + using T_da = \ + raft::host_device_accessor, raft::memory_type::host>; \ + using IdxT_ha = raft::host_device_accessor, \ raft::memory_type::device>; \ - using T_da = raft::host_device_accessor, \ - raft::memory_type::host>; \ - using IdxT_ha = raft::host_device_accessor, \ - raft::memory_type::device>; \ - using IdxT_da = raft::host_device_accessor, \ - raft::memory_type::host>; \ + using IdxT_da = \ + raft::host_device_accessor, raft::memory_type::host>; \ \ template void build( \ const raft::resources& handle, \ diff --git a/cpp/src/neighbors/iface/iface_pq_float_int64_t.cu b/cpp/src/neighbors/iface/iface_pq_float_int64_t.cu index 204f47a948..0f0395e8a6 100644 --- a/cpp/src/neighbors/iface/iface_pq_float_int64_t.cu +++ b/cpp/src/neighbors/iface/iface_pq_float_int64_t.cu @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -17,14 +17,14 @@ namespace cuvs::neighbors { #define CUVS_INST_MG_PQ(T, IdxT) \ - using T_ha = raft::host_device_accessor, \ + using T_ha = \ + raft::host_device_accessor, raft::memory_type::device>; \ + using T_da = \ + raft::host_device_accessor, raft::memory_type::host>; \ + using IdxT_ha = raft::host_device_accessor, \ raft::memory_type::device>; \ - using T_da = raft::host_device_accessor, \ - raft::memory_type::host>; \ - using IdxT_ha = raft::host_device_accessor, \ - raft::memory_type::device>; \ - using IdxT_da = raft::host_device_accessor, \ - raft::memory_type::host>; \ + using IdxT_da = \ + raft::host_device_accessor, raft::memory_type::host>; \ \ template void build( \ const raft::resources& handle, \ diff --git a/cpp/src/neighbors/iface/iface_pq_half_int64_t.cu b/cpp/src/neighbors/iface/iface_pq_half_int64_t.cu index 782ea1ffb7..b605150b5d 100644 --- a/cpp/src/neighbors/iface/iface_pq_half_int64_t.cu +++ b/cpp/src/neighbors/iface/iface_pq_half_int64_t.cu @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -17,14 +17,14 @@ namespace cuvs::neighbors { #define CUVS_INST_MG_PQ(T, IdxT) \ - using T_ha = raft::host_device_accessor, \ + using T_ha = \ + raft::host_device_accessor, raft::memory_type::device>; \ + using T_da = \ + raft::host_device_accessor, raft::memory_type::host>; \ + using IdxT_ha = raft::host_device_accessor, \ raft::memory_type::device>; \ - using T_da = raft::host_device_accessor, \ - raft::memory_type::host>; \ - using IdxT_ha = raft::host_device_accessor, \ - raft::memory_type::device>; \ - using IdxT_da = raft::host_device_accessor, \ - raft::memory_type::host>; \ + using IdxT_da = \ + raft::host_device_accessor, raft::memory_type::host>; \ \ template void build( \ const raft::resources& handle, \ diff --git a/cpp/src/neighbors/iface/iface_pq_int8_t_int64_t.cu b/cpp/src/neighbors/iface/iface_pq_int8_t_int64_t.cu index 73b1405364..129e8d254a 100644 --- a/cpp/src/neighbors/iface/iface_pq_int8_t_int64_t.cu +++ b/cpp/src/neighbors/iface/iface_pq_int8_t_int64_t.cu @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -17,14 +17,14 @@ namespace cuvs::neighbors { #define CUVS_INST_MG_PQ(T, IdxT) \ - using T_ha = raft::host_device_accessor, \ + using T_ha = \ + raft::host_device_accessor, raft::memory_type::device>; \ + using T_da = \ + raft::host_device_accessor, raft::memory_type::host>; \ + using IdxT_ha = raft::host_device_accessor, \ raft::memory_type::device>; \ - using T_da = raft::host_device_accessor, \ - raft::memory_type::host>; \ - using IdxT_ha = raft::host_device_accessor, \ - raft::memory_type::device>; \ - using IdxT_da = raft::host_device_accessor, \ - raft::memory_type::host>; \ + using IdxT_da = \ + raft::host_device_accessor, raft::memory_type::host>; \ \ template void build( \ const raft::resources& handle, \ diff --git a/cpp/src/neighbors/iface/iface_pq_uint8_t_int64_t.cu b/cpp/src/neighbors/iface/iface_pq_uint8_t_int64_t.cu index bc76cd3991..8bbbed7597 100644 --- a/cpp/src/neighbors/iface/iface_pq_uint8_t_int64_t.cu +++ b/cpp/src/neighbors/iface/iface_pq_uint8_t_int64_t.cu @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -17,14 +17,14 @@ namespace cuvs::neighbors { #define CUVS_INST_MG_PQ(T, IdxT) \ - using T_ha = raft::host_device_accessor, \ + using T_ha = \ + raft::host_device_accessor, raft::memory_type::device>; \ + using T_da = \ + raft::host_device_accessor, raft::memory_type::host>; \ + using IdxT_ha = raft::host_device_accessor, \ raft::memory_type::device>; \ - using T_da = raft::host_device_accessor, \ - raft::memory_type::host>; \ - using IdxT_ha = raft::host_device_accessor, \ - raft::memory_type::device>; \ - using IdxT_da = raft::host_device_accessor, \ - raft::memory_type::host>; \ + using IdxT_da = \ + raft::host_device_accessor, raft::memory_type::host>; \ \ template void build( \ const raft::resources& handle, \ diff --git a/cpp/src/neighbors/ivf_pq/detail/ivf_pq_process_and_fill_codes.cu b/cpp/src/neighbors/ivf_pq/detail/ivf_pq_process_and_fill_codes.cu index f67677080a..e7d74b81bf 100644 --- a/cpp/src/neighbors/ivf_pq/detail/ivf_pq_process_and_fill_codes.cu +++ b/cpp/src/neighbors/ivf_pq/detail/ivf_pq_process_and_fill_codes.cu @@ -10,7 +10,7 @@ template void cuvs::neighbors::ivf_pq::detail::launch_process_and_fill_codes_kernel( \ raft::resources const& handle, \ cuvs::neighbors::ivf_pq::index& index, \ - raft::device_matrix_view new_vectors_residual, \ + raft::device_matrix_view new_vectors_residual, \ std::variant src_offset_or_indices, \ const uint32_t* new_labels, \ IdxT n_rows); diff --git a/cpp/src/neighbors/ivf_pq/ivf_pq_build.cuh b/cpp/src/neighbors/ivf_pq/ivf_pq_build.cuh index 31f2a12989..ad0792af09 100644 --- a/cpp/src/neighbors/ivf_pq/ivf_pq_build.cuh +++ b/cpp/src/neighbors/ivf_pq/ivf_pq_build.cuh @@ -1414,7 +1414,7 @@ auto build(raft::resources const& handle, // Make rotation matrix helpers::make_rotation_matrix(handle, &index, params.force_random_rotation); - helpers::set_centers(handle, &index, raft::make_const_mdspan(centers_view)); + helpers::set_centers(handle, &index, centers_const_view); // Train PQ codebooks switch (index.codebook_kind()) { diff --git a/cpp/src/neighbors/ivf_pq/ivf_pq_build_common.cu b/cpp/src/neighbors/ivf_pq/ivf_pq_build_common.cu index 983d0d8b95..f3f0ae311a 100644 --- a/cpp/src/neighbors/ivf_pq/ivf_pq_build_common.cu +++ b/cpp/src/neighbors/ivf_pq/ivf_pq_build_common.cu @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2022-2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -269,7 +269,7 @@ void make_rotation_matrix(raft::resources const& res, void set_centers(raft::resources const& handle, index* index, - raft::device_matrix_view cluster_centers) + raft::device_matrix_view cluster_centers) { RAFT_EXPECTS(cluster_centers.extent(0) == index->n_lists(), "Number of rows in the new centers must be equal to the number of IVF lists"); @@ -281,14 +281,14 @@ void set_centers(raft::resources const& handle, void extract_centers(raft::resources const& res, const cuvs::neighbors::ivf_pq::index& index, - raft::device_matrix_view cluster_centers) + raft::device_matrix_view cluster_centers) { detail::extract_centers(res, index, cluster_centers); } void extract_centers(raft::resources const& res, const cuvs::neighbors::ivf_pq::index& index, - raft::host_matrix_view cluster_centers) + raft::host_matrix_view cluster_centers) { detail::extract_centers(res, index, cluster_centers); } diff --git a/cpp/src/neighbors/ivf_pq/ivf_pq_process_and_fill_codes.cuh b/cpp/src/neighbors/ivf_pq/ivf_pq_process_and_fill_codes.cuh index 3ecfb22f5d..3102bf3c0d 100644 --- a/cpp/src/neighbors/ivf_pq/ivf_pq_process_and_fill_codes.cuh +++ b/cpp/src/neighbors/ivf_pq/ivf_pq_process_and_fill_codes.cuh @@ -127,11 +127,12 @@ struct encode_vectors { }; template -void launch_process_and_fill_codes_kernel(raft::resources const& handle, - index& index, - raft::device_matrix_view new_vectors_residual, - std::variant src_offset_or_indices, - const uint32_t* new_labels, - IdxT n_rows); +void launch_process_and_fill_codes_kernel( + raft::resources const& handle, + index& index, + raft::device_matrix_view new_vectors_residual, + std::variant src_offset_or_indices, + const uint32_t* new_labels, + IdxT n_rows); } // namespace cuvs::neighbors::ivf_pq::detail diff --git a/cpp/src/neighbors/ivf_pq/ivf_pq_process_and_fill_codes_impl.cuh b/cpp/src/neighbors/ivf_pq/ivf_pq_process_and_fill_codes_impl.cuh index 7496064e47..ea56b79426 100644 --- a/cpp/src/neighbors/ivf_pq/ivf_pq_process_and_fill_codes_impl.cuh +++ b/cpp/src/neighbors/ivf_pq/ivf_pq_process_and_fill_codes_impl.cuh @@ -61,12 +61,13 @@ __launch_bounds__(BlockSize) static __global__ void process_and_fill_codes_kerne } template -void launch_process_and_fill_codes_kernel(raft::resources const& handle, - index& index, - raft::device_matrix_view new_vectors_residual, - std::variant src_offset_or_indices, - const uint32_t* new_labels, - IdxT n_rows) +void launch_process_and_fill_codes_kernel( + raft::resources const& handle, + index& index, + raft::device_matrix_view new_vectors_residual, + std::variant src_offset_or_indices, + const uint32_t* new_labels, + IdxT n_rows) { constexpr uint32_t kBlockSize = 256; const uint32_t threads_per_vec = std::min(raft::WarpSize, index.pq_book_size()); diff --git a/cpp/src/neighbors/knn_merge_parts.cu b/cpp/src/neighbors/knn_merge_parts.cu index fcac8d2a7f..da7110a475 100644 --- a/cpp/src/neighbors/knn_merge_parts.cu +++ b/cpp/src/neighbors/knn_merge_parts.cu @@ -15,7 +15,7 @@ void _knn_merge_parts(raft::resources const& res, raft::device_matrix_view inV, raft::device_matrix_view outK, raft::device_matrix_view outV, - raft::device_vector_view translations) + raft::device_vector_view translations) { auto parts = translations.extent(0); auto rows = outK.extent(0); @@ -38,7 +38,7 @@ void knn_merge_parts(raft::resources const& res, raft::device_matrix_view inV, raft::device_matrix_view outK, raft::device_matrix_view outV, - raft::device_vector_view translations) + raft::device_vector_view translations) { _knn_merge_parts(res, inK, inV, outK, outV, translations); } @@ -47,7 +47,7 @@ void knn_merge_parts(raft::resources const& res, raft::device_matrix_view inV, raft::device_matrix_view outK, raft::device_matrix_view outV, - raft::device_vector_view translations) + raft::device_vector_view translations) { _knn_merge_parts(res, inK, inV, outK, outV, translations); } @@ -56,7 +56,7 @@ void knn_merge_parts(raft::resources const& res, raft::device_matrix_view inV, raft::device_matrix_view outK, raft::device_matrix_view outV, - raft::device_vector_view translations) + raft::device_vector_view translations) { _knn_merge_parts(res, inK, inV, outK, outV, translations); } diff --git a/cpp/src/neighbors/scann/detail/scann_avq.cuh b/cpp/src/neighbors/scann/detail/scann_avq.cuh index 95f2d84499..3e8238c5e2 100644 --- a/cpp/src/neighbors/scann/detail/scann_avq.cuh +++ b/cpp/src/neighbors/scann/detail/scann_avq.cuh @@ -395,8 +395,8 @@ class cluster_loader { raft::device_matrix d_cluster_buf_; raft::device_matrix d_cluster_copy_buf_; const T* dataset_ptr_; - raft::host_vector_view h_cluster_offsets_; - raft::device_vector_view cluster_ids_; + raft::host_vector_view h_cluster_offsets_; + raft::device_vector_view cluster_ids_; cudaStream_t stream_; int64_t dim_; int64_t n_rows_; @@ -419,8 +419,8 @@ class cluster_loader { int64_t n_rows, int64_t max_cluster_size, int64_t h_buf_size, - raft::host_vector_view h_cluster_offsets, - raft::device_vector_view cluster_ids, + raft::host_vector_view h_cluster_offsets, + raft::device_vector_view cluster_ids, bool needs_copy, cudaStream_t stream) : dim_(dim), @@ -440,8 +440,8 @@ class cluster_loader { public: cluster_loader(raft::resources const& res, raft::device_matrix_view dataset_view, - raft::host_vector_view h_cluster_offsets, - raft::device_vector_view cluster_ids, + raft::host_vector_view h_cluster_offsets, + raft::device_vector_view cluster_ids, int64_t max_cluster_size, cudaStream_t stream) : cluster_loader(res, @@ -460,8 +460,8 @@ class cluster_loader { cluster_loader(raft::resources const& res, raft::host_matrix_view dataset_view, - raft::host_vector_view h_cluster_offsets, - raft::device_vector_view cluster_ids, + raft::host_vector_view h_cluster_offsets, + raft::device_vector_view cluster_ids, int64_t max_cluster_size, cudaStream_t stream) : cluster_loader(res, @@ -577,10 +577,10 @@ class cluster_loader { * @param eta the weight for the parallel component of the residual in the avq update */ template , - raft::memory_type::host>> + typename IdxT = int64_t, + typename LabelT = uint32_t, + typename Accessor = + raft::host_device_accessor, raft::memory_type::host>> void apply_avq(raft::resources const& res, raft::mdspan, raft::row_major, Accessor> dataset, raft::device_matrix_view centroids_view, diff --git a/cpp/src/neighbors/scann/detail/scann_build.cuh b/cpp/src/neighbors/scann/detail/scann_build.cuh index 2c5163286c..8902fc2051 100644 --- a/cpp/src/neighbors/scann/detail/scann_build.cuh +++ b/cpp/src/neighbors/scann/detail/scann_build.cuh @@ -34,9 +34,9 @@ using namespace cuvs::spatial::knn::detail; // NOLINT */ template , - raft::memory_type::host>> + typename IdxT = int64_t, + typename Accessor = + raft::host_device_accessor, raft::memory_type::host>> index build( raft::resources const& res, const index_params& params, diff --git a/cpp/src/neighbors/scann/detail/scann_quantize.cuh b/cpp/src/neighbors/scann/detail/scann_quantize.cuh index 69c7ca08e8..0b122d38b6 100644 --- a/cpp/src/neighbors/scann/detail/scann_quantize.cuh +++ b/cpp/src/neighbors/scann/detail/scann_quantize.cuh @@ -326,7 +326,7 @@ template __launch_bounds__(BlockSize) RAFT_KERNEL quantize_bfloat16_noise_shaped_kernel(raft::device_matrix_view dataset, raft::device_matrix_view bf16_dataset, - raft::device_vector_view sq_norms, + raft::device_vector_view sq_norms, float noise_shaping_threshold) { IdxT row_idx = raft::Pow2<32>::div(IdxT{threadIdx.x} + IdxT{BlockSize} * IdxT{blockIdx.x}); @@ -516,8 +516,8 @@ void quantize_bfloat16(raft::resources const& res, */ template , - raft::memory_type::host>> + typename Accessor = + raft::host_device_accessor, raft::memory_type::host>> auto sample_training_residuals( raft::resources const& res, random::RngState random_state, diff --git a/cpp/src/neighbors/scann/detail/scann_serialize.cuh b/cpp/src/neighbors/scann/detail/scann_serialize.cuh index 8da1e0d9fc..c3b4fdf357 100644 --- a/cpp/src/neighbors/scann/detail/scann_serialize.cuh +++ b/cpp/src/neighbors/scann/detail/scann_serialize.cuh @@ -39,8 +39,8 @@ std::ofstream open_file(std::string file_name) // Helper for serializing device/host matrix to a given file template , - raft::memory_type::host>> + typename Accessor = + raft::host_device_accessor, raft::memory_type::host>> void serialize_matrix( raft::resources const& res, std::filesystem::path file_path, diff --git a/cpp/src/neighbors/scann/scann.cuh b/cpp/src/neighbors/scann/scann.cuh index e6844bc44e..56b302e3f9 100644 --- a/cpp/src/neighbors/scann/scann.cuh +++ b/cpp/src/neighbors/scann/scann.cuh @@ -53,9 +53,9 @@ namespace cuvs::neighbors::experimental::scann { * @return the constructed scann index */ template , - raft::memory_type::host>> + typename IdxT = uint32_t, + typename Accessor = + raft::host_device_accessor, raft::memory_type::host>> index build( raft::resources const& res, const index_params& params, diff --git a/cpp/src/neighbors/vamana.cuh b/cpp/src/neighbors/vamana.cuh index 65fd54ca83..d2a73809ed 100644 --- a/cpp/src/neighbors/vamana.cuh +++ b/cpp/src/neighbors/vamana.cuh @@ -67,9 +67,9 @@ namespace cuvs::neighbors::vamana { * @return the constructed vamana index */ template , - raft::memory_type::host>> + typename IdxT = uint32_t, + typename Accessor = + raft::host_device_accessor, raft::memory_type::host>> index build( raft::resources const& res, const index_params& params, diff --git a/cpp/src/sparse/cluster/cluster_solvers.cuh b/cpp/src/sparse/cluster/cluster_solvers.cuh index 6df61b4696..0b6044453d 100644 --- a/cpp/src/sparse/cluster/cluster_solvers.cuh +++ b/cpp/src/sparse/cluster/cluster_solvers.cuh @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2019-2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -55,8 +55,8 @@ struct kmeans_solver_t { km_params.max_iter = config_.maxIter; km_params.rng_state.seed = config_.seed; - auto X = raft::make_device_matrix_view(obs, n_obs_vecs, dim); - auto labels = raft::make_device_vector_view(codes, n_obs_vecs); + auto X = raft::make_device_matrix_view(obs, n_obs_vecs, dim); + auto labels = raft::make_device_vector_view(codes, n_obs_vecs); auto centroids = raft::make_device_matrix(handle, config_.n_clusters, dim); auto weight = raft::make_device_vector(handle, n_obs_vecs); @@ -65,12 +65,13 @@ struct kmeans_solver_t { weight.data_handle() + n_obs_vecs, 1); - auto sw = std::make_optional((raft::device_vector_view)weight.view()); + auto sw = + std::make_optional((raft::device_vector_view)weight.view()); cuvs::cluster::kmeans::fit_predict(handle, km_params, X, sw, - centroids.view(), + std::make_optional(centroids.view()), labels, raft::make_host_scalar_view(&residual), raft::make_host_scalar_view(&iters)); diff --git a/cpp/tests/cluster/kmeans.cu b/cpp/tests/cluster/kmeans.cu index bb4868a54c..05668ff4da 100644 --- a/cpp/tests/cluster/kmeans.cu +++ b/cpp/tests/cluster/kmeans.cu @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2022-2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -256,7 +256,7 @@ class KmeansTest : public ::testing::TestWithParam> { d_labels_ref.resize(n_samples, stream); d_centroids.resize(params.n_clusters * n_features, stream); - std::optional> d_sw = std::nullopt; + std::optional> d_sw = std::nullopt; auto d_centroids_view = raft::make_device_matrix_view(d_centroids.data(), params.n_clusters, n_features); if (testparams.weighted) { From 59e50e20e3d2a0840cd75108081a9735ec5e3b62 Mon Sep 17 00:00:00 2001 From: divyegala Date: Wed, 3 Dec 2025 03:46:04 -0800 Subject: [PATCH 02/17] use ci artifacts --- ci/build_cpp.sh | 2 ++ ci/build_docs.sh | 2 ++ ci/build_go.sh | 4 +++- ci/build_java.sh | 2 ++ ci/build_python.sh | 2 ++ ci/build_rust.sh | 4 +++- ci/build_wheel.sh | 1 + ci/test_cpp.sh | 2 ++ ci/test_python.sh | 2 ++ ci/test_wheel_cuvs.sh | 2 ++ ci/use_conda_packages_from_prs.sh | 28 ++++++++++++++++++++++++++++ ci/use_wheels_from_prs.sh | 18 ++++++++++++++++++ 12 files changed, 67 insertions(+), 2 deletions(-) create mode 100755 ci/use_conda_packages_from_prs.sh create mode 100755 ci/use_wheels_from_prs.sh diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index 94092f0dd0..86894d51bf 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -8,6 +8,8 @@ source rapids-configure-sccache source rapids-date-string +source ./ci/use_conda_packages_from_prs.sh + export CMAKE_GENERATOR=Ninja rapids-print-env diff --git a/ci/build_docs.sh b/ci/build_docs.sh index a4eea8b915..7d819f8916 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -4,6 +4,8 @@ set -euo pipefail +source ./ci/use_conda_packages_from_prs.sh + rapids-logger "Downloading artifacts from previous jobs" CPP_CHANNEL=$(rapids-download-conda-from-github cpp) PYTHON_CHANNEL=$(rapids-download-conda-from-github python) diff --git a/ci/build_go.sh b/ci/build_go.sh index 5e9cac68bc..150f2b7817 100755 --- a/ci/build_go.sh +++ b/ci/build_go.sh @@ -1,9 +1,11 @@ #!/bin/bash -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 set -euo pipefail +source ./ci/use_conda_packages_from_prs.sh + rapids-logger "Downloading artifacts from previous jobs" CPP_CHANNEL=$(rapids-download-conda-from-github cpp) diff --git a/ci/build_java.sh b/ci/build_java.sh index d5352910f8..5beabcdeeb 100755 --- a/ci/build_java.sh +++ b/ci/build_java.sh @@ -4,6 +4,8 @@ set -euo pipefail +source ./ci/use_conda_packages_from_prs.sh + # TODO: Remove this argument-handling when build and test workflows are separated, # and test_java.sh no longer calls build_java.sh # ref: https://github.com/rapidsai/cuvs/issues/868 diff --git a/ci/build_python.sh b/ci/build_python.sh index f6035c2e1a..d1c7583ea8 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -8,6 +8,8 @@ source rapids-configure-sccache source rapids-date-string +source ./ci/use_conda_packages_from_prs.sh + export CMAKE_GENERATOR=Ninja rapids-print-env diff --git a/ci/build_rust.sh b/ci/build_rust.sh index adba4bd71f..a458f1d3fe 100755 --- a/ci/build_rust.sh +++ b/ci/build_rust.sh @@ -1,9 +1,11 @@ #!/bin/bash -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 set -euo pipefail +source ./ci/use_conda_packages_from_prs.sh + rapids-logger "Downloading artifacts from previous jobs" CPP_CHANNEL=$(rapids-download-conda-from-github cpp) diff --git a/ci/build_wheel.sh b/ci/build_wheel.sh index f3dcb91364..19a78a85f6 100755 --- a/ci/build_wheel.sh +++ b/ci/build_wheel.sh @@ -10,6 +10,7 @@ package_dir=$2 source rapids-configure-sccache source rapids-date-string source rapids-init-pip +source ./ci/use_wheels_from_prs.sh rapids-generate-version > ./VERSION diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index d1a1d2d5f4..82aea62533 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -6,6 +6,8 @@ set -euo pipefail . /opt/conda/etc/profile.d/conda.sh +source ./ci/use_conda_packages_from_prs.sh + rapids-logger "Configuring conda strict channel priority" conda config --set channel_priority strict diff --git a/ci/test_python.sh b/ci/test_python.sh index a427b16862..80fe63ebfa 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -6,6 +6,8 @@ set -euo pipefail . /opt/conda/etc/profile.d/conda.sh +source ./ci/use_conda_packages_from_prs.sh + rapids-logger "Configuring conda strict channel priority" conda config --set channel_priority strict diff --git a/ci/test_wheel_cuvs.sh b/ci/test_wheel_cuvs.sh index 427dc69adc..daf09957a7 100755 --- a/ci/test_wheel_cuvs.sh +++ b/ci/test_wheel_cuvs.sh @@ -6,6 +6,8 @@ set -euo pipefail source rapids-init-pip +source ./ci/use_wheels_from_prs.sh + # Delete system libnccl.so to ensure the wheel is used rm -rf /usr/lib64/libnccl* diff --git a/ci/use_conda_packages_from_prs.sh b/ci/use_conda_packages_from_prs.sh new file mode 100755 index 0000000000..52c719d399 --- /dev/null +++ b/ci/use_conda_packages_from_prs.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# download CI artifacts +LIBRAFT_CHANNEL=$(rapids-get-pr-artifact raft 2836 cpp conda) + +# For `rattler` builds: +# +# Add these channels to the array checked by 'rapids-rattler-channel-string'. +# This ensures that when conda packages are built with strict channel priority enabled, +# the locally-downloaded packages will be preferred to remote packages (e.g. nightlies). +# +RAPIDS_PREPENDED_CONDA_CHANNELS=( + "${LIBRAFT_CHANNEL}" +) +export RAPIDS_PREPENDED_CONDA_CHANNELS + +# For tests and `conda-build` builds: +# +# Add these channels to the system-wide conda configuration. +# This results in PREPENDING them to conda's channel list, so +# these packages should be found first if strict channel priority is enabled. +# +for _channel in "${RAPIDS_PREPENDED_CONDA_CHANNELS[@]}" +do + conda config --system --add channels "${_channel}" +done diff --git a/ci/use_wheels_from_prs.sh b/ci/use_wheels_from_prs.sh new file mode 100755 index 0000000000..3750041c30 --- /dev/null +++ b/ci/use_wheels_from_prs.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# initialize PIP_CONSTRAINT +source rapids-init-pip + +RAPIDS_PY_CUDA_SUFFIX=$(rapids-wheel-ctk-name-gen "${RAPIDS_CUDA_VERSION}") + +# download wheels, store the directories holding them in variables +LIBRAFT_WHEELHOUSE=$( + RAPIDS_PY_WHEEL_NAME="libraft_${RAPIDS_PY_CUDA_SUFFIX}" rapids-get-pr-artifact raft 2836 cpp wheel +) + +# write a pip constraints file saying e.g. "whenever you encounter a requirement for 'librmm-cu12', use this wheel" +cat > "${PIP_CONSTRAINT}" < Date: Wed, 3 Dec 2025 04:08:01 -0800 Subject: [PATCH 03/17] remove checks --- .github/workflows/pr.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 1c14b155d4..b1fb035952 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -137,7 +137,6 @@ jobs: enable_check_generated_files: false ignored_pr_jobs: "telemetry-summarize" conda-cpp-build: - needs: checks secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@main with: From 6ebd30e2acb21ff0100047aa6ba6ec5ee6c67f3e Mon Sep 17 00:00:00 2001 From: divyegala Date: Wed, 3 Dec 2025 04:21:24 -0800 Subject: [PATCH 04/17] rework ci lines --- ci/build_cpp.sh | 3 +-- ci/build_docs.sh | 4 ++-- ci/build_go.sh | 3 +-- ci/build_java.sh | 3 +-- ci/build_python.sh | 3 +-- ci/build_rust.sh | 3 +-- ci/test_cpp.sh | 3 +-- ci/test_python.sh | 3 +-- 8 files changed, 9 insertions(+), 16 deletions(-) diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index 86894d51bf..b6086bb70f 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -8,8 +8,6 @@ source rapids-configure-sccache source rapids-date-string -source ./ci/use_conda_packages_from_prs.sh - export CMAKE_GENERATOR=Ninja rapids-print-env @@ -25,6 +23,7 @@ export RAPIDS_PACKAGE_VERSION RAPIDS_ARTIFACTS_DIR=${RAPIDS_ARTIFACTS_DIR:-"${PWD}/artifacts"} mkdir -p "${RAPIDS_ARTIFACTS_DIR}" export RAPIDS_ARTIFACTS_DIR +source ./ci/use_conda_packages_from_prs.sh # populates `RATTLER_CHANNELS` array and `RATTLER_ARGS` array source rapids-rattler-channel-string diff --git a/ci/build_docs.sh b/ci/build_docs.sh index 7d819f8916..b8ee594c26 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -4,12 +4,12 @@ set -euo pipefail -source ./ci/use_conda_packages_from_prs.sh - rapids-logger "Downloading artifacts from previous jobs" CPP_CHANNEL=$(rapids-download-conda-from-github cpp) PYTHON_CHANNEL=$(rapids-download-conda-from-github python) +source ./ci/use_conda_packages_from_prs.sh + rapids-logger "Create test conda environment" . /opt/conda/etc/profile.d/conda.sh diff --git a/ci/build_go.sh b/ci/build_go.sh index 150f2b7817..b0f274ead0 100755 --- a/ci/build_go.sh +++ b/ci/build_go.sh @@ -4,10 +4,9 @@ set -euo pipefail -source ./ci/use_conda_packages_from_prs.sh - rapids-logger "Downloading artifacts from previous jobs" CPP_CHANNEL=$(rapids-download-conda-from-github cpp) +source ./ci/use_conda_packages_from_prs.sh rapids-logger "Create test conda environment" . /opt/conda/etc/profile.d/conda.sh diff --git a/ci/build_java.sh b/ci/build_java.sh index 5beabcdeeb..a9595d3966 100755 --- a/ci/build_java.sh +++ b/ci/build_java.sh @@ -4,8 +4,6 @@ set -euo pipefail -source ./ci/use_conda_packages_from_prs.sh - # TODO: Remove this argument-handling when build and test workflows are separated, # and test_java.sh no longer calls build_java.sh # ref: https://github.com/rapidsai/cuvs/issues/868 @@ -20,6 +18,7 @@ fi rapids-logger "Downloading artifacts from previous jobs" CPP_CHANNEL=$(rapids-download-conda-from-github cpp) +source ./ci/use_conda_packages_from_prs.sh rapids-logger "Generate Java testing dependencies" diff --git a/ci/build_python.sh b/ci/build_python.sh index d1c7583ea8..f1c156fe2c 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -8,8 +8,6 @@ source rapids-configure-sccache source rapids-date-string -source ./ci/use_conda_packages_from_prs.sh - export CMAKE_GENERATOR=Ninja rapids-print-env @@ -17,6 +15,7 @@ rapids-print-env rapids-logger "Begin py build" CPP_CHANNEL=$(rapids-download-conda-from-github cpp) +source ./ci/use_conda_packages_from_prs.sh version=$(rapids-generate-version) export RAPIDS_PACKAGE_VERSION=${version} diff --git a/ci/build_rust.sh b/ci/build_rust.sh index a458f1d3fe..e19541bfad 100755 --- a/ci/build_rust.sh +++ b/ci/build_rust.sh @@ -4,10 +4,9 @@ set -euo pipefail -source ./ci/use_conda_packages_from_prs.sh - rapids-logger "Downloading artifacts from previous jobs" CPP_CHANNEL=$(rapids-download-conda-from-github cpp) +source ./ci/use_conda_packages_from_prs.sh rapids-logger "Create test conda environment" . /opt/conda/etc/profile.d/conda.sh diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index 82aea62533..b0086f1222 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -6,12 +6,11 @@ set -euo pipefail . /opt/conda/etc/profile.d/conda.sh -source ./ci/use_conda_packages_from_prs.sh - rapids-logger "Configuring conda strict channel priority" conda config --set channel_priority strict CPP_CHANNEL=$(rapids-download-conda-from-github cpp) +source ./ci/use_conda_packages_from_prs.sh rapids-logger "Generate C++ testing dependencies" rapids-dependency-file-generator \ diff --git a/ci/test_python.sh b/ci/test_python.sh index 80fe63ebfa..716dc890c9 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -6,14 +6,13 @@ set -euo pipefail . /opt/conda/etc/profile.d/conda.sh -source ./ci/use_conda_packages_from_prs.sh - rapids-logger "Configuring conda strict channel priority" conda config --set channel_priority strict rapids-logger "Downloading artifacts from previous jobs" CPP_CHANNEL=$(rapids-download-conda-from-github cpp) PYTHON_CHANNEL=$(rapids-download-conda-from-github python) +source ./ci/use_conda_packages_from_prs.sh rapids-logger "Generate Python testing dependencies" rapids-dependency-file-generator \ From 9f588677838ee9ef31bb2bae480410ab8f653686 Mon Sep 17 00:00:00 2001 From: divyegala Date: Wed, 3 Dec 2025 04:27:45 -0800 Subject: [PATCH 05/17] remove more need checks --- .github/workflows/pr.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index b1fb035952..18d865f21f 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -174,7 +174,6 @@ jobs: build_type: pull-request script: ci/test_python.sh rocky8-clib-standalone-build: - needs: [checks] secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@main strategy: @@ -283,7 +282,6 @@ jobs: container_image: "rapidsai/ci-conda:26.02-latest" script: "ci/build_docs.sh" wheel-build-libcuvs: - needs: checks secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@main with: From 40fd155f7929261ff25b66f01371b050cac158fb Mon Sep 17 00:00:00 2001 From: divyegala Date: Wed, 3 Dec 2025 05:02:40 -0800 Subject: [PATCH 06/17] download pylibraft as well --- ci/use_conda_packages_from_prs.sh | 2 ++ ci/use_wheels_from_prs.sh | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ci/use_conda_packages_from_prs.sh b/ci/use_conda_packages_from_prs.sh index 52c719d399..6ae4bdfff6 100755 --- a/ci/use_conda_packages_from_prs.sh +++ b/ci/use_conda_packages_from_prs.sh @@ -4,6 +4,7 @@ # download CI artifacts LIBRAFT_CHANNEL=$(rapids-get-pr-artifact raft 2836 cpp conda) +PYLIBRAFT_CHANNEL=$(rapids-get-pr-artifact raft 2836 python conda) # For `rattler` builds: # @@ -13,6 +14,7 @@ LIBRAFT_CHANNEL=$(rapids-get-pr-artifact raft 2836 cpp conda) # RAPIDS_PREPENDED_CONDA_CHANNELS=( "${LIBRAFT_CHANNEL}" + "${PYLIBRAFT_CHANNEL}" ) export RAPIDS_PREPENDED_CONDA_CHANNELS diff --git a/ci/use_wheels_from_prs.sh b/ci/use_wheels_from_prs.sh index 3750041c30..6061902b85 100755 --- a/ci/use_wheels_from_prs.sh +++ b/ci/use_wheels_from_prs.sh @@ -11,8 +11,11 @@ RAPIDS_PY_CUDA_SUFFIX=$(rapids-wheel-ctk-name-gen "${RAPIDS_CUDA_VERSION}") LIBRAFT_WHEELHOUSE=$( RAPIDS_PY_WHEEL_NAME="libraft_${RAPIDS_PY_CUDA_SUFFIX}" rapids-get-pr-artifact raft 2836 cpp wheel ) - +PYLIBRAFT_WHEELHOUSE=$( + RAPIDS_PY_WHEEL_NAME="pylibraft_${RAPIDS_PY_CUDA_SUFFIX}" rapids-get-pr-artifact raft 2836 python wheel +) # write a pip constraints file saying e.g. "whenever you encounter a requirement for 'librmm-cu12', use this wheel" cat > "${PIP_CONSTRAINT}" < Date: Wed, 3 Dec 2025 05:59:42 -0800 Subject: [PATCH 07/17] revert get_raft.cmake --- cpp/cmake/thirdparty/get_raft.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/cmake/thirdparty/get_raft.cmake b/cpp/cmake/thirdparty/get_raft.cmake index 35f5dd31d1..492ae6cba1 100644 --- a/cpp/cmake/thirdparty/get_raft.cmake +++ b/cpp/cmake/thirdparty/get_raft.cmake @@ -55,8 +55,8 @@ endfunction() # To use a different RAFT locally, set the CMake variable # CPM_raft_SOURCE=/path/to/local/raft find_and_configure_raft(VERSION ${RAFT_VERSION}.00 - FORK bdice - PINNED_TAG cccl-mdspan + FORK ${RAFT_FORK} + PINNED_TAG ${RAFT_PINNED_TAG} ENABLE_MNMG_DEPENDENCIES OFF ENABLE_NVTX OFF BUILD_STATIC_DEPS ${CUVS_STATIC_RAPIDS_LIBRARIES} From a31db96a4d62575084cc5fde428b369c46d05829 Mon Sep 17 00:00:00 2001 From: divyegala Date: Wed, 3 Dec 2025 06:41:26 -0800 Subject: [PATCH 08/17] Revert "revert get_raft.cmake" This reverts commit 4e04cab286f92def3a84f5068270029085e952ca. --- cpp/cmake/thirdparty/get_raft.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/cmake/thirdparty/get_raft.cmake b/cpp/cmake/thirdparty/get_raft.cmake index 492ae6cba1..35f5dd31d1 100644 --- a/cpp/cmake/thirdparty/get_raft.cmake +++ b/cpp/cmake/thirdparty/get_raft.cmake @@ -55,8 +55,8 @@ endfunction() # To use a different RAFT locally, set the CMake variable # CPM_raft_SOURCE=/path/to/local/raft find_and_configure_raft(VERSION ${RAFT_VERSION}.00 - FORK ${RAFT_FORK} - PINNED_TAG ${RAFT_PINNED_TAG} + FORK bdice + PINNED_TAG cccl-mdspan ENABLE_MNMG_DEPENDENCIES OFF ENABLE_NVTX OFF BUILD_STATIC_DEPS ${CUVS_STATIC_RAPIDS_LIBRARIES} From 9ae4e44f0221fc20833527eb4f256766976af6e6 Mon Sep 17 00:00:00 2001 From: divyegala Date: Thu, 4 Dec 2025 02:39:53 -0800 Subject: [PATCH 09/17] propagate static deps through pinned raft --- cpp/cmake/thirdparty/get_raft.cmake | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cpp/cmake/thirdparty/get_raft.cmake b/cpp/cmake/thirdparty/get_raft.cmake index 35f5dd31d1..8ecf3686be 100644 --- a/cpp/cmake/thirdparty/get_raft.cmake +++ b/cpp/cmake/thirdparty/get_raft.cmake @@ -14,13 +14,18 @@ function(find_and_configure_raft) cmake_parse_arguments(PKG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) + # Set BUILD_SHARED_LIBS whenever building static dependencies + if(PKG_BUILD_STATIC_DEPS) + set(BUILD_SHARED_LIBS OFF) + endif() + + # Determine whether to clone raft locally if(PKG_CLONE_ON_PIN AND NOT PKG_PINNED_TAG STREQUAL "${rapids-cmake-checkout-tag}") message(STATUS "cuVS: RAFT pinned tag found: ${PKG_PINNED_TAG}. Cloning raft locally.") set(CPM_DOWNLOAD_raft ON) elseif(PKG_BUILD_STATIC_DEPS AND (NOT CPM_raft_SOURCE)) message(STATUS "cuVS: Cloning raft locally to build static libraries.") set(CPM_DOWNLOAD_raft ON) - set(BUILD_SHARED_LIBS OFF) endif() set(RAFT_COMPONENTS "") @@ -55,8 +60,8 @@ endfunction() # To use a different RAFT locally, set the CMake variable # CPM_raft_SOURCE=/path/to/local/raft find_and_configure_raft(VERSION ${RAFT_VERSION}.00 - FORK bdice - PINNED_TAG cccl-mdspan + FORK ${RAFT_FORK} + PINNED_TAG ${RAFT_PINNED_TAG} ENABLE_MNMG_DEPENDENCIES OFF ENABLE_NVTX OFF BUILD_STATIC_DEPS ${CUVS_STATIC_RAPIDS_LIBRARIES} From 8ed1af5073655d630b1089488e6fb61b86bedaa2 Mon Sep 17 00:00:00 2001 From: divyegala Date: Thu, 4 Dec 2025 02:45:17 -0800 Subject: [PATCH 10/17] Revert "remove checks" This reverts commit 7c5dd65c69661f0a1833aa03031a25805af83c1d. --- .github/workflows/pr.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 82c66a94c1..02581da0cd 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -137,6 +137,7 @@ jobs: enable_check_generated_files: false ignored_pr_jobs: "telemetry-summarize" conda-cpp-build: + needs: checks secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@main with: From dd7bb3b11b44621f81a13c7b4c55bd60dc81ef22 Mon Sep 17 00:00:00 2001 From: divyegala Date: Thu, 4 Dec 2025 02:45:26 -0800 Subject: [PATCH 11/17] Revert "remove more need checks" This reverts commit 9f588677838ee9ef31bb2bae480410ab8f653686. --- .github/workflows/pr.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 02581da0cd..d74ab4abbe 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -175,6 +175,7 @@ jobs: build_type: pull-request script: ci/test_python.sh rocky8-clib-standalone-build: + needs: [checks] secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@main strategy: @@ -289,6 +290,7 @@ jobs: container_image: "rapidsai/ci-conda:26.02-latest" script: "ci/build_docs.sh" wheel-build-libcuvs: + needs: checks secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@main with: From 0f43b1854f3409eb5a1fe642d2da5639618a810e Mon Sep 17 00:00:00 2001 From: divyegala Date: Thu, 4 Dec 2025 03:21:29 -0800 Subject: [PATCH 12/17] pin raft --- cpp/cmake/thirdparty/get_raft.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/cmake/thirdparty/get_raft.cmake b/cpp/cmake/thirdparty/get_raft.cmake index 8ecf3686be..ccbbcdbf31 100644 --- a/cpp/cmake/thirdparty/get_raft.cmake +++ b/cpp/cmake/thirdparty/get_raft.cmake @@ -60,8 +60,8 @@ endfunction() # To use a different RAFT locally, set the CMake variable # CPM_raft_SOURCE=/path/to/local/raft find_and_configure_raft(VERSION ${RAFT_VERSION}.00 - FORK ${RAFT_FORK} - PINNED_TAG ${RAFT_PINNED_TAG} + FORK bdice + PINNED_TAG cccl-mdspan ENABLE_MNMG_DEPENDENCIES OFF ENABLE_NVTX OFF BUILD_STATIC_DEPS ${CUVS_STATIC_RAPIDS_LIBRARIES} From 2a5a5521af7950bba14b5424693999a1801b46ba Mon Sep 17 00:00:00 2001 From: divyegala Date: Thu, 4 Dec 2025 23:28:49 -0800 Subject: [PATCH 13/17] Revert "pin raft" This reverts commit 0f43b1854f3409eb5a1fe642d2da5639618a810e. --- cpp/cmake/thirdparty/get_raft.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/cmake/thirdparty/get_raft.cmake b/cpp/cmake/thirdparty/get_raft.cmake index ccbbcdbf31..8ecf3686be 100644 --- a/cpp/cmake/thirdparty/get_raft.cmake +++ b/cpp/cmake/thirdparty/get_raft.cmake @@ -60,8 +60,8 @@ endfunction() # To use a different RAFT locally, set the CMake variable # CPM_raft_SOURCE=/path/to/local/raft find_and_configure_raft(VERSION ${RAFT_VERSION}.00 - FORK bdice - PINNED_TAG cccl-mdspan + FORK ${RAFT_FORK} + PINNED_TAG ${RAFT_PINNED_TAG} ENABLE_MNMG_DEPENDENCIES OFF ENABLE_NVTX OFF BUILD_STATIC_DEPS ${CUVS_STATIC_RAPIDS_LIBRARIES} From d383f48b8f3593f013fae3c641db688972e57d2a Mon Sep 17 00:00:00 2001 From: divyegala Date: Thu, 4 Dec 2025 23:29:17 -0800 Subject: [PATCH 14/17] Revert "rework ci lines" This reverts commit 6ebd30e2acb21ff0100047aa6ba6ec5ee6c67f3e. --- ci/build_cpp.sh | 3 ++- ci/build_docs.sh | 4 ++-- ci/build_go.sh | 3 ++- ci/build_java.sh | 3 ++- ci/build_python.sh | 3 ++- ci/build_rust.sh | 3 ++- ci/test_cpp.sh | 3 ++- ci/test_python.sh | 3 ++- 8 files changed, 16 insertions(+), 9 deletions(-) diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index b6086bb70f..86894d51bf 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -8,6 +8,8 @@ source rapids-configure-sccache source rapids-date-string +source ./ci/use_conda_packages_from_prs.sh + export CMAKE_GENERATOR=Ninja rapids-print-env @@ -23,7 +25,6 @@ export RAPIDS_PACKAGE_VERSION RAPIDS_ARTIFACTS_DIR=${RAPIDS_ARTIFACTS_DIR:-"${PWD}/artifacts"} mkdir -p "${RAPIDS_ARTIFACTS_DIR}" export RAPIDS_ARTIFACTS_DIR -source ./ci/use_conda_packages_from_prs.sh # populates `RATTLER_CHANNELS` array and `RATTLER_ARGS` array source rapids-rattler-channel-string diff --git a/ci/build_docs.sh b/ci/build_docs.sh index 1257b55e04..71bcc426b7 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -4,12 +4,12 @@ set -euo pipefail +source ./ci/use_conda_packages_from_prs.sh + rapids-logger "Downloading artifacts from previous jobs" CPP_CHANNEL=$(rapids-download-conda-from-github cpp) PYTHON_CHANNEL=$(rapids-download-conda-from-github python) -source ./ci/use_conda_packages_from_prs.sh - rapids-logger "Create test conda environment" . /opt/conda/etc/profile.d/conda.sh diff --git a/ci/build_go.sh b/ci/build_go.sh index 1bd9a2316e..3041c2bfe5 100755 --- a/ci/build_go.sh +++ b/ci/build_go.sh @@ -4,9 +4,10 @@ set -euo pipefail +source ./ci/use_conda_packages_from_prs.sh + rapids-logger "Downloading artifacts from previous jobs" CPP_CHANNEL=$(rapids-download-conda-from-github cpp) -source ./ci/use_conda_packages_from_prs.sh rapids-logger "Create test conda environment" . /opt/conda/etc/profile.d/conda.sh diff --git a/ci/build_java.sh b/ci/build_java.sh index 673f951a10..2c7b154d85 100755 --- a/ci/build_java.sh +++ b/ci/build_java.sh @@ -4,6 +4,8 @@ set -euo pipefail +source ./ci/use_conda_packages_from_prs.sh + # TODO: Remove this argument-handling when build and test workflows are separated, # and test_java.sh no longer calls build_java.sh # ref: https://github.com/rapidsai/cuvs/issues/868 @@ -21,7 +23,6 @@ conda config --set channel_priority strict rapids-logger "Downloading artifacts from previous jobs" CPP_CHANNEL=$(rapids-download-conda-from-github cpp) -source ./ci/use_conda_packages_from_prs.sh rapids-logger "Generate Java testing dependencies" diff --git a/ci/build_python.sh b/ci/build_python.sh index f1c156fe2c..d1c7583ea8 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -8,6 +8,8 @@ source rapids-configure-sccache source rapids-date-string +source ./ci/use_conda_packages_from_prs.sh + export CMAKE_GENERATOR=Ninja rapids-print-env @@ -15,7 +17,6 @@ rapids-print-env rapids-logger "Begin py build" CPP_CHANNEL=$(rapids-download-conda-from-github cpp) -source ./ci/use_conda_packages_from_prs.sh version=$(rapids-generate-version) export RAPIDS_PACKAGE_VERSION=${version} diff --git a/ci/build_rust.sh b/ci/build_rust.sh index f95fb206aa..3023890cfa 100755 --- a/ci/build_rust.sh +++ b/ci/build_rust.sh @@ -4,9 +4,10 @@ set -euo pipefail +source ./ci/use_conda_packages_from_prs.sh + rapids-logger "Downloading artifacts from previous jobs" CPP_CHANNEL=$(rapids-download-conda-from-github cpp) -source ./ci/use_conda_packages_from_prs.sh rapids-logger "Create test conda environment" . /opt/conda/etc/profile.d/conda.sh diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index b0086f1222..82aea62533 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -6,11 +6,12 @@ set -euo pipefail . /opt/conda/etc/profile.d/conda.sh +source ./ci/use_conda_packages_from_prs.sh + rapids-logger "Configuring conda strict channel priority" conda config --set channel_priority strict CPP_CHANNEL=$(rapids-download-conda-from-github cpp) -source ./ci/use_conda_packages_from_prs.sh rapids-logger "Generate C++ testing dependencies" rapids-dependency-file-generator \ diff --git a/ci/test_python.sh b/ci/test_python.sh index 716dc890c9..80fe63ebfa 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -6,13 +6,14 @@ set -euo pipefail . /opt/conda/etc/profile.d/conda.sh +source ./ci/use_conda_packages_from_prs.sh + rapids-logger "Configuring conda strict channel priority" conda config --set channel_priority strict rapids-logger "Downloading artifacts from previous jobs" CPP_CHANNEL=$(rapids-download-conda-from-github cpp) PYTHON_CHANNEL=$(rapids-download-conda-from-github python) -source ./ci/use_conda_packages_from_prs.sh rapids-logger "Generate Python testing dependencies" rapids-dependency-file-generator \ From 9d6e674d5a436fd7f4117570f5bff6af33745bde Mon Sep 17 00:00:00 2001 From: divyegala Date: Thu, 4 Dec 2025 23:29:44 -0800 Subject: [PATCH 15/17] Revert "download pylibraft as well" This reverts commit 40fd155f7929261ff25b66f01371b050cac158fb. --- ci/use_conda_packages_from_prs.sh | 2 -- ci/use_wheels_from_prs.sh | 5 +---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/ci/use_conda_packages_from_prs.sh b/ci/use_conda_packages_from_prs.sh index 6ae4bdfff6..52c719d399 100755 --- a/ci/use_conda_packages_from_prs.sh +++ b/ci/use_conda_packages_from_prs.sh @@ -4,7 +4,6 @@ # download CI artifacts LIBRAFT_CHANNEL=$(rapids-get-pr-artifact raft 2836 cpp conda) -PYLIBRAFT_CHANNEL=$(rapids-get-pr-artifact raft 2836 python conda) # For `rattler` builds: # @@ -14,7 +13,6 @@ PYLIBRAFT_CHANNEL=$(rapids-get-pr-artifact raft 2836 python conda) # RAPIDS_PREPENDED_CONDA_CHANNELS=( "${LIBRAFT_CHANNEL}" - "${PYLIBRAFT_CHANNEL}" ) export RAPIDS_PREPENDED_CONDA_CHANNELS diff --git a/ci/use_wheels_from_prs.sh b/ci/use_wheels_from_prs.sh index 6061902b85..3750041c30 100755 --- a/ci/use_wheels_from_prs.sh +++ b/ci/use_wheels_from_prs.sh @@ -11,11 +11,8 @@ RAPIDS_PY_CUDA_SUFFIX=$(rapids-wheel-ctk-name-gen "${RAPIDS_CUDA_VERSION}") LIBRAFT_WHEELHOUSE=$( RAPIDS_PY_WHEEL_NAME="libraft_${RAPIDS_PY_CUDA_SUFFIX}" rapids-get-pr-artifact raft 2836 cpp wheel ) -PYLIBRAFT_WHEELHOUSE=$( - RAPIDS_PY_WHEEL_NAME="pylibraft_${RAPIDS_PY_CUDA_SUFFIX}" rapids-get-pr-artifact raft 2836 python wheel -) + # write a pip constraints file saying e.g. "whenever you encounter a requirement for 'librmm-cu12', use this wheel" cat > "${PIP_CONSTRAINT}" < Date: Thu, 4 Dec 2025 23:29:58 -0800 Subject: [PATCH 16/17] Revert "use ci artifacts" This reverts commit 59e50e20e3d2a0840cd75108081a9735ec5e3b62. --- ci/build_cpp.sh | 2 -- ci/build_docs.sh | 2 -- ci/build_go.sh | 4 +--- ci/build_java.sh | 2 -- ci/build_python.sh | 2 -- ci/build_rust.sh | 4 +--- ci/build_wheel.sh | 1 - ci/test_cpp.sh | 2 -- ci/test_python.sh | 2 -- ci/test_wheel_cuvs.sh | 2 -- ci/use_conda_packages_from_prs.sh | 28 ---------------------------- ci/use_wheels_from_prs.sh | 18 ------------------ 12 files changed, 2 insertions(+), 67 deletions(-) delete mode 100755 ci/use_conda_packages_from_prs.sh delete mode 100755 ci/use_wheels_from_prs.sh diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index 86894d51bf..94092f0dd0 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -8,8 +8,6 @@ source rapids-configure-sccache source rapids-date-string -source ./ci/use_conda_packages_from_prs.sh - export CMAKE_GENERATOR=Ninja rapids-print-env diff --git a/ci/build_docs.sh b/ci/build_docs.sh index 71bcc426b7..f9ab38721b 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -4,8 +4,6 @@ set -euo pipefail -source ./ci/use_conda_packages_from_prs.sh - rapids-logger "Downloading artifacts from previous jobs" CPP_CHANNEL=$(rapids-download-conda-from-github cpp) PYTHON_CHANNEL=$(rapids-download-conda-from-github python) diff --git a/ci/build_go.sh b/ci/build_go.sh index 3041c2bfe5..07a296b42d 100755 --- a/ci/build_go.sh +++ b/ci/build_go.sh @@ -1,11 +1,9 @@ #!/bin/bash -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 set -euo pipefail -source ./ci/use_conda_packages_from_prs.sh - rapids-logger "Downloading artifacts from previous jobs" CPP_CHANNEL=$(rapids-download-conda-from-github cpp) diff --git a/ci/build_java.sh b/ci/build_java.sh index 2c7b154d85..922483446f 100755 --- a/ci/build_java.sh +++ b/ci/build_java.sh @@ -4,8 +4,6 @@ set -euo pipefail -source ./ci/use_conda_packages_from_prs.sh - # TODO: Remove this argument-handling when build and test workflows are separated, # and test_java.sh no longer calls build_java.sh # ref: https://github.com/rapidsai/cuvs/issues/868 diff --git a/ci/build_python.sh b/ci/build_python.sh index d1c7583ea8..f6035c2e1a 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -8,8 +8,6 @@ source rapids-configure-sccache source rapids-date-string -source ./ci/use_conda_packages_from_prs.sh - export CMAKE_GENERATOR=Ninja rapids-print-env diff --git a/ci/build_rust.sh b/ci/build_rust.sh index 3023890cfa..7af017eab7 100755 --- a/ci/build_rust.sh +++ b/ci/build_rust.sh @@ -1,11 +1,9 @@ #!/bin/bash -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 set -euo pipefail -source ./ci/use_conda_packages_from_prs.sh - rapids-logger "Downloading artifacts from previous jobs" CPP_CHANNEL=$(rapids-download-conda-from-github cpp) diff --git a/ci/build_wheel.sh b/ci/build_wheel.sh index 19a78a85f6..f3dcb91364 100755 --- a/ci/build_wheel.sh +++ b/ci/build_wheel.sh @@ -10,7 +10,6 @@ package_dir=$2 source rapids-configure-sccache source rapids-date-string source rapids-init-pip -source ./ci/use_wheels_from_prs.sh rapids-generate-version > ./VERSION diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index 82aea62533..d1a1d2d5f4 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -6,8 +6,6 @@ set -euo pipefail . /opt/conda/etc/profile.d/conda.sh -source ./ci/use_conda_packages_from_prs.sh - rapids-logger "Configuring conda strict channel priority" conda config --set channel_priority strict diff --git a/ci/test_python.sh b/ci/test_python.sh index 80fe63ebfa..a427b16862 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -6,8 +6,6 @@ set -euo pipefail . /opt/conda/etc/profile.d/conda.sh -source ./ci/use_conda_packages_from_prs.sh - rapids-logger "Configuring conda strict channel priority" conda config --set channel_priority strict diff --git a/ci/test_wheel_cuvs.sh b/ci/test_wheel_cuvs.sh index daf09957a7..427dc69adc 100755 --- a/ci/test_wheel_cuvs.sh +++ b/ci/test_wheel_cuvs.sh @@ -6,8 +6,6 @@ set -euo pipefail source rapids-init-pip -source ./ci/use_wheels_from_prs.sh - # Delete system libnccl.so to ensure the wheel is used rm -rf /usr/lib64/libnccl* diff --git a/ci/use_conda_packages_from_prs.sh b/ci/use_conda_packages_from_prs.sh deleted file mode 100755 index 52c719d399..0000000000 --- a/ci/use_conda_packages_from_prs.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -# download CI artifacts -LIBRAFT_CHANNEL=$(rapids-get-pr-artifact raft 2836 cpp conda) - -# For `rattler` builds: -# -# Add these channels to the array checked by 'rapids-rattler-channel-string'. -# This ensures that when conda packages are built with strict channel priority enabled, -# the locally-downloaded packages will be preferred to remote packages (e.g. nightlies). -# -RAPIDS_PREPENDED_CONDA_CHANNELS=( - "${LIBRAFT_CHANNEL}" -) -export RAPIDS_PREPENDED_CONDA_CHANNELS - -# For tests and `conda-build` builds: -# -# Add these channels to the system-wide conda configuration. -# This results in PREPENDING them to conda's channel list, so -# these packages should be found first if strict channel priority is enabled. -# -for _channel in "${RAPIDS_PREPENDED_CONDA_CHANNELS[@]}" -do - conda config --system --add channels "${_channel}" -done diff --git a/ci/use_wheels_from_prs.sh b/ci/use_wheels_from_prs.sh deleted file mode 100755 index 3750041c30..0000000000 --- a/ci/use_wheels_from_prs.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -# initialize PIP_CONSTRAINT -source rapids-init-pip - -RAPIDS_PY_CUDA_SUFFIX=$(rapids-wheel-ctk-name-gen "${RAPIDS_CUDA_VERSION}") - -# download wheels, store the directories holding them in variables -LIBRAFT_WHEELHOUSE=$( - RAPIDS_PY_WHEEL_NAME="libraft_${RAPIDS_PY_CUDA_SUFFIX}" rapids-get-pr-artifact raft 2836 cpp wheel -) - -# write a pip constraints file saying e.g. "whenever you encounter a requirement for 'librmm-cu12', use this wheel" -cat > "${PIP_CONSTRAINT}" < Date: Fri, 5 Dec 2025 01:28:22 -0800 Subject: [PATCH 17/17] bad revert --- ci/build_go.sh | 2 +- ci/build_rust.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/build_go.sh b/ci/build_go.sh index 07a296b42d..925dfb9153 100755 --- a/ci/build_go.sh +++ b/ci/build_go.sh @@ -1,5 +1,5 @@ #!/bin/bash -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 set -euo pipefail diff --git a/ci/build_rust.sh b/ci/build_rust.sh index 7af017eab7..e0f0b023fa 100755 --- a/ci/build_rust.sh +++ b/ci/build_rust.sh @@ -1,5 +1,5 @@ #!/bin/bash -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. # SPDX-License-Identifier: Apache-2.0 set -euo pipefail