Skip to content

Expose Vamana build and serialize through cuvs-java - #2555

Open
shaunakkapur wants to merge 6 commits into
NVIDIA:mainfrom
shaunakkapur:feat/java-vamana-index
Open

shaunakkapur wants to merge 6 commits into
NVIDIA:mainfrom
shaunakkapur:feat/java-vamana-index

Conversation

@shaunakkapur

@shaunakkapur shaunakkapur commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Description

Adds a public cuvs-java API for building and serializing Vamana indexes using the generated Panama bindings that already exist.

The API follows the existing CAGRA provider pattern:

  • VamanaIndex exposes build, dimensions, and DiskANN serialization.
  • VamanaIndexParams exposes the native build parameters with Java-side validation.
  • VamanaIndexImpl owns the native handle and preserves the lifetime of a dataset view.
  • CuVSProvider, JDKProvider, and UnsupportedProvider expose the new builder.
  • The Vamana documentation gains Java examples.

serialize(Path filePrefix, boolean includeDataset) intentionally accepts a path prefix because the native call can write the graph at that prefix and the dataset at <prefix>.data.

The integration tests cover supported host and device datatypes, both native L2 metrics, dimensions, serialization layout, parameter validation, and resource ownership. This includes the float16 and device-backed paths added by the current native Vamana implementation.

Scope

This PR is build-and-serialize only. It does not add Vamana search, deserialization, sector_aligned, AiSAQ layout changes, or cuvs-lucene integration because those capabilities are not exposed by the current Vamana C API or belong to later work.

Testing

All 19 tests in VamanaBuildAndSerializeIT pass in CI on both CUDA 12.9 and 13.3, alongside the existing unit tests, the Lucene build, and the C++ matrix. The suite covers float32 and unsigned byte builds, float16 on a device-backed matrix, both serialization modes, the DiskANN file layout assertions, L2SqrtExpanded, parameter validation against the native RAFT_EXPECTS checks, dataset ownership, and lifecycle.

Also verified locally against a libcuvs.so built from current main:

  • mvn verify, 19 of 19 plus the existing unit tests
  • mvn spotless:check and ci/checks/run_spotless.sh, no rewrites
  • javadoc:javadoc with doclint all,-missing
  • cuvs-lucene test-compile against the installed jar

An earlier run failed in conda-cpp-build on a RAFT and ucxx mismatch in the build environment, in raft/comms/detail/std_comms.hpp. That was unrelated to this PR, which contains no C++ or CMake changes, and it has since been resolved upstream.

@copy-pr-bot

copy-pr-bot Bot commented Sep 4, 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.

@shaunakkapur
shaunakkapur force-pushed the feat/java-vamana-index branch from 40d7748 to b7ecf25 Compare September 4, 2026 19:33
@shaunakkapur shaunakkapur changed the title [WIP] Expose Vamana build and serialize through cuvs-java Expose Vamana build and serialize through cuvs-java Sep 4, 2026
@shaunakkapur
shaunakkapur marked this pull request as ready for review September 4, 2026 19:49
@shaunakkapur
shaunakkapur requested review from a team as code owners September 4, 2026 19:49
@shaunakkapur
shaunakkapur force-pushed the feat/java-vamana-index branch 2 times, most recently from f16b0f8 to b780b7f Compare September 10, 2026 19:04
Comment thread java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java Outdated
Comment thread fern/pages/java_api/index.md Outdated
cuVS provides a GPU Vamana builder and DiskANN-compatible serialization,
and the generated Panama bindings for it already exist in cuvs-java, but
there is no public API, so nothing can call Vamana from Java. This adds
VamanaIndex and VamanaIndexParams beside CagraIndex.

Scope is build and serialize only, matching the native surface. cuVS
exposes no Vamana search entry point, so neither does this.

serialize takes a Path prefix rather than an OutputStream, because one
native call writes two files, the graph at the prefix and the dataset at
prefix + ".data".

VamanaIndexParams.Builder mirrors the native RAFT_EXPECTS checks so an
invalid configuration fails in Java with a readable message instead of
inside a GPU kernel.

The native index may retain a non-owning device view of the dataset, so
the index holds a reference to keep it alive and closes it only when it
created the matrix from a float[][].

newVamanaIndexBuilder is added to CuVSProvider as a default method rather
than an abstract one so that providers written against an earlier version
of the interface keep compiling.

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

Resolve the generated Fern CuVSProvider API page by regenerating it from
the merged source rather than hand-picking either side.
The helper CuVSTestCase.isLinuxAmd64 was renamed to isLinuxSupportedArch
upstream, which also widened it to accept aarch64. Match the guard every
other IT in this package uses.
Widening the guard to isLinuxSupportedArch let these tests run on arm64 for
the first time, where cuvsVamanaBuild fails with an illegal memory access in
batched_insert_vamana. That poisons the CUDA context, so the following 81
tests in the same JVM errored as collateral. The defect is in native cuVS,
which this PR does not touch, so restrict the tests rather than paper over it
here.
Resolve fern/docs.yml by regenerating the navigation, so both the new
upstream Lucene API section and this branch's Vamana pages are present.
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.

2 participants