Skip to content

Migrate brute-force k-NN benchmark to NVBench - #2371

Draft
PointKernel wants to merge 2 commits into
NVIDIA:mainfrom
PointKernel:agent/migrate-brute-force-knn-to-nvbench
Draft

Migrate brute-force k-NN benchmark to NVBench#2371
PointKernel wants to merge 2 commits into
NVIDIA:mainfrom
PointKernel:agent/migrate-brute-force-knn-to-nvbench

Conversation

@PointKernel

@PointKernel PointKernel commented Jul 28, 2026

Copy link
Copy Markdown
Member

This PR migrates the standalone brute-force k-NN benchmark from generic Google Benchmark target plumbing and one-shot host wall-clock timing to NVBench. It follows the cuDF setup by fetching static NVBench through rapids-cmake, using a shared NVBench main, and registering typed and value axes.

NVBench provides CUDA-event timing, automatic warmup and repeated measurements with noise-based stopping, typed and value axes, and element-throughput reporting for this device-only search. Input allocation, data initialization, and index construction remain outside the timed region.

The benchmark audit found that focused single-GPU search companions for cuVS brute force, IVF-Flat, IVF-PQ, IVF-SQ, IVF-RaBitQ, and CAGRA are appropriate NVBench candidates. GGNN may also qualify once its search measurement boundary is isolated. Build workflows and the end-to-end ANN benchmarks should remain on Google Benchmark, including CPU HNSW/FAISS/DiskANN, FAISS GPU comparisons, multi-GPU, and hybrid CAGRA workflows, because they rely on JSON configuration, persisted indexes, recall, threaded QPS and latency, NVTX-derived counters, and the existing cuvs_bench Google Benchmark JSON parser.

@copy-pr-bot

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

@cjnolet

cjnolet commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Hi @PointKernel. What's the justification for this change? Are you working on improving brute force knn?

Not a great idea to cherry pick algorithms from cuVS bench outside of the existing infra, especially not to yet another benchmark harness. If we are going to make such a change, we should do so for all the supported algorithms.

Of course, if this is just for your own internal testing then please feel free to disregard. Opening up a PR tells me you probably want this merged, and in that case, we need to have a much larger discussion about this.

@PointKernel

Copy link
Copy Markdown
Member Author

@cjnolet Thanks for raising your concern. I am not specifically working on brute force kNN. I noticed this benchmark was already doing its own GPU timing and synchronization, so it seemed like a simple place to show what NVBench could provide.

We migrated all the cuDF GPU benchmarks to NVBench and have found it useful for kernel benchmarks. It takes care of timing, synchronization, warmups, repetitions, and parameter handling that would otherwise need to be implemented manually. Since this benchmark already contains much of that boilerplate, it felt like a good contained example for comparing the two approaches.

I agree this should not become a one off in cuVS. I opened the PR so we could discuss the idea around a concrete example rather than an abstract proposal. If cuVS finds this direction useful, this could be the starting point for a broader and more consistent effort across the appropriate GPU benchmarks.

@cjnolet

cjnolet commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Okay that does makes sense. Thank you for the explanation!

@GregoryKimball

Copy link
Copy Markdown

Thank you @cjnolet for checking out this diff and thank you @PointKernel for putting it together.

cuDF benchmarks were originally written in googlebench. We started migrating to nvbench in 2021 and just finished in 2025, so there is no need to rush adoption all at once. NVbench is the standard for CCCL and a great tool to make GPU benchmarking easier. My favorite feature is that benchmark parameters can be varied at runtime without recompiling anything. I asked @PointKernel to open the PR to start the conversation with cuVS about nvbench.

@cjnolet

cjnolet commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Thanks guys.

I should probably point out, though, that we are getting close to marking our c++ backend as legacy as we move more towards benchmarking the Python backend in cuVS-bench.

It's not formal yet, because we are still in the process of adopting and fleshing out the new python backend, but that is the ultimate goal.

Does nvbench support any type of Python layer?

@PointKernel

Copy link
Copy Markdown
Member Author

Does nvbench support any type of Python layer?

Yes, I believe so. @oleksandr-pavlyk could probably comment more on this.

@oleksandr-pavlyk

oleksandr-pavlyk commented Jul 29, 2026

Copy link
Copy Markdown

Does nvbench support any type of Python layer?

Yes, I believe so. @oleksandr-pavlyk could probably comment more on this.

There is no restriction on types to use in the benchmark. You can peruse Python examples of benchmarking at the repo: https://github.com/NVIDIA/nvbench/tree/main/python/examples

They include benchmarking of numba-cuda kernels, torch operators, cupy functions, cute-dsl operations, and kernels compiled from source using cuda-core.

Benchmarking in Python currently expects that work is submitted on the stream supplied in cuda.bench.Launch object.

Unlike C++, Python does not currently allow for cuda.bench.State to set external stream to use.

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.

4 participants