Skip to content

Fix: Avoid duplicate neighbor slots in HNSW reverse links#699

Merged
ashvardanian merged 3 commits intounum-cloud:main-devfrom
yoonseok-kim:issue-698-bugfix
Mar 2, 2026
Merged

Fix: Avoid duplicate neighbor slots in HNSW reverse links#699
ashvardanian merged 3 commits intounum-cloud:main-devfrom
yoonseok-kim:issue-698-bugfix

Conversation

@yoonseok-kim
Copy link
Contributor

This PR fixes #698.

@yoonseok-kim yoonseok-kim changed the base branch from main to main-dev January 7, 2026 18:23
@yoonseok-kim
Copy link
Contributor Author

yoonseok-kim commented Feb 17, 2026

I understand this problem may not be a critical issue, but I think it could be considered a bug. I would appreciate it if you could review whether it might be possible to address this in next release. If this PR is merged, it would benefit our product. Thank you for your consideration. :)

@ashvardanian
Copy link
Contributor

Hi @yoonseok-kim! Shouldn't we instead use std::find? It typically vectorizes much better 🤗

@yoonseok-kim
Copy link
Contributor Author

Good point. thanks! I’ll apply it.

// then no need to modify any connections or run the heuristics.
if (close_header.size() < connectivity_max) {
close_header.push_back(new_slot);
if (std::find_if(close_header.begin(), close_header.end(),
Copy link
Contributor Author

@yoonseok-kim yoonseok-kim Feb 23, 2026

Choose a reason for hiding this comment

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

close_header's iterator returns misaligned_ref_gt, not compressed_slot_t, so the internal *it == value comparison in std::find fails. I tried changing to std::find_if so that the predicate(lambda) receives a value. when the lambda is called with compressed_slot_t slot, the misaligned_ref_gt is converted to a value and slot == new_slot compiles.

@yoonseok-kim
Copy link
Contributor Author

yoonseok-kim commented Feb 23, 2026

I would appreciate it if you could review this.
(I think current CI failures don't appear to be related to this PR.)

@yoonseok-kim yoonseok-kim changed the base branch from main-dev to main February 27, 2026 02:17
@yoonseok-kim yoonseok-kim changed the base branch from main to main-dev February 27, 2026 02:18
@ashvardanian ashvardanian merged commit 6995246 into unum-cloud:main-dev Mar 2, 2026
8 of 12 checks passed
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.

Bug: Duplicate neighbor slots produced during incremental indexing(update, remove) in HNSW reverse links

2 participants