-
Notifications
You must be signed in to change notification settings - Fork 195
Multi partition cagra search #2035
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
Draft
jamxia155
wants to merge
32
commits into
NVIDIA:main
Choose a base branch
from
jamxia155:multi-segment-cagra-search
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.
+3,306
−71
Draft
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
c6e880d
Add multi-segment GPU search: cuvsSelectK C API and Java bindings
jamxia155 390adec
Add parallel multi-segment CAGRA search with async memory resource
jamxia155 92dbcf9
Fix CudaStreamPool races and reduce multi-segment search overhead
jamxia155 82dcf71
Default initialize CAGRA search parameters
jamxia155 fad76cb
Enable persistent CAGRA kernel to be shared across index segments
jamxia155 22a2c8d
java: parallelize persistent-mode segment searches in MultiSegmentCag…
jamxia155 69c4771
Add native multi-segment CAGRA search and per-resources workspace pool
jamxia155 49e5a14
java: add DataType.HALF (float16) support to CuVSMatrix
jamxia155 29751c7
Fix errors after merge
jamxia155 2fffcb8
Remove dead code
jamxia155 d284bd0
Remove remnants of experimental code
jamxia155 1e012c0
Load libcudart.so automatically when libcuvs_c.so uses static CUDA
jamxia155 235fb32
Add multi-segment CAGRA search with bitset prefilter support
jamxia155 86a4f70
Add prefiltered ground truth generation to cuvs_bench
jamxia155 21bd700
Check for sufficient itopk_size
jamxia155 e1954b3
Update nomenclature to multi-partition
jamxia155 fdb025c
Refactor multi-partition CAGRA search to return merged global top-k
jamxia155 12d7f55
Allow multi-partition CAGRA search topk to exceed per-partition itopk…
jamxia155 7f479b8
Revert "Allow multi-partition CAGRA search topk to exceed per-partiti…
jamxia155 6b4e34f
Route multi-partition CAGRA search by params.algo
jamxia155 cf679b9
Enable MULTI_KERNEL in multi-partition CAGRA search
jamxia155 37a65d7
Tighten SINGLE_CTA multi-partition feasibility check
jamxia155 56e99ee
Add partition-aware MULTI_KERNEL expansion kernels
jamxia155 aa93362
Add unit tests for partition-aware MULTI_KERNEL kernels
jamxia155 4db0941
Fuse MULTI_KERNEL multi-partition into a single search call
jamxia155 876fb4d
Revert MULTI_KERNEL multi-partition work
jamxia155 f071508
Tighten SINGLE_CTA multi-partition feasibility check
jamxia155 efc7283
Generalize multi-partition post-processing for variable per-partition…
jamxia155 837767d
Add multi-partition MULTI_CTA search path
jamxia155 4b423ea
Gate multi-partition AUTO on (query, partition) CTA count
jamxia155 54a55f5
Merge remote-tracking branch 'origin/main' into multi-segment-cagra-s…
jamxia155 134f899
Updates to snapshotRepository and plugins
jolorunyomi 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| #pragma once | ||
|
|
||
| #include <cuvs/core/c_api.h> | ||
| #include <dlpack/dlpack.h> | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| /** | ||
| * @brief Select the k smallest values from a flat device array of n candidates. | ||
| * | ||
| * Treats `in_val` as a matrix of shape [1, n] and selects the `k` smallest | ||
| * float values. `out_idx` receives the int64 column positions of the selected | ||
| * values in [0, n), so the caller can recover per-segment identity as: | ||
| * | ||
| * segment_index = out_idx[j] / segment_k | ||
| * position_in_segment = out_idx[j] % segment_k | ||
| * | ||
| * @param[in] res cuvsResources_t handle | ||
| * @param[in] in_val DLManagedTensor* shape [1, n], float32, device memory | ||
| * @param[out] out_val DLManagedTensor* shape [1, k], float32, device memory | ||
| * @param[out] out_idx DLManagedTensor* shape [1, k], int64, device memory | ||
| * @return cuvsError_t | ||
| */ | ||
| CUVS_EXPORT cuvsError_t cuvsSelectK(cuvsResources_t res, | ||
| DLManagedTensor* in_val, | ||
| DLManagedTensor* out_val, | ||
| DLManagedTensor* out_idx); | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif |
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 |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #include <cuvs/core/c_api.h> | ||
| #include "../core/exceptions.hpp" | ||
| #include <cuvs/selection/select_k.hpp> | ||
| #include <dlpack/dlpack.h> | ||
|
|
||
| #include <raft/core/device_mdspan.hpp> | ||
| #include <raft/core/resources.hpp> | ||
|
|
||
| extern "C" cuvsError_t cuvsSelectK(cuvsResources_t res, | ||
| DLManagedTensor* in_val, | ||
| DLManagedTensor* out_val, | ||
| DLManagedTensor* out_idx) | ||
| { | ||
| return cuvs::core::translate_exceptions([=] { | ||
| auto* res_ptr = reinterpret_cast<raft::resources*>(res); | ||
|
|
||
| int64_t n = in_val->dl_tensor.shape[1]; | ||
| int64_t k = out_val->dl_tensor.shape[1]; | ||
|
|
||
| auto in_view = raft::make_device_matrix_view<const float, int64_t, raft::row_major>( | ||
| static_cast<const float*>(in_val->dl_tensor.data), 1, n); | ||
|
|
||
| auto out_val_view = raft::make_device_matrix_view<float, int64_t, raft::row_major>( | ||
| static_cast<float*>(out_val->dl_tensor.data), 1, k); | ||
|
|
||
| auto out_idx_view = raft::make_device_matrix_view<int64_t, int64_t, raft::row_major>( | ||
| static_cast<int64_t*>(out_idx->dl_tensor.data), 1, k); | ||
|
|
||
| cuvs::selection::select_k( | ||
| *res_ptr, | ||
| in_view, | ||
| std::nullopt, // implicit positions [0, n) as in_idx | ||
| out_val_view, | ||
| out_idx_view, | ||
| true); // select_min = true (smallest distance = nearest neighbor) | ||
| }); | ||
| } | ||
Oops, something went wrong.
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.
Validate the DLPack contract before dereferencing
shape[1]and casting buffers.cuvsSelectKcurrently assumes non-null 2D CUDA tensors with float32 / float32 / int64 dtypes, zero offset, and contiguous row-major layout. Without checkingndim,shape,device,dtype,byte_offset, and stride compatibility, malformed callers can crash here or feed corrupted views intoselect_k.🤖 Prompt for AI Agents