diff --git a/cpp/include/raft/neighbors/detail/knn_merge_parts.cuh b/cpp/include/raft/neighbors/detail/knn_merge_parts.cuh index c8ff03741c..bc64fc9181 100644 --- a/cpp/include/raft/neighbors/detail/knn_merge_parts.cuh +++ b/cpp/include/raft/neighbors/detail/knn_merge_parts.cuh @@ -16,6 +16,7 @@ #pragma once +#include #include #include @@ -168,5 +169,7 @@ inline void knn_merge_parts(const value_t* inK, else if (k <= 1024) knn_merge_parts_impl( inK, inV, outK, outV, n_samples, n_parts, k, stream, translations); + else + THROW("Unimplemented for k=%d, knn_merge_parts works for k<=1024", k); } } // namespace raft::neighbors::detail diff --git a/cpp/include/raft/sparse/linalg/spmm.hpp b/cpp/include/raft/sparse/linalg/spmm.hpp index dd661c71ac..d0727755b6 100644 --- a/cpp/include/raft/sparse/linalg/spmm.hpp +++ b/cpp/include/raft/sparse/linalg/spmm.hpp @@ -60,11 +60,18 @@ void spmm(raft::resources const& handle, { bool is_row_major = detail::is_row_major(y, z); + // WARNING: The following copy is working around a bug in cusparse which causes an alignment issue + // and incorrect results. This bug is fixed in CUDA 12.5+ so this workaround shouldn't be removed + // until that version is supported. + auto z_tmp = raft::make_device_matrix(handle, z.extent(0), z.extent(1)); + raft::copy( + z_tmp.data_handle(), z.data_handle(), z.size(), raft::resource::get_cuda_stream(handle)); + auto z_tmp_view = is_row_major ? raft::make_device_strided_matrix_view( - z.data_handle(), z.extent(0), z.extent(1), z.stride(0)) + z_tmp.data_handle(), z.extent(0), z.extent(1), z.stride(0)) : raft::make_device_strided_matrix_view( - z.data_handle(), z.extent(0), z.extent(1), z.stride(1)); + z_tmp.data_handle(), z.extent(0), z.extent(1), z.stride(1)); auto descr_x = detail::create_descriptor(x); auto descr_y = detail::create_descriptor(y); diff --git a/cpp/test/cluster/spectral.cu b/cpp/test/cluster/spectral.cu index 580564ccbc..3cc5df1e7c 100644 --- a/cpp/test/cluster/spectral.cu +++ b/cpp/test/cluster/spectral.cu @@ -95,7 +95,7 @@ TEST(Raft, Spectral) eigenvalues.data(), eigenvectors.data()); - ASSERT_TRUE(devArrMatch(expected_clustering.data(), + ASSERT_TRUE(devArrMatch(clustering.data(), exp_dev.data(), exp_dev.size(), 1, diff --git a/python/raft-ann-bench/src/raft-ann-bench/generate_groundtruth/__main__.py b/python/raft-ann-bench/src/raft-ann-bench/generate_groundtruth/__main__.py index f4d97edea5..a5ebb76635 100644 --- a/python/raft-ann-bench/src/raft-ann-bench/generate_groundtruth/__main__.py +++ b/python/raft-ann-bench/src/raft-ann-bench/generate_groundtruth/__main__.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright (c) 2023, NVIDIA CORPORATION. +# Copyright (c) 2023-2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -62,17 +62,12 @@ def calc_truth(dataset, queries, k, metric="sqeuclidean"): X = cp.asarray(dataset[i : i + n_batch, :], cp.float32) - D, Ind = knn( - X, - queries, - k, - metric=metric, - handle=handle, - global_id_offset=i, # shift neighbor index by offset i - ) + D, Ind = knn(X, queries, k, metric=metric, handle=handle) handle.sync() D, Ind = cp.asarray(D), cp.asarray(Ind) + Ind += i # shift neighbor index by offset i + if distances is None: distances = D indices = Ind