Skip to content

Fast CAGRA Index Merge - #2352

Open
landrumb wants to merge 50 commits into
NVIDIA:mainfrom
landrumb:landrumb/cagra-fastener-merge
Open

Fast CAGRA Index Merge#2352
landrumb wants to merge 50 commits into
NVIDIA:mainfrom
landrumb:landrumb/cagra-fastener-merge

Conversation

@landrumb

@landrumb landrumb commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

This PR implements the Fastener graph merge operation. This PR supports merging for float, half, int8, and uint8 dtypes, and euclidean distances.

There was originally specialization to use int8 GEMM for the integer types, but I ran into portability issues on Ada and it turns out that using the same f32 path for both is simpler and not substantially slower. Currently investigating switching the unified path to TF32 to use tensor cores.

The core logic resides in cagra_merge_scaffold.cuh.

This PR adds 7.64 MiB to libcuvs.so, a 2.94% increase.

image (H100) image image image image image

@copy-pr-bot

copy-pr-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@copy-pr-bot

copy-pr-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@dantegd

dantegd commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

/ok to test 2c54392

@aamijar aamijar added non-breaking Introduces a non-breaking change feature request New feature or request labels Jul 22, 2026
@aamijar aamijar moved this to In Progress in Unstructured Data Processing Jul 22, 2026
@landrumb

Copy link
Copy Markdown
Contributor Author

/ok to test

@landrumb

Copy link
Copy Markdown
Contributor Author

/ok to test

@landrumb

Copy link
Copy Markdown
Contributor Author

/ok to test

@landrumb

Copy link
Copy Markdown
Contributor Author

/ok to test

landrumb and others added 5 commits August 3, 2026 10:23
Co-authored-by: Artem M. Chirkin <9253178+achirkin@users.noreply.github.com>
Co-authored-by: Artem M. Chirkin <9253178+achirkin@users.noreply.github.com>
@landrumb
landrumb requested a review from dantegd August 4, 2026 16:44
@landrumb
landrumb force-pushed the landrumb/cagra-fastener-merge branch from 1b8558a to 653e8a0 Compare August 4, 2026 20:20
@landrumb
landrumb requested a review from achirkin August 5, 2026 17:50
rapids-bot Bot pushed a commit that referenced this pull request Aug 6, 2026
The graph merge PR (#2352) uses some of the kernels defined by CAGRA, and binary size takes a hit from them not appearing in a TU where they can be shared by both CAGRA and Fastener.

Authors:
  - Ben Landrum (https://github.com/landrumb)

Approvers:
  - Divye Gala (https://github.com/divyegala)

URL: #2412

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

Have only the small concerns, besides it things look solid!

Also, it looks like a few working artifacts may have slipped into the PR that need to be removed before merge: PR_2352_REVIEW_WORK.md, pipnn.pdf and FASTENER_PR_PLAN.md, right?

Comment thread cpp/src/neighbors/detail/cagra/cagra_merge_scaffold.cuh Outdated
Comment thread cpp/src/neighbors/detail/cagra/cagra_merge_scaffold.cuh Outdated
Comment thread cpp/include/cuvs/neighbors/cagra.hpp Outdated
Comment thread cpp/include/cuvs/neighbors/cagra.hpp
Comment thread c/src/neighbors/cagra.cpp
Comment thread cpp/src/neighbors/detail/cagra/cagra_merge.cuh Outdated
Comment thread cpp/src/neighbors/detail/cagra/cagra_merge_scaffold.cuh
Comment thread cpp/src/neighbors/detail/cagra/cagra_merge_scaffold.cuh Outdated
Comment thread cpp/src/neighbors/detail/cagra/cagra_merge_scaffold.cuh Outdated
Comment thread cpp/src/neighbors/detail/cagra/cagra_merge_scaffold.cuh

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

Thanks for the refactoring! One problem with the switch to cublasLtMatmul (see below).

decltype(&cublasLtMatrixLayoutDestroy)>;

cublasLtMatmulDesc_t operation_raw = nullptr;
RAFT_CUBLAS_TRY(cublasLtMatmulDescCreate(&operation_raw, GEMM_COMPUTE_TYPE, CUDA_R_32F));

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.

Please destroy the descriptors and matrix layouts after you use them, (otherwise, this is a memory leak currently).
Have a look at how it's one in raft: https://github.com/NVIDIA/raft/blob/main/cpp/include/raft/linalg/detail/cublaslt_wrappers.hpp

I think, the best solution though would be to create a tiny PR in raft to add the corresponding wrapper/helper for the configuration you need and then use it here.

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.

Added raft PR for this: NVIDIA/raft#3106

Comment thread cpp/src/neighbors/detail/cagra/cagra_merge_scaffold.cuh
@landrumb
landrumb requested a review from a team as a code owner August 10, 2026 22:09
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.

5 participants