Add PyLucene backend for cuVS-Lucene vector search in cuvs-bench - #2385
Draft
nvzm123 wants to merge 5 commits into
Draft
Add PyLucene backend for cuVS-Lucene vector search in cuvs-bench#2385nvzm123 wants to merge 5 commits into
nvzm123 wants to merge 5 commits into
Conversation
Dataset preparation imports h5py at runtime. Declare it in both the dependency manifest and project metadata so supported environments install it consistently.
Add opt-in atomic JSON persistence for Python-native backends, preserve canonical result fields, and keep derived CSV artifacts synchronized. Propagate sweep failures through the CLI and cover result identity, export, and cleanup behavior.
Register a local PyLucene backend for cuVS-Lucene HNSW and CAGRA codecs. Add deterministic config selection, lazy JVM and codec resolution, GPU writer validation, safe index lifecycle handling, commit-bound provenance, CAGRA integrity checks, and focused unit coverage.
Exercise real JVM and cuVS-Lucene HNSW and CAGRA build/search paths behind an opt-in pytest marker. Cover persisted GPU formats, index reuse, CLI execution, fallback rejection, and integrity failures.
Document the verified dependency build, runtime configuration, supported codecs and limits, manual smoke workflow, index reuse behavior, and benchmark result semantics.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a built-in
pylucenebackend to cuVS Bench for building and searching local Lucene vector indexes with cuVS-Lucene codecs through PyLucene.The backend supports the three cuVS-accelerated HNSW codecs and the CAGRA build/search codec proposed in NVIDIA/cuvs-lucene#174. It follows cuVS Bench's registered backend/config-loader architecture and writes benchmark artifacts compatible with the existing JSON-to-CSV reporting workflow.
Backend behavior
pyluceneas a built-in benchmark backend and configuration loader.pylucene_cuvs_hnsw:Lucene101AcceleratedHNSWCodec,Lucene101AcceleratedHNSWBaseLayerCodec, andLucene101AcceleratedHNSWMultiLayerCodecpylucene_cuvs_cagra:CuVS2510GPUSearchCodeccuvs-javaand thincuvs-luceneJARs, then resolves codecs through Lucene SPI.IndexWriterand searches through the publicKnnFloatVectorQueryAPI.HNSW configurations use GPU graph construction followed by Lucene HNSW search. The CAGRA configuration uses GPU build and CAGRA search. New builds inspect cuVS-Lucene writer diagnostics and fail instead of silently accepting a CPU or alternate-index fallback.
Index integrity and reuse
The backend writes commit-bound provenance manifests for HNSW and CAGRA indexes. Reuse and search validate the requested codec, dataset shape, Lucene commit fingerprints, and persisted writer path before accepting an existing index.
CAGRA indexes receive additional structural validation through Lucene's codec APIs, including segment and field metadata, vector counts and dimensions, data-file coverage, codec headers and footers, and checksums. Missing, stale, truncated, corrupted, brute-force-fallback, or deletion-bearing CAGRA indexes are rejected before search.
Partial indexes are removed after failed new builds. Existing indexes are preserved when codec preflight fails before replacement.
Benchmark result integration
This PR adds opt-in orchestrator persistence for backends that return in-process results. PyLucene build and search results are written as Google Benchmark-compatible JSON and exported through the existing CSV/frontier pipeline.
The shared result handling:
Existing backends do not opt into this persistence path and retain their current result-file behavior.
Supported inputs and current limits
The backend currently supports:
--batch-size;k <= 1024.cuVS-Lucene's public Lucene query API does not currently expose backend-specific search parameters. PyLucene's JVM is process-global, so JAR paths, native-library paths, and JVM arguments must be fixed before the first PyLucene run in a process.
Dependencies and documentation
PyLucene is intentionally not installed by cuVS Bench; it must be built from source for the selected Lucene API version. The runtime also requires JDK 22, matching cuVS native libraries, the base
cuvs-javaJAR, and the standard thincuvs-luceneJAR. Fat cuVS-Lucene JARs are rejected because PyLucene supplies Lucene's classes.The cuVS Bench dependency manifest now declares
h5py, which is used by the existing dataset-preparation commands.The installation and usage guides document dependency builds, runtime configuration, supported codecs and limits, result semantics, and a complete command-line smoke workflow.
Compatibility remains provisional while NVIDIA/cuvs-lucene#174 is under review. The validated source pair is cuVS
a59e2445with cuVS-Lucene7d70d2f; that cuVS-Lucene revision does not compile against current cuVSmainatf72199e3. The documentation pins the compatible revisions to avoid accidentally combining a moving PR head with mismatched native artifacts. The validated PyLucene version is 10.0.0; cuVS-Lucene currently compiles against Lucene 10.2.0, so the exact combination must be validated until compatible artifacts are released.Test coverage
The pytest coverage includes:
The live integration cases verify writer telemetry and persisted formats, index reuse, expected self matches, finite ordered distances, recall of at least 0.75, CAGRA integrity failures, and rejection of cuVS-Lucene's real one-vector brute-force fallback.
Validation
pylucene.py./test_pylucene.sh --no-build --full-e2e: 22 passedRelated work