Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing workaroun to cuSPARSE bug that was reverted during 24.02 release #2184

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cpp/include/raft/neighbors/detail/knn_merge_parts.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#pragma once

#include <raft/core/error.hpp>
#include <raft/util/cuda_utils.cuh>
#include <raft/util/cudart_utils.hpp>

Expand Down Expand Up @@ -168,5 +169,7 @@ inline void knn_merge_parts(const value_t* inK,
else if (k <= 1024)
knn_merge_parts_impl<value_idx, value_t, 1024, 8>(
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
8 changes: 6 additions & 2 deletions cpp/include/raft/sparse/linalg/spmm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,15 @@ 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<ValueType, IndexType>(handle, z.extent(0), z.extent(1));
trxcllnt marked this conversation as resolved.
Show resolved Hide resolved
cjnolet marked this conversation as resolved.
Show resolved Hide resolved
auto z_tmp_view =
is_row_major ? raft::make_device_strided_matrix_view<ValueType, IndexType, layout_c_contiguous>(
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<ValueType, IndexType, layout_f_contiguous>(
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);
Expand Down
2 changes: 1 addition & 1 deletion cpp/test/cluster/spectral.cu
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
Expand Down
Loading