Switch to device permute in Vamana#2214
Conversation
Signed-off-by: Mickael Ide <mide@nvidia.com>
📝 WalkthroughSummary by CodeRabbit
WalkthroughVamana insert-order permutation generation moved from CPU to GPU: ChangesVamana Permutation Migration to GPU
🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cpp/src/neighbors/detail/vamana/vamana_build.cuh`:
- Line 62: The fallback seed uses non-thread-safe std::rand() when constructing
raft::random::RngState (the expression raft::random::RngState rng(seed != 0 ?
seed : static_cast<uint64_t>(std::rand()))); replace the std::rand() call with a
thread-safe source (for example, use std::random_device() or a time-based value
such as std::chrono::high_resolution_clock::now().time_since_epoch().count()) so
the fallback expression becomes thread-safe; ensure the replacement is cast to
uint64_t and preserves the existing conditional logic that uses seed when
non-zero.
- Around line 52-55: The function signature for create_insert_permutation has a
syntax error: the parameter list is missing a comma between the insert_order and
seed parameters. Edit the create_insert_permutation declaration to insert a
comma between raft::device_vector_view<IdxT, uint32_t> insert_order and uint64_t
seed = 0 so the compiler sees two distinct parameters (reference the
create_insert_permutation function name and the insert_order and seed parameter
names).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: bcebf6b2-2208-4281-aa12-ab0fc4936104
📒 Files selected for processing (1)
cpp/src/neighbors/detail/vamana/vamana_build.cuh
Signed-off-by: Mickael Ide <mide@nvidia.com>
Signed-off-by: Mickael Ide <mide@nvidia.com>
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
cpp/src/neighbors/detail/vamana/vamana_build.cuh (1)
185-187:⚠️ Potential issue | 🟠 Major | ⚡ Quick winPass a real seed here, or drop the third argument.
Line 187 is still passing
Npositionally, butcreate_insert_permutationnow derives the length frominsert_orderand treats the third parameter asseed. That means same-sized builds get the same insertion order, which is almost certainly not what this refactor intended.Suggested fix
- create_insert_permutation(res, insert_order.view(), static_cast<uint32_t>(N)); + create_insert_permutation(res, insert_order.view());If you want reproducible-but-configurable behavior, thread an actual seed from
index_paramsinstead of reusingN.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cpp/src/neighbors/detail/vamana/vamana_build.cuh` around lines 185 - 187, The call creating the insertion permutation passes N as the third (seed) argument to create_insert_permutation, causing identical seeds for equal-sized builds; change the call in the block that creates insert_order so it either omits the third argument or passes a real seed value (e.g., thread a seed from index_params or another config field) to create_insert_permutation(insert_order.view(), static_cast<uint32_t>(N), seed) (or remove the seed parameter entirely), and ensure the code uses raft::make_device_vector<IdxT, uint32_t>(res, N) and create_insert_permutation with matching arguments.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@cpp/src/neighbors/detail/vamana/vamana_build.cuh`:
- Around line 185-187: The call creating the insertion permutation passes N as
the third (seed) argument to create_insert_permutation, causing identical seeds
for equal-sized builds; change the call in the block that creates insert_order
so it either omits the third argument or passes a real seed value (e.g., thread
a seed from index_params or another config field) to
create_insert_permutation(insert_order.view(), static_cast<uint32_t>(N), seed)
(or remove the seed parameter entirely), and ensure the code uses
raft::make_device_vector<IdxT, uint32_t>(res, N) and create_insert_permutation
with matching arguments.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: def4ad9d-bf5e-4b72-94cc-3691d1698dfe
📒 Files selected for processing (1)
cpp/src/neighbors/detail/vamana/vamana_build.cuh
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
cpp/src/neighbors/detail/vamana/vamana_build.cuh (1)
52-66:⚠️ Potential issue | 🟡 Minor | ⚡ Quick win
create_insert_permutationnow always usesseed = 0, making insert order deterministic across builds
create_insert_permutationdefaultsuint64_t seed = 0and initializesraft::random::RngState rng(seed), whilebatched_insert_vamanacalls it ascreate_insert_permutation(res, insert_order.view())(no seed override). Please confirm this deterministic behavior is intentional; if not, plumb a seed through the API or use a non-deterministic (but thread-safe) seed source.Secondary note: the permutation keys are
floatin[0, 1]; for very largeN, collisions can reduce randomness/uniformity (still yields a valid permutation).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cpp/src/neighbors/detail/vamana/vamana_build.cuh` around lines 52 - 66, create_insert_permutation currently defaults seed=0 causing deterministic insert orders; update the API to accept a non-default seed (or thread-safe random source) and propagate it from callers such as batched_insert_vamana (i.e., add a seed parameter to create_insert_permutation and change batched_insert_vamana to pass a runtime-generated seed), replace float keys with a wider integer key (e.g., uint64_t) generated from raft::random::RngState to avoid collisions for large N, and ensure the thrust::sort_by_key still uses the new key type when shuffling insert_order.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@cpp/src/neighbors/detail/vamana/vamana_build.cuh`:
- Around line 52-66: create_insert_permutation currently defaults seed=0 causing
deterministic insert orders; update the API to accept a non-default seed (or
thread-safe random source) and propagate it from callers such as
batched_insert_vamana (i.e., add a seed parameter to create_insert_permutation
and change batched_insert_vamana to pass a runtime-generated seed), replace
float keys with a wider integer key (e.g., uint64_t) generated from
raft::random::RngState to avoid collisions for large N, and ensure the
thrust::sort_by_key still uses the new key type when shuffling insert_order.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 4df9963e-5c27-4817-b9dd-a13e9ad34679
📒 Files selected for processing (1)
cpp/src/neighbors/detail/vamana/vamana_build.cuh
No description provided.