Skip to content

Fuse RaBitQ block reductions into one templated blockReduceSumN<N>#2362

Open
Stardust-SJF wants to merge 2 commits into
NVIDIA:mainfrom
Stardust-SJF:cuvs_ivf_rabitq_syn_fix_fused
Open

Fuse RaBitQ block reductions into one templated blockReduceSumN<N>#2362
Stardust-SJF wants to merge 2 commits into
NVIDIA:mainfrom
Stardust-SJF:cuvs_ivf_rabitq_syn_fix_fused

Conversation

@Stardust-SJF

@Stardust-SJF Stardust-SJF commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Thanks @hhy3 for finding and fixing the bug! This PR removes the barrier between block reductions by replacing the per-value blockReduceSum (and PR #2322's helper-internal barrier) with a fused blockReduceSumN<N> that reduces all N factor components in a single pass over a shared[N][32] memory space. Each reduction group is now one call, the space is never reused back-to-back, so the shared-memory reuse race is removed. Also, it fixes another potential shared-memory race in the compute_best_rescale_parallel function.

By the way, it will also slightly improve the performance for the quantization process.

Replace the per-value blockReduceSum (and PR NVIDIA#2322's helper-internal barrier)
with a fused blockReduceSumN<N> that reduces all N factor components in a single
pass over a shared[N][32] memory space. Each reduction group is now
one call, the space is never reused back-to-back, so the shared-memory reuse
race is removed.

blockReduceSum(val) is kept as a thin N=1 alias, so the standalone reductions are
unchanged and route through the same family. Distinct N are distinct template
instantiations with their own space, so a standalone N=1 reduction never
aliases the N=4/N=2 cluster used in the same kernel.
@copy-pr-bot

copy-pr-bot Bot commented Jul 24, 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.

compute_best_rescale_parallel had four potential data races that the fused blockReduceSumN commit could not address. This commit fixes that.
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.

1 participant