-
Notifications
You must be signed in to change notification settings - Fork 182
Graph degree equals intermediate graph degree bug fix #1834
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
Merged
rapids-bot
merged 6 commits into
rapidsai:main
from
irina-resh-nvda:graph_degree_equals_intermediate_graph_degree_bug_fix
Feb 24, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3e04a0a
added reproducing test
irina-resh-nvda aabe3fb
cudaErrorIllegalAddress fix
irina-resh-nvda ae74c5d
Merge branch 'main' into graph_degree_equals_intermediate_graph_degre…
irina-resh-nvda d230bfc
style fix
irina-resh-nvda 10effdb
Merge branch 'main' into graph_degree_equals_intermediate_graph_degre…
irina-resh-nvda 31f5e93
addressed suggestions
irina-resh-nvda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
cpp/tests/neighbors/ann_cagra/bug_iterative_cagra_build.cu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #include <gtest/gtest.h> | ||
|
|
||
| #include <cuvs/neighbors/cagra.hpp> | ||
|
|
||
| #include <raft/core/device_mdarray.hpp> | ||
| #include <raft/core/device_resources.hpp> | ||
| #include <raft/random/rng.cuh> | ||
|
|
||
| #include <cstdint> | ||
| #include <type_traits> | ||
|
|
||
| namespace cuvs::neighbors::cagra { | ||
|
|
||
| template <typename DataT> | ||
| class CagraIterativeBuildBugTest : public ::testing::Test { | ||
| public: | ||
| using data_type = DataT; | ||
|
|
||
| protected: | ||
| void run() | ||
| { | ||
| // Set up iterative CAGRA graph building | ||
| cagra::index_params index_params; | ||
| // The bug manifests when graph_degree is equal to intermediate_graph_degree | ||
| // see issue https://github.com/rapidsai/cuvs/issues/1818 | ||
| index_params.graph_degree = 16; | ||
| index_params.intermediate_graph_degree = 16; | ||
|
|
||
| // Use iterative CAGRA search for graph building | ||
| index_params.graph_build_params = graph_build_params::iterative_search_params(); | ||
|
|
||
| // Build the index | ||
| auto cagra_index = cagra::build(res, index_params, raft::make_const_mdspan(dataset->view())); | ||
| raft::resource::sync_stream(res); | ||
|
|
||
| // Verify the index was built successfully | ||
| ASSERT_GT(cagra_index.size(), 0); | ||
| ASSERT_EQ(cagra_index.dim(), n_dim); | ||
| } | ||
|
|
||
| void SetUp() override | ||
| { | ||
| dataset.emplace(raft::make_device_matrix<data_type, int64_t>(res, n_samples, n_dim)); | ||
| raft::random::RngState r(1234ULL); | ||
|
|
||
| // Generate random data based on type | ||
| if constexpr (std::is_same_v<data_type, float>) { | ||
| raft::random::normal( | ||
| res, r, dataset->data_handle(), n_samples * n_dim, data_type(0), data_type(1)); | ||
| } else if constexpr (std::is_same_v<data_type, int8_t>) { | ||
| raft::random::uniformInt( | ||
| res, r, dataset->data_handle(), n_samples * n_dim, int8_t(-128), int8_t(127)); | ||
| } else if constexpr (std::is_same_v<data_type, uint8_t>) { | ||
| raft::random::uniformInt( | ||
| res, r, dataset->data_handle(), n_samples * n_dim, uint8_t(0), uint8_t(255)); | ||
| } | ||
| raft::resource::sync_stream(res); | ||
| } | ||
|
|
||
| void TearDown() override | ||
| { | ||
| dataset.reset(); | ||
| raft::resource::sync_stream(res); | ||
| } | ||
|
|
||
| private: | ||
| raft::resources res; | ||
| std::optional<raft::device_matrix<data_type, int64_t>> dataset = std::nullopt; | ||
|
|
||
| constexpr static int64_t n_samples = 10000; | ||
| constexpr static int64_t n_dim = 1024; | ||
| }; | ||
|
|
||
| // Instantiate test for different data types | ||
| using TestTypes = ::testing::Types<float, int8_t, uint8_t>; | ||
| TYPED_TEST_SUITE(CagraIterativeBuildBugTest, TestTypes); | ||
|
|
||
| TYPED_TEST(CagraIterativeBuildBugTest, IterativeBuildTest) { this->run(); } | ||
|
|
||
| } // namespace cuvs::neighbors::cagra | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.