Skip to content

[WIP] Expose SOAR as a public cluster API - #2540

Open
ronjer30 wants to merge 2 commits into
NVIDIA:mainfrom
ronjer30:feat/cluster-soar-cpp-api
Open

[WIP] Expose SOAR as a public cluster API#2540
ronjer30 wants to merge 2 commits into
NVIDIA:mainfrom
ronjer30:feat/cluster-soar-cpp-api

Conversation

@ronjer30

@ronjer30 ronjer30 commented Sep 1, 2026

Copy link
Copy Markdown

Description

  • Relocate the shared SOAR implementation to cluster::soar::detail, expose it through the public soar::predict wrapper, and update ScaNN to use the relocated internal implementation.
  • Add unit coverage for reference results, residual computation, boundary behavior, and invalid shapes.
  • Add API documentation and a standalone C++ example using balanced k-means primary assignments.

Testing

  • Built the cuVS library successfully.
  • Built and ran SOAR_EXAMPLE.
  • Added parameterized GPU tests comparing SOAR results against host reference.
  • SCANN_EXAMPLE index build time on NVIDIA GB10, 10 runs after warm-up: 412.3 ± 4.0 ms before and 410.8 ± 6.0 ms after; no measurable regression.

SOAR (Spilling with Orthogonality-Amplified Residuals,
https://arxiv.org/abs/2404.00774) gives each vector a second centroid chosen to
complement its primary assignment rather than to be merely the next closest.
Indexing a vector under both partitions improves recall for queries near a
partition boundary. The implementation lived in
`neighbors/scann/detail/scann_soar.cuh` and was reachable only by building a
ScaNN index, even though the algorithm needs nothing beyond centroids and
primary k-means labels.

Promotes it to a cluster-level API. `cuvs::cluster::soar::predict` takes a
dataset, centroids, and primary labels, and writes one secondary label per row.
`soar::params` exposes the `lambda` weight controlling how strongly a candidate
centroid is penalized for having a residual aligned with the primary one.

Moves `scann_soar.cuh` to `cluster/detail/soar.cuh` and points the ScaNN builder
at the relocated entry point so there is a single implementation.
`compute_soar_labels` now takes its centroids as a const view. The detail header
also gains `compute_residuals`, which the public API needs to derive residuals
from labels; the ScaNN builder already holds residuals for quantization and
keeps supplying its own, so it does not pay for a second pass over the dataset.

Adds `cpp/tests/cluster/soar.cu` to `CLUSTER_TEST`, covering assignments against
an exhaustive host search, the residual computation against a host reference, a
hand-checked separated-cluster case, and the shape-validation errors. Adds a C++
API documentation page.

Signed-off-by: Ranjit Rajan <ranjitr@nvidia.com>
`SOAR_EXAMPLE` shows the call sequence a caller needs: balanced k-means for the
centroids and primary labels, then `soar::predict` to fill one secondary label
per row.

Signed-off-by: Ranjit Rajan <ranjitr@nvidia.com>
@ronjer30
ronjer30 requested review from a team as code owners September 1, 2026 18:59
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