Skip to content

Add missing HNSW bindings - #2307

Open
julianmi wants to merge 18 commits into
NVIDIA:mainfrom
julianmi:hnsw-bindings
Open

Add missing HNSW bindings#2307
julianmi wants to merge 18 commits into
NVIDIA:mainfrom
julianmi:hnsw-bindings

Conversation

@julianmi

@julianmi julianmi commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Add the missing HNSW bindings and cleans up the changes in #1719.

Implements feature #2156. More work might be needed to better fit the recall curve provided by HNSW. See #2031. CC @achirkin

@julianmi
julianmi requested review from a team as code owners July 8, 2026 13:26
@julianmi julianmi self-assigned this Jul 8, 2026
@julianmi julianmi added feature request New feature or request non-breaking Introduces a non-breaking change labels Jul 8, 2026
*/
@Override
public SearchResults search(HnswQuery query) throws Throwable {
synchronized (lifecycleLock) {

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.

If I understand the intent correctly, this synchronized block was added to ensure a clean shutdown. However, it also appears to serialize all searches, preventing concurrent execution. If we want to enforce shutdown semantics here, a read-write lock may be a better fit. That said, at least in Lucene this concern is usually delegated to the caller. The caller typically tracks in-flight requests via reference counting (or a similar mechanism) and ensures that shutdown does not proceed until all outstanding requests have completed. So adding it here might duplicate an effort in some systems.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you and sorry that I missed this comment. I ran into an issues with a test that I've added and added the synchronization. I've reverted this change.

@dantegd dantegd 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.

lgtm, but it'd be a good idea to also update fern/pages/cuvs_bench/param_tuning.md?. The cuvs_hnsw section currently describes builds as always using ACE, but it would be good to reflect that the C++ HNSW build path automatically uses an in-memory CAGRA build when sufficient memory is available and falls back to ACE otherwise. This PR exposes that existing behavior through the bindings, so it would be good for the tuning guide to reflect it. What do you think?

@julianmi

Copy link
Copy Markdown
Contributor Author

lgtm, but it'd be a good idea to also update fern/pages/cuvs_bench/param_tuning.md?. The cuvs_hnsw section currently describes builds as always using ACE, but it would be good to reflect that the C++ HNSW build path automatically uses an in-memory CAGRA build when sufficient memory is available and falls back to ACE otherwise. This PR exposes that existing behavior through the bindings, so it would be good for the tuning guide to reflect it. What do you think?

Good catch. I updated the cuvs_hnsw tuning section to describe the automatic in-memory CAGRA/ACE selection and clarified that the ACE tuning parameters apply only when ACE is selected.

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

Labels

feature request New feature or request non-breaking Introduces a non-breaking change

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

4 participants