Skip to content

PiPNN 5/6: add HashPrune candidate merging - #1591

Open
weiyaoluo (SeliMeli) wants to merge 2 commits into
pipnn-stack/04-integrationfrom
pipnn-stack/06-hash-prune
Open

weiyaoluo (SeliMeli) wants to merge 2 commits into
pipnn-stack/04-integrationfrom
pipnn-stack/06-hash-prune

Conversation

@SeliMeli

Copy link
Copy Markdown
Contributor

Purpose

This PR adds optional HashPrune candidate merging to PiPNN.

Direct candidate merging remains the default.

Main changes

  • lsh.rs creates deterministic random-hyperplane sketches.
  • Each directed edge receives a relative-direction hash.
  • Leaf CSR conversion omits unassigned numerical-kernel slots.
  • Each source owns one bounded reservoir and one lock.
  • A hash bucket keeps its nearest candidate.
  • Full reservoirs reject or evict candidates by total order.
  • final_prune=true sends reservoir candidates to shared RobustPrune.
  • final_prune=false returns the nearest graph-degree candidates.
  • Disk configuration accepts the optional HashPrune policy.

Required invariants

  • Effective hash capacity covers graph degree.
  • l_max does not exceed the structural reservoir limit.
  • Padded cells never become candidates.
  • One source lock protects each reservoir mutation.
  • Leaf-local IDs become global IDs before insertion.
  • Tie order uses distance, relative hash, and neighbor ID.

Review order

  1. Review HashPruneConfig and Builder::hash_prune in mod.rs.
  2. Review sketch construction in lsh.rs.
  3. Review slab ownership and locking in hash_prune.rs.
  4. Review insertion and extraction in hash_prune.rs.
  5. Review leaf CSR conversion in leaf_build.rs.
  6. Review disk configuration.

Validation

  • The diskann PiPNN library tests pass.
  • The disk tests pass, including a HashPrune build over MinMax rows.
  • Targeted strict-provenance Miri tests pass.

Stack

Stack 5/6. Depends on #1291. #1294 adds the benchmark routes.

This PR replaces #1295. The stack order changed, and GitHub closed #1295 as merged. The earlier review of HashPrune is on #1295.

Merge leaf candidates into bounded direction-hash reservoirs.
Expose HashPrune settings through the disk PiPNN configuration.
Add direct and HashPrune disk-build coverage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	diskann-disk/src/build/builder/tests.rs
#	diskann-disk/src/build/configuration/build_algorithm.rs
#	diskann-disk/src/build/configuration/mod.rs
@SeliMeli
weiyaoluo (SeliMeli) requested review from a team and a balanced review from Copilot November 11, 2026 08:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Tie handling violates the required deterministic candidate order, and CSR conversion lacks regression coverage for unassigned slots and reused scratch flags.

2 open issues
What changed in this PR

Adds optional HashPrune candidate merging to PiPNN’s batch graph builder, extending the disk-build integration while keeping direct merging as the default.

Changes:

  • Adds seeded hyperplane sketches and bounded, per-point candidate reservoirs with optional final RobustPrune.
  • Converts leaf candidates into symmetric CSR edges while excluding unassigned kernel slots.
  • Adds SIMD optimizations, disk integration coverage, and nightly Miri checks.
File Description
diskann/​src/​graph/​pipnn/​mod.rs Adds HashPrune configuration, validation, and build routing.
diskann/​src/​graph/​pipnn/​lsh.rs Generates seeded random-hyperplane sketches.
diskann/​src/​graph/​pipnn/​leaf_build.rs Builds symmetric CSR edges for reservoir ingestion.
diskann/​src/​graph/​pipnn/​hash_prune.rs Implements locked reservoirs, candidate selection, and extraction.
diskann/​src/​graph/​pipnn/​bf16.rs Adds compact distance conversion and tests.
diskann/​src/​graph/​adjacencylist.rs Allows allocation-preserving conversion of unique neighbor vectors.
diskann/​Cargo.toml Adds optional HashPrune dependencies to PiPNN.
diskann-wide/​src/​doubled.rs Optimizes first-set-lane lookup for doubled masks.
diskann-wide/​src/​arch/​x86_64/​v3/​i16x16_.rs Uses native SIMD instructions for equality masks.
diskann-disk/​src/​build/​builder/​tests.rs Tests HashPrune disk builds over MinMax-decoded rows.
Cargo.lock Records the added dependencies.
.github/​workflows/​nightly.yml Adds strict-provenance Miri checks for sketches and reservoirs.

Review effort: Balanced

Comment on lines +498 to +500
if state.len >= l_max && dist_key >= state.farthest_dist {
return false;
}
grow(offsets, point_count + 1, 0);
offsets[..point_count + 1].fill(0);
for (source, neighbors) in neighbors.chunks_exact(leaf_k).enumerate() {
for neighbor in neighbors.iter().filter(|neighbor| neighbor.is_assigned()) {
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.15686% with 49 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.24%. Comparing base (b5b7acf) to head (90d6fb9).

Files with missing lines Patch % Lines
diskann/src/graph/pipnn/hash_prune.rs 95.91% 35 Missing ⚠️
diskann/src/graph/pipnn/lsh.rs 94.02% 8 Missing ⚠️
diskann/src/graph/pipnn/mod.rs 95.93% 5 Missing ⚠️
diskann/src/graph/pipnn/leaf_build.rs 99.20% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                      Coverage Diff                       @@
##           pipnn-stack/04-integration    #1591      +/-   ##
==============================================================
+ Coverage                       92.20%   92.24%   +0.03%     
==============================================================
  Files                             621      624       +3     
  Lines                          130490   131750    +1260     
==============================================================
+ Hits                           120318   121527    +1209     
- Misses                          10172    10223      +51     
Flag Coverage Δ
miri 92.24% <96.15%> (+0.03%) ⬆️
unittests 92.19% <96.15%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
diskann-wide/src/arch/x86_64/v3/i16x16_.rs 100.00% <100.00%> (ø)
diskann-wide/src/doubled.rs 85.89% <100.00%> (+0.30%) ⬆️
diskann/src/graph/adjacencylist.rs 99.71% <100.00%> (+0.01%) ⬆️
diskann/src/graph/pipnn/bf16.rs 100.00% <100.00%> (ø)
diskann/src/graph/pipnn/leaf_build.rs 99.72% <99.20%> (+0.13%) ⬆️
diskann/src/graph/pipnn/mod.rs 95.18% <95.93%> (+0.16%) ⬆️
diskann/src/graph/pipnn/lsh.rs 94.02% <94.02%> (ø)
diskann/src/graph/pipnn/hash_prune.rs 95.91% <95.91%> (ø)

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants