-
Notifications
You must be signed in to change notification settings - Fork 143
Reduce binary size of refine functions #1095
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
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d19c868
Use already instantiated ivf_flat search kernels for refinement
tfeher 3fa8b68
Add headers for data types
tfeher daf2181
Merge remote-tracking branch 'origin/branch-25.08' into refine_binary…
tfeher 028e98b
instantiate ivfflat_interleaved_scan in separate files
tfeher 9c2fccd
Address review issues
tfeher c9d7e68
fix template arg order and factor bitset filtered instantiations into…
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
49 changes: 49 additions & 0 deletions
49
cpp/src/neighbors/ivf_flat/ivf_flat_interleaved_scan_explicit_inst.cuh
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,49 @@ | ||
| /* | ||
| * Copyright (c) 2025, 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. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "../detail/ann_utils.cuh" | ||
| #include "ivf_flat_interleaved_scan.cuh" | ||
| #include <cstdint> | ||
| #include <cuvs/neighbors/common.hpp> | ||
| #include <cuvs/neighbors/ivf_flat.hpp> | ||
| #include <raft/core/resource/cuda_stream.hpp> | ||
| #include <raft/core/resources.hpp> | ||
|
|
||
| #define CUVS_INST_IVF_FLAT_INTERLEAVED_SCAN(T, IdxT, SampleFilterT) \ | ||
| template void \ | ||
| ivfflat_interleaved_scan<T, \ | ||
| typename cuvs::spatial::knn::detail::utils::config<T>::value_t, \ | ||
| IdxT, \ | ||
| SampleFilterT>(const index<T, IdxT>& index, \ | ||
| const T* queries, \ | ||
| const uint32_t* coarse_query_results, \ | ||
| const uint32_t n_queries, \ | ||
| const uint32_t queries_offset, \ | ||
| const cuvs::distance::DistanceType metric, \ | ||
| const uint32_t n_probes, \ | ||
| const uint32_t k, \ | ||
| const uint32_t max_samples, \ | ||
| const uint32_t* chunk_indices, \ | ||
| const bool select_min, \ | ||
| SampleFilterT sample_filter, \ | ||
| uint32_t* neighbors, \ | ||
| float* distances, \ | ||
| uint32_t& grid_dim_x, \ | ||
| rmm::cuda_stream_view stream); | ||
|
|
||
| #define COMMA , |
96 changes: 96 additions & 0 deletions
96
cpp/src/neighbors/ivf_flat/ivf_flat_interleaved_scan_ext.cuh
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,96 @@ | ||
| /* | ||
| * Copyright (c) 2025, 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. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <cstdint> | ||
| #include <cuda_fp16.h> | ||
|
|
||
| #include "../detail/ann_utils.cuh" | ||
| #include <cuvs/neighbors/common.hpp> | ||
| #include <raft/core/resource/cuda_stream.hpp> | ||
| #include <raft/core/resources.hpp> | ||
| #include <raft/util/raft_explicit.hpp> | ||
|
|
||
| namespace cuvs::neighbors::ivf_flat::detail { | ||
| template <typename T, typename AccT, typename IdxT, typename IvfSampleFilterT> | ||
| void ivfflat_interleaved_scan(const index<T, IdxT>& index, | ||
| const T* queries, | ||
| const uint32_t* coarse_query_results, | ||
| const uint32_t n_queries, | ||
| const uint32_t queries_offset, | ||
| const cuvs::distance::DistanceType metric, | ||
| const uint32_t n_probes, | ||
| const uint32_t k, | ||
| const uint32_t max_samples, | ||
| const uint32_t* chunk_indices, | ||
| const bool select_min, | ||
| IvfSampleFilterT sample_filter, | ||
| uint32_t* neighbors, | ||
| float* distances, | ||
| uint32_t& grid_dim_x, | ||
| rmm::cuda_stream_view stream) RAFT_EXPLICIT; | ||
|
|
||
| #define CUVS_INST_IVF_FLAT_INTERLEAVED_SCAN(T, IdxT, SampleFilterT) \ | ||
tfeher marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| extern template void \ | ||
| ivfflat_interleaved_scan<T, \ | ||
| typename cuvs::spatial::knn::detail::utils::config<T>::value_t, \ | ||
| IdxT, \ | ||
| SampleFilterT>(const index<T, IdxT>& index, \ | ||
| const T* queries, \ | ||
| const uint32_t* coarse_query_results, \ | ||
| const uint32_t n_queries, \ | ||
| const uint32_t queries_offset, \ | ||
| const cuvs::distance::DistanceType metric, \ | ||
| const uint32_t n_probes, \ | ||
| const uint32_t k, \ | ||
| const uint32_t max_samples, \ | ||
| const uint32_t* chunk_indices, \ | ||
| const bool select_min, \ | ||
| SampleFilterT sample_filter, \ | ||
| uint32_t* neighbors, \ | ||
| float* distances, \ | ||
| uint32_t& grid_dim_x, \ | ||
| rmm::cuda_stream_view stream); | ||
|
|
||
| CUVS_INST_IVF_FLAT_INTERLEAVED_SCAN(float, int64_t, cuvs::neighbors::filtering::none_sample_filter); | ||
|
|
||
| CUVS_INST_IVF_FLAT_INTERLEAVED_SCAN(half, int64_t, cuvs::neighbors::filtering::none_sample_filter); | ||
|
|
||
| CUVS_INST_IVF_FLAT_INTERLEAVED_SCAN(int8_t, | ||
| int64_t, | ||
| cuvs::neighbors::filtering::none_sample_filter); | ||
|
|
||
| CUVS_INST_IVF_FLAT_INTERLEAVED_SCAN(uint8_t, | ||
| int64_t, | ||
| cuvs::neighbors::filtering::none_sample_filter); | ||
|
|
||
| #define COMMA , | ||
| CUVS_INST_IVF_FLAT_INTERLEAVED_SCAN( | ||
| float, int64_t, cuvs::neighbors::filtering::bitset_filter<uint32_t COMMA int64_t>); | ||
|
|
||
| CUVS_INST_IVF_FLAT_INTERLEAVED_SCAN( | ||
| half, int64_t, cuvs::neighbors::filtering::bitset_filter<uint32_t COMMA int64_t>); | ||
|
|
||
| CUVS_INST_IVF_FLAT_INTERLEAVED_SCAN( | ||
| int8_t, int64_t, cuvs::neighbors::filtering::bitset_filter<uint32_t COMMA int64_t>); | ||
|
|
||
| CUVS_INST_IVF_FLAT_INTERLEAVED_SCAN( | ||
| uint8_t, int64_t, cuvs::neighbors::filtering::bitset_filter<uint32_t COMMA int64_t>); | ||
| #undef COMMA | ||
| #undef CUVS_INST_IVF_FLAT_INTERLEAVED_SCAN | ||
|
|
||
| } // namespace cuvs::neighbors::ivf_flat::detail | ||
21 changes: 21 additions & 0 deletions
21
cpp/src/neighbors/ivf_flat/ivf_flat_interleaved_scan_float_int64_t.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,21 @@ | ||
| /* | ||
| * Copyright (c) 2025, 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. | ||
| */ | ||
| #include "ivf_flat_interleaved_scan_explicit_inst.cuh" | ||
|
|
||
| namespace cuvs::neighbors::ivf_flat::detail { | ||
|
|
||
| CUVS_INST_IVF_FLAT_INTERLEAVED_SCAN(float, int64_t, filtering::none_sample_filter); | ||
| } // namespace cuvs::neighbors::ivf_flat::detail |
23 changes: 23 additions & 0 deletions
23
cpp/src/neighbors/ivf_flat/ivf_flat_interleaved_scan_float_int64_t_bitset.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,23 @@ | ||
| /* | ||
| * Copyright (c) 2025, 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. | ||
| */ | ||
| #include "ivf_flat_interleaved_scan_explicit_inst.cuh" | ||
|
|
||
| namespace cuvs::neighbors::ivf_flat::detail { | ||
|
|
||
| CUVS_INST_IVF_FLAT_INTERLEAVED_SCAN(float, | ||
| int64_t, | ||
| filtering::bitset_filter<uint32_t COMMA int64_t>); | ||
| } // namespace cuvs::neighbors::ivf_flat::detail |
24 changes: 24 additions & 0 deletions
24
cpp/src/neighbors/ivf_flat/ivf_flat_interleaved_scan_half_int64_t.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,24 @@ | ||
| /* | ||
| * Copyright (c) 2025, 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. | ||
| */ | ||
|
|
||
| #include "ivf_flat_interleaved_scan_explicit_inst.cuh" | ||
| #include <cuda_fp16.h> | ||
|
|
||
| namespace cuvs::neighbors::ivf_flat::detail { | ||
|
|
||
| CUVS_INST_IVF_FLAT_INTERLEAVED_SCAN(half, int64_t, filtering::none_sample_filter); | ||
|
|
||
| } // namespace cuvs::neighbors::ivf_flat::detail |
26 changes: 26 additions & 0 deletions
26
cpp/src/neighbors/ivf_flat/ivf_flat_interleaved_scan_half_int64_t_bitset.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,26 @@ | ||
| /* | ||
| * Copyright (c) 2025, 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. | ||
| */ | ||
|
|
||
| #include "ivf_flat_interleaved_scan_explicit_inst.cuh" | ||
| #include <cuda_fp16.h> | ||
|
|
||
| namespace cuvs::neighbors::ivf_flat::detail { | ||
|
|
||
| CUVS_INST_IVF_FLAT_INTERLEAVED_SCAN(half, | ||
| int64_t, | ||
| filtering::bitset_filter<uint32_t COMMA int64_t>); | ||
|
|
||
| } // namespace cuvs::neighbors::ivf_flat::detail |
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.