-
Notifications
You must be signed in to change notification settings - Fork 211
Fix IVF extend list resize bug #2297
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
Open
qwertyforce
wants to merge
7
commits into
NVIDIA:main
Choose a base branch
from
qwertyforce:fix_ivf_resize
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7d5f827
Fix IVF extend list resize
f4cee4f
better comments + hpp
7cd89ac
improve tests
4fad934
Pad the list extents to account for interleaved storage
achirkin fba1eb4
Fix serialize: store actual used size rather than the padded extents …
achirkin a51ec2a
Merge branch 'main' into fix_ivf_resize
achirkin 31ac750
Merge branch 'main' into fix_ivf_resize
tfeher 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
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
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
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
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 |
|---|---|---|
| @@ -1,17 +1,73 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION. | ||
| * SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #include <gtest/gtest.h> | ||
|
|
||
| #include "../ann_ivf_sq.cuh" | ||
|
|
||
| #include <raft/core/resource/cuda_stream.hpp> | ||
| #include <raft/linalg/init.cuh> | ||
| #include <raft/matrix/init.cuh> | ||
|
|
||
| #include <optional> | ||
|
|
||
| namespace cuvs::neighbors::ivf_sq { | ||
|
|
||
| typedef AnnIVFSQTest<float, float, int64_t> AnnIVFSQTestF_float; | ||
| TEST_P(AnnIVFSQTestF_float, AnnIVFSQ) { this->testAll(); } | ||
|
|
||
| INSTANTIATE_TEST_CASE_P(AnnIVFSQTest, AnnIVFSQTestF_float, ::testing::ValuesIn(inputs)); | ||
|
|
||
| TEST(AnnIVFSQTest, ExtendInPlaceUpdatesListSizeWithinCapacity) | ||
|
huuanhhuyn marked this conversation as resolved.
|
||
| { | ||
| raft::resources handle; | ||
| auto stream = raft::resource::get_cuda_stream(handle); | ||
|
|
||
| constexpr int64_t base_rows = 100; | ||
| constexpr int64_t grow_rows = 20; | ||
| constexpr int64_t rows = base_rows + grow_rows; | ||
| constexpr int64_t dim = 4; | ||
|
|
||
| auto data = raft::make_device_matrix<float, int64_t>(handle, rows, dim); | ||
| raft::matrix::fill(handle, data.view(), 0.0f); | ||
|
|
||
| index_params params; | ||
| params.n_lists = 1; | ||
| params.metric = cuvs::distance::DistanceType::L2Expanded; | ||
| params.add_data_on_build = false; | ||
| params.max_train_points_per_cluster = 256; | ||
| params.conservative_memory_allocation = false; | ||
|
|
||
| auto all_data_view = | ||
| raft::make_device_matrix_view<const float, int64_t>(data.data_handle(), rows, dim); | ||
| auto index = build(handle, params, all_data_view); | ||
|
|
||
| auto base_data_view = | ||
| raft::make_device_matrix_view<const float, int64_t>(data.data_handle(), base_rows, dim); | ||
| extend(handle, base_data_view, std::nullopt, &index); | ||
| raft::resource::sync_stream(handle); | ||
|
|
||
| ASSERT_EQ(index.lists()[0]->get_size(), base_rows); | ||
| ASSERT_EQ(index.lists()[0]->indices_capacity(), raft::Pow2<kIndexGroupSize>::roundUp(rows)); | ||
| auto* base_list = index.lists()[0].get(); | ||
|
huuanhhuyn marked this conversation as resolved.
|
||
|
|
||
| auto indices = raft::make_device_vector<int64_t, int64_t>(handle, grow_rows); | ||
| raft::linalg::range(indices.data_handle(), base_rows, rows, stream); | ||
|
|
||
| auto grow_data_view = raft::make_device_matrix_view<const float, int64_t>( | ||
| data.data_handle() + base_rows * dim, grow_rows, dim); | ||
| auto grow_indices_view = | ||
| raft::make_device_vector_view<const int64_t, int64_t>(indices.data_handle(), grow_rows); | ||
| extend(handle, | ||
| grow_data_view, | ||
| std::make_optional<raft::device_vector_view<const int64_t, int64_t>>(grow_indices_view), | ||
| &index); | ||
| raft::resource::sync_stream(handle); | ||
|
|
||
| EXPECT_EQ(index.lists()[0].get(), base_list); | ||
| EXPECT_EQ(index.lists()[0]->get_size(), rows); | ||
| } | ||
|
|
||
| } // namespace cuvs::neighbors::ivf_sq | ||
Oops, something went wrong.
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.