Skip to content

Improvements on NND kernels: u8 MMA and warp guard - #2751

Merged
rapids-bot[bot] merged 9 commits into
NVIDIA:mainfrom
sherylll:update-nnd-bbq
Oct 12, 2026
Merged

rapids-bot[bot] merged 9 commits into
NVIDIA:mainfrom
sherylll:update-nnd-bbq

Conversation

@sherylll

@sherylll sherylll commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor
  • Replace u4 MMA with u8 MMA for better compatibility. Perf is not negatively affected because the kernel is latency bound.
  • In MMA kernels, add warp guard on MMA instructions against elements past the useful range (new_size/old_size)
  • Make DEGREE_ON_DEVICE compile-time constant
  • Small fixes on data types and loop bounds

@copy-pr-bot

copy-pr-bot Bot commented Oct 6, 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.

Skip warps whose output block is out of range;
Remove redundant syncthreads in local_join_kernel_wmma
Simplify BBQ staging function
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/cuvs/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 37a0878c-f438-41d2-8f80-a1a5a362bad1

📥 Commits

Reviewing files that changed from the base of the PR and between a322a5a and ccabb5c.


📒 Files selected for processing (2)
  • cpp/src/neighbors/detail/nn_descent.cuh
  • cpp/src/neighbors/detail/nn_descent_gnnd.hpp

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.



📝 Summary

Summary by CodeRabbit

  • Performance
    • Improved accelerated neighbor search by skipping unnecessary calculations for inactive regions while preserving required synchronization.
    • Reduced processing when neighbor lists are only partially filled.
    • Optimized dense and BBQ join searches, including searches that use packed 4-bit values, for more efficient neighbor discovery.

Walkthrough

NN-descent graph insertion now uses a fixed device-side degree. Dense WMMA joins skip inactive tiles. BBQ kernels derive self-join behavior from layouts, bound list processing by actual sizes, and use byte-fragment MMA for packed low- and high-nibble computation.

Changes

NN-descent kernels

Layer / File(s) Summary
Fixed device-side graph degree
cpp/src/neighbors/detail/nn_descent.cuh, cpp/src/neighbors/detail/nn_descent_gnnd.hpp
Graph insertion uses DEGREE_ON_DEVICE instead of a passed graph width. Dense kernel declarations and launches drop the graph-width argument. The prior degree and segment constants are removed from nn_descent_gnnd.hpp.
Dense WMMA inactive-tile checks
cpp/src/neighbors/detail/nn_descent.cuh
Dense WMMA joins skip MMA operations and result stores for inactive tiles. Block-wide synchronization remains outside the conditional work.
BBQ SIMT layout and list processing
cpp/src/neighbors/detail/nn_descent.cuh
The BBQ SIMT kernel derives self-join behavior from document and query layouts. Cross-list scans use actual list sizes, and dispatch no longer passes a self-join tag.
BBQ packed-nibble WMMA
cpp/src/neighbors/detail/nn_descent.cuh
The BBQ WMMA kernel stages promoted tiles across block threads and uses 16×16×16 byte fragments to compute packed low and high nibbles. It skips inactive-warp MMA and stores, retains cooperative barriers, and bounds list scans by actual sizes.

Priority: ⬇️ Low

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Suggested reviewers: cjnolet


Merge Risk: ⚪ Minimal · up to ccabb

No actionable merge-blocking issue was established in the reviewed changes.

Pre-merge checks | Passed 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check Passed The title clearly identifies the main kernel improvements: u8 MMA support and warp guards.
Description check Passed The description directly covers the changes to MMA instructions, warp guards, device degree configuration, data types, and loop bounds.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

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

@lowener lowener added improvement Improves an existing functionality non-breaking Introduces a non-breaking change C++ labels Oct 8, 2026
@lowener

lowener commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

/ok to test 3a2cf55

@sherylll

sherylll commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 28c16b9

@achirkin

achirkin commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

/ok to test 28c16b9

@sherylll

sherylll commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 2871cbf

@sherylll sherylll changed the title Small optimizations to local_join kernels Improvements on NND kernels: Oct 9, 2026
@sherylll sherylll changed the title Improvements on NND kernels: Improvements on NND kernels: u8 MMA and warp guard Oct 9, 2026
@aamijar

aamijar commented Oct 12, 2026

Copy link
Copy Markdown
Member

/merge

@rapids-bot
rapids-bot Bot merged commit 6ecd8ce into NVIDIA:main Oct 12, 2026
230 of 232 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in Unstructured Data Processing Oct 12, 2026
maxwbuckley added a commit to maxwbuckley/cuvs that referenced this pull request Oct 13, 2026
NVIDIA#2751 reworked local_join_kernel_wmma (per-k-step barrier moved out of the
k loop, per-warp guards). Take main's version of nn_descent.cuh here; the
fused join is redone on top of it in the next commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
maxwbuckley added a commit to maxwbuckley/cuvs that referenced this pull request Oct 13, 2026
…MA loops

Rework of the fused local join after main gained NVIDIA#2751 (per-warp MMA
guards, per-k-step barrier already moved out of the k loop), following
review:

- One pass over the features: each tile step gathers the new rows and
  the old rows, so phase 2 no longer re-gathers every new-vector tile.
- The new x new and new x old products are two MMA loops per tile, each
  behind its own NVIDIA#2751 warp guard, instead of a per-accumulator branch
  inside a single loop. The branchy loop compiled to 15 branches and
  ~2.6x the instructions per k loop, and was slower than main for fp32
  input; the split loops are straight-line and reload a_frag instead.
- The new/old tiles and the distance block share one shared-memory
  arena (their lifetimes never overlap), and s_unique_counter gets its
  own slot, so the extra barrier the aliasing needed is gone.

Output is byte-identical to main (kernel harness, 42 cases, 0
mismatched pairs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C++ improvement Improves an existing functionality non-breaking Introduces a non-breaking change

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants