Add PyLucene backend for cuVS-Lucene vector search in cuvs-bench - #2385
Draft
nvzm123 wants to merge 10 commits into
Draft
Add PyLucene backend for cuVS-Lucene vector search in cuvs-bench#2385nvzm123 wants to merge 10 commits into
nvzm123 wants to merge 10 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.
…ark-backend Signed-off-by: nvzm123 <zmeeks@nvidia.com> # Conflicts: # python/cuvs_bench/cuvs_bench/orchestrator/orchestrator.py # python/cuvs_bench/cuvs_bench/run/__main__.py # python/cuvs_bench/cuvs_bench/run/data_export.py # python/cuvs_bench/cuvs_bench/tests/test_data_export.py
Use the shared direct CSV exporter for in-process backends and remove the redundant JSON persistence layer. Preserve scoped result identities, latency percentiles, safe artifact paths, stale-result cleanup, and accurate CLI exit behavior. Signed-off-by: nvzm123 <zmeeks@nvidia.com>
Target the production HNSW and CAGRA codecs exposed by the current cuVS-Lucene PR. Preserve the intentional HNSW CPU fallback, keep fail-closed CAGRA integrity checks, and verify actual HNSW writer selection through a downstream test-only codec adapter. Signed-off-by: nvzm123 <zmeeks@nvidia.com>
Document the current JDK, PyLucene, cuVS Java, and cuVS-Lucene requirements. Describe the two supported production codecs, HNSW fallback behavior, CAGRA validation contract, and the current manual validation workflow. Signed-off-by: nvzm123 <zmeeks@nvidia.com>
Signed-off-by: nvzm123 <zmeeks@nvidia.com>
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 through PyLucene and the production codecs proposed in NVIDIA/cuvs-lucene#174.The implementation targets the current PR #174 API at
fda97b3d:Lucene101AcceleratedHNSWCodecfor cuVS-assisted HNSW construction with Lucene HNSW search, andCuVS2510GPUSearchCodecfor CAGRA construction and search. It follows cuVS Bench's backend/config-loader architecture and the current in-process result-export contract.Backend behavior
pyluceneas a built-in backend and configuration loader, with packagedpylucene_cuvs_hnswandpylucene_cuvs_cagraconfigurations.cuvs-javaand thincuvs-luceneJARs, validates classpath inputs, configures the native-library search path, and resolves production codecs through Lucene SPI.IndexWriterand searches through the publicKnnFloatVectorQueryAPI.BuildResultandList[SearchResult]models, including throughput, per-batch latency, percentiles, recall inputs, and backend metadata.The HNSW codec uses its production contract: it selects the cuVS writer when GPU support is available and intentionally falls back, with cuVS-Lucene's warning, to Lucene's CPU HNSW writer otherwise. The CAGRA codec requires GPU support and is validated fail-closed before its results are accepted.
Index integrity and lifecycle
The backend writes atomic, commit-bound provenance manifests for HNSW and CAGRA indexes. Reuse and search validate the codec, writer policy, expected dataset shape, and Lucene commit fingerprint before accepting an existing index.
CAGRA indexes receive additional structural and checksum validation through Lucene's codec APIs, including segment/field metadata, vector counts and dimensions, data-file coverage, codec headers and footers, deletions, and checksums. Missing, stale, truncated, corrupted, brute-force-fallback, or non-CAGRA vector segments are rejected before search.
Index paths and result identities are validated and contained beneath their configured roots. Failed new builds remove partial output without deleting unrelated or caller-untrusted paths, while preflight failures preserve existing indexes.
Result and CLI integration
The backend uses cuVS Bench's current direct CSV exporter for in-process results. The shared result handling added here:
Supported inputs and current limits
--batch-sizek <= 1024The public Lucene query API does not expose backend-specific search tuning 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 remains an external, source-built dependency. The documented environment uses JDK 22, PyLucene/Lucene 10.2.0, matching cuVS 26.10 native libraries and
cuvs-java, and the standard thin cuVS-Lucene JAR. Fat cuVS-Lucene JARs are rejected because PyLucene supplies Lucene's classes.The installation and usage guides cover dependency builds, artifact validation, runtime configuration, the HNSW fallback and CAGRA contracts, supported limits, index reuse, result semantics, and a complete manual smoke workflow. The dependency manifest also declares
h5py, which the existing dataset-preparation commands import at runtime.Compatibility remains provisional while PR #174 is under review. The live validation used its exact current head
fda97b3d, PyLucene 10.2.0, and matching cuVS 26.10.0 native/Java artifacts.Test coverage
The pytest suites cover registration and configuration, lazy imports, JVM/classpath/native validation, thin-JAR enforcement, SPI resolution, build/reuse/rebuild/cleanup behavior, query conversion and batching, result metrics, provenance mismatches, path containment, CAGRA segment traversal and corruption cases, direct CSV export, and CLI failure propagation.
The opt-in integration suite uses a downstream test-only Java codec adapter that delegates to the real production HNSW codec and wraps only
fieldsWriter()diagnostics. Stock PyLucene instantiates it throughClass.forName(...).newInstance(), allowing the test to prove the concrete writer selected without adding production APIs or SPI names to cuVS-Lucene. Live cases exercise both production codecs, real JVM/GPU build and search, index reuse, recall/distance checks, CAGRA fallback rejection, integrity failures, and a fresh-process CLI workflow.Validation
python -m pytest -q cuvs_bench/tests: 408 passed, 31 skippedpylucene.pyfern/build_docs.sh check: 248 MDX files valid, 0 errors (2 pre-existing warnings)Related work