-
Notifications
You must be signed in to change notification settings - Fork 194
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
IVF-Flat reconstruction #1270
Open
viclafargue
wants to merge
48
commits into
rapidsai:branch-23.08
Choose a base branch
from
viclafargue:ivf-reconstruction
base: branch-23.08
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
IVF-Flat reconstruction #1270
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
328a179
Initial index splitting
lowener a83aca4
Adapt `extend`
lowener 843904a
Refactoring: build and extend fix
lowener f09b3a0
Refactor ivf flat search for index splitting
lowener fdc9395
Merge branch 'branch-23.04' into 23.04-flat-split
lowener 93d5b35
Use mdpsan/mdarray aliases
lowener 5fcf564
Add serialization
lowener c49bf67
Deserialize ivf_flat and style fix
lowener 6ba87d4
Merge branch 'branch-23.04' into 23.04-flat-split
lowener 7e2d80b
Integrate ivf::list to ivf_flat index splitting
lowener 74e0a8c
Update refine
lowener 7b36742
Merge branch 'branch-23.04' into 23.04-flat-split
lowener 135a9b6
Use std vector for ivf flat index list
lowener 81b2cbf
Test second variant of `ivf_flat::extend`
lowener fd33dbc
Use ValueT template on spec
lowener 539fbc5
Use second variant of ivf_extend
lowener 31815d7
Merge branch 'branch-23.04' into 23.04-flat-split
cjnolet 33bfb82
Fix spec template
lowener adb96e4
Revert ValueT on ivfpq
lowener 32936c9
Make ivf::list more flexible
achirkin 23e0f84
Merge pull request #1 from achirkin/23.04-flat-split
lowener acf1888
Use new list API for ivf flat
lowener 0283d25
Merge branch 'branch-23.04' into 23.04-flat-split
lowener f790abf
Fix adaptive centers
lowener 6a05196
Fix adaptive center norms testing
lowener eda7923
Merge branch 'branch-23.04' into 23.04-flat-split
lowener f0a7031
Fix list spec template after merge
lowener a6c54a4
Add serialization overload
lowener 85b4aa1
Fix list size override
lowener 692af0d
Fix resizelist with interleaved format
lowener d892ebb
Merge branch 'branch-23.04' into 23.04-flat-split
lowener a8b96a7
Fix refine list resize operation
lowener 1870541
Merge branch 'branch-23.04' into 23.04-flat-split
lowener beb9264
IVF-Flat reconstruction
viclafargue 2e8bc92
Merge branch 'branch-23.04' into ivf-reconstruction
viclafargue ebda975
Merge branch 'branch-23.04' into ivf-reconstruction
cjnolet 81d51be
Merge branch 'branch-23.04' into ivf-reconstruction
cjnolet d250ae9
Merge branch 'branch-23.06' into ivf-reconstruction
cjnolet e9df346
Merge branch 'branch-23.06' into ivf-reconstruction
viclafargue f798657
addressing review + expose function
viclafargue 080c784
Cluster reconstruction
viclafargue 0f6cdbe
addressing review 1/2
viclafargue cad88b3
addressing review 2/2
viclafargue 6cd1abc
Fix style
viclafargue de6c13d
addressing review
viclafargue 7064703
Merge branch 'branch-23.08' into ivf-reconstruction
viclafargue 5e02d7f
Fix style
viclafargue 87edda0
Fix doc
viclafargue 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 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 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 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 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 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 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 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,38 @@ | ||
/* | ||
* Copyright (c) 2023, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* NOTE: this file is generated by ivf_flat_00_generate.py | ||
* | ||
* Make changes there and run in this directory: | ||
* | ||
* > python ivf_flat_00_generate.py | ||
* | ||
*/ | ||
|
||
#include <raft/neighbors/ivf_flat-inl.cuh> | ||
|
||
#define instantiate_raft_neighbors_ivf_flat_reconstruct(T, IdxT) \ | ||
template void raft::neighbors::ivf_flat::reconstruct_list_data<T, IdxT>( \ | ||
raft::resources const& handle, \ | ||
const raft::neighbors::ivf_flat::index<T, IdxT>& idx, \ | ||
raft::device_matrix_view<T, uint32_t, row_major> out_vectors, \ | ||
uint32_t label, \ | ||
uint32_t offset); | ||
|
||
instantiate_raft_neighbors_ivf_flat_reconstruct(float, int64_t); | ||
|
||
#undef instantiate_raft_neighbors_ivf_flat_reconstruct |
This file contains 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,38 @@ | ||
/* | ||
* Copyright (c) 2023, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* NOTE: this file is generated by ivf_flat_00_generate.py | ||
* | ||
* Make changes there and run in this directory: | ||
* | ||
* > python ivf_flat_00_generate.py | ||
* | ||
*/ | ||
|
||
#include <raft/neighbors/ivf_flat-inl.cuh> | ||
|
||
#define instantiate_raft_neighbors_ivf_flat_reconstruct(T, IdxT) \ | ||
template void raft::neighbors::ivf_flat::reconstruct_list_data<T, IdxT>( \ | ||
raft::resources const& handle, \ | ||
const raft::neighbors::ivf_flat::index<T, IdxT>& idx, \ | ||
raft::device_matrix_view<T, uint32_t, row_major> out_vectors, \ | ||
uint32_t label, \ | ||
uint32_t offset); | ||
|
||
instantiate_raft_neighbors_ivf_flat_reconstruct(int8_t, int64_t); | ||
|
||
#undef instantiate_raft_neighbors_ivf_flat_reconstruct |
This file contains 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,38 @@ | ||
/* | ||
* Copyright (c) 2023, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* NOTE: this file is generated by ivf_flat_00_generate.py | ||
* | ||
* Make changes there and run in this directory: | ||
* | ||
* > python ivf_flat_00_generate.py | ||
* | ||
*/ | ||
|
||
#include <raft/neighbors/ivf_flat-inl.cuh> | ||
|
||
#define instantiate_raft_neighbors_ivf_flat_reconstruct(T, IdxT) \ | ||
template void raft::neighbors::ivf_flat::reconstruct_list_data<T, IdxT>( \ | ||
raft::resources const& handle, \ | ||
const raft::neighbors::ivf_flat::index<T, IdxT>& idx, \ | ||
raft::device_matrix_view<T, uint32_t, row_major> out_vectors, \ | ||
uint32_t label, \ | ||
uint32_t offset); | ||
|
||
instantiate_raft_neighbors_ivf_flat_reconstruct(uint8_t, int64_t); | ||
|
||
#undef instantiate_raft_neighbors_ivf_flat_reconstruct |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the consensus was to opt for a "inverted-index" module (hashmap/array/whatever) shared among ivf methods to convert user indices to (label, in-cluster-offset) pairs?
This code could break if the user adds non-contiguous range of large indices to the DB.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review! Yes absolutely, this is a temporary solution that would be largely improved by the use of a hashmap in a follow-up PR. But, I thought that letting this version as it is would set the API and allow people to run a reconstruction if their use case allows it (smaller index). But, can still remove it if that's the better path forward. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was actually thinking of decoupling the ivf-list hashmap struct api from the ivf-pq and ivf-flat methods. Hence a user would need to construct the hashmap explicitly once (costly operation) and then either:
a) search-by-user-ids in two calls (e.g. hashmap::get_lists_offsets + index::get_vectors)
b) pass the hashmap as an argument to the ivf index methods (index::get_vectors)
Not sure what we will decide in the end, but point is the api may change as we progress with the hashmap. Then, maybe we just can keep this function in the
detail
namespace for now? Hence the work won't be lost and if someone needs the functionality urgently, they can use the detail function, and we don't need to break the public api in the follow-up PR.