Skip to content
Closed
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1c0f648
Add PyLucene integration support
cjnolet May 13, 2026
e27a53b
Fix benchmark version marker
cjnolet May 19, 2026
3cab384
Fix PyLucene sidecar packaging and update cuVS version
nvzm123 Jul 8, 2026
6e3cf20
Merge remote-tracking branch 'upstream/main' into pr-147
nvzm123 Jul 8, 2026
7ec17fe
Expand PyLucene smoke coverage
nvzm123 Jul 16, 2026
5ade7af
Merge branch 'main' into pr-147
nvzm123 Jul 16, 2026
692c3db
Make writer telemetry on-demand
nvzm123 Jul 21, 2026
0e6bb43
Avoid duplicate binary format initialization
nvzm123 Jul 21, 2026
eeff876
Cache binary quantized vector formats
nvzm123 Jul 21, 2026
b76e2f5
Expose writer diagnostics through format descriptions
nvzm123 Jul 21, 2026
bf23e24
Use Lucene 102 binary vector formats
nvzm123 Jul 21, 2026
f7a8c66
Use the standard jar for PyLucene
nvzm123 Jul 21, 2026
7084157
Add a public PyLucene test entrypoint
nvzm123 Jul 21, 2026
d13184d
Move PyLucene tests under examples Python
nvzm123 Jul 21, 2026
df836cc
Clarify binary format version handling
nvzm123 Jul 21, 2026
e62a048
Expand PyLucene GPU end-to-end coverage
nvzm123 Jul 27, 2026
4ce56fa
Merge branch 'main' into pr-147
nvzm123 Jul 27, 2026
3221719
Refine PyLucene end-to-end coverage
nvzm123 Jul 27, 2026
9e164ad
Avoid leaking unused quantized flat writers
nvzm123 Jul 27, 2026
7d70d2f
Restore Lucene provider follow-up TODO
nvzm123 Jul 27, 2026
f0e14f4
Merge main and finalize PyLucene GPU tests
nvzm123 Aug 4, 2026
1ecc8bb
Reference multithreaded test follow-up
nvzm123 Aug 4, 2026
fda97b3
Refine PyLucene GPU end-to-end tests
nvzm123 Aug 14, 2026
6fe2c28
Align PyLucene integration with Lucene 10.2
nvzm123 Aug 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,100 @@ mvn clean compile package

The artifacts would be built and available in the target / folder.

### Using with PyLucene

PyLucene embeds a JVM and starts it with the classpath passed to `lucene.initVM(...)`.
Because PyLucene's generated Python module only exposes the Java classes it was built
to wrap, use Lucene's service provider lookup to load `cuvs-lucene` codecs from
Python instead of importing `com.nvidia.cuvs.lucene` classes directly.

Build the standard cuvs-lucene jar:

```sh
mvn clean package -DskipTests
```

Then start PyLucene with the base `cuvs-java` jar, the standard `cuvs-lucene`
jar, and PyLucene's own Lucene classpath:

```python
import os
from pathlib import Path

import lucene

cuvs_java_jar = Path(os.environ["CUVS_LUCENE_CUVS_JAVA_JAR"])
Comment thread
nvzm123 marked this conversation as resolved.
Outdated
cuvs_lucene_jar = next(
jar

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.

These steps still look overly complex for a user that just wants to use pylucene.

Boilerplate like this should ideally be provided in a Python library or scripts somewhere that can be easily included in their code. Ideally they should just have to import the codec and call codec.forCodec call.

Have you looked at other Pylucene extensions on GitHub to see their "usage" docs?

for jar in Path("target").glob("cuvs-lucene-*.jar")
if "-jar-with-" not in jar.name
and not jar.name.endswith(("-sources.jar", "-javadoc.jar"))
)
lucene.initVM(
classpath=os.pathsep.join(
[str(cuvs_java_jar), str(cuvs_lucene_jar), lucene.CLASSPATH]
),
vmargs=[
"--enable-native-access=ALL-UNNAMED",
"--add-modules=jdk.incubator.vector",
],
)

from org.apache.lucene.codecs import Codec

codec = Codec.forName("Lucene101AcceleratedHNSWCodec")
```

Use the returned `codec` with `IndexWriterConfig.setCodec(codec)`. The standard
artifact includes `cuvs-lucene` classes and service descriptors.
PyLucene must provide Lucene classes, and the base multi-release `cuvs-java` jar
must be present separately on the JVM classpath. Do not use a native classifier
`cuvs-java` jar here unless you also want to rely on its embedded native
libraries; the base jar uses native libraries from
`LD_LIBRARY_PATH`/`java.library.path`.

To run the PyLucene pytest smoke suite against a local PyLucene environment:

```sh
./test_pylucene.sh

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.

Please remove as stated above.

```

The script builds and validates the jar before invoking pytest. To invoke pytest
directly against existing artifacts instead:

```sh
CUVS_LUCENE_JAR=/path/to/cuvs-lucene.jar \
CUVS_LUCENE_CUVS_JAVA_JAR=/path/to/cuvs-java.jar \
python3 -m pytest -q -s examples/Python/test_pylucene_smoke.py
```

To run an expanded GPU end-to-end pytest suite through CPU HNSW,
CAGRA-to-HNSW, and CAGRA search paths:

```sh
./test_pylucene.sh --gpu-e2e
```

The expanded suite runs the `gpu-basic`, `gpu-segments`, `cpu-hnsw`, and

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.

Great description here. How to build and run tests should really be in a separate build and install guide. I think this is okay for now, especially since we are moving cuVS-Lucene to cuVS, but it's something to consider.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense

`cagra-hnsw` case groups. The basic cases cover `hnsw`, `cagra`, `hnsw-single`,
and `cagra-single`. The segment cases cover 1-segment indexes, 10-segment
indexes, 10 segments force-merged to 1, and 100 segments force-merged to 10 for
both HNSW and CAGRA. The CPU HNSW cases force the accelerated HNSW codec through
its Lucene CPU fallback path in the same run, including 10 segments force-merged
to 1 and 100 segments force-merged to 10. The CAGRA-to-HNSW cases explicitly
cover one-layer and three-layer HNSW graphs built from CAGRA with NN_DESCENT,
`graphDegree=32`, and `intermediateGraphDegree=64`. The base matrix uses 2,000
documents and 32 dimensions; high-segment cases use at least 257 rows per
segment to avoid expected cuVS graph-degree clamps on tiny per-segment datasets.
The suite checks Lucene SPI discovery, jar packaging, index file suffixes
(`.vex`/`.vem` for HNSW and `.vcag`/`.vemc` for CAGRA), indexed vector metadata,
unfiltered KNN, filtered KNN, missing-vector documents, deletions, and force
merge behavior. To run a subset or resize the test:

```sh
./test_pylucene.sh --gpu-e2e --cases=gpu-segments --rows=5000 --dims=64 --topk=20
```

### Running Tests

```sh
Expand Down
9 changes: 9 additions & 0 deletions ci/test_pylucene_smoke.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail

REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
exec "${REPO_ROOT}/test_pylucene.sh" "$@"
Loading