-
Notifications
You must be signed in to change notification settings - Fork 22
Add PyLucene integration and CPU/GPU end-to-end tests #174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nvzm123
wants to merge
20
commits into
NVIDIA:main
Choose a base branch
from
nvzm123:pr-147
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
1c0f648
Add PyLucene integration support
cjnolet e27a53b
Fix benchmark version marker
cjnolet 3cab384
Fix PyLucene sidecar packaging and update cuVS version
nvzm123 6e3cf20
Merge remote-tracking branch 'upstream/main' into pr-147
nvzm123 7ec17fe
Expand PyLucene smoke coverage
nvzm123 5ade7af
Merge branch 'main' into pr-147
nvzm123 692c3db
Make writer telemetry on-demand
nvzm123 0e6bb43
Avoid duplicate binary format initialization
nvzm123 eeff876
Cache binary quantized vector formats
nvzm123 b76e2f5
Expose writer diagnostics through format descriptions
nvzm123 bf23e24
Use Lucene 102 binary vector formats
nvzm123 f7a8c66
Use the standard jar for PyLucene
nvzm123 7084157
Add a public PyLucene test entrypoint
nvzm123 d13184d
Move PyLucene tests under examples Python
nvzm123 df836cc
Clarify binary format version handling
nvzm123 e62a048
Expand PyLucene GPU end-to-end coverage
nvzm123 4ce56fa
Merge branch 'main' into pr-147
nvzm123 3221719
Refine PyLucene end-to-end coverage
nvzm123 9e164ad
Avoid leaking unused quantized flat writers
nvzm123 7d70d2f
Restore Lucene provider follow-up TODO
nvzm123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,3 +7,5 @@ target | |
| bin | ||
| .project | ||
| cuvs-workdir | ||
| __pycache__/ | ||
| .pytest_cache/ | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,232 @@ | ||
| #!/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)" | ||
| cd "${REPO_ROOT}" | ||
|
|
||
| MVN_BIN="${MVN:-mvn}" | ||
| PYTHON_BIN="${PYTHON:-python3}" | ||
| SKIP_BUILD=0 | ||
| FULL_END_TO_END=0 | ||
| PYLUCENE_CASES="${CUVS_LUCENE_PYLUCENE_CASES:-}" | ||
| PYLUCENE_ROWS="${CUVS_LUCENE_PYLUCENE_ROWS:-}" | ||
| PYLUCENE_DIMS="${CUVS_LUCENE_PYLUCENE_DIMS:-}" | ||
| PYLUCENE_TOPK="${CUVS_LUCENE_PYLUCENE_TOPK:-}" | ||
| PYLUCENE_MIN_RECALL="${CUVS_LUCENE_PYLUCENE_MIN_RECALL:-}" | ||
| CUVS_LUCENE_JAR_PATH="${CUVS_LUCENE_JAR:-}" | ||
| PYLUCENE_TEST_CLASSES_PATH="${CUVS_LUCENE_PYLUCENE_TEST_CLASSES:-target/test-classes}" | ||
| PYTEST_ARGS=() | ||
|
|
||
| while [[ "$#" -gt 0 ]]; do | ||
| arg="$1" | ||
| shift | ||
| case "${arg}" in | ||
| --full-e2e|--gpu-e2e) | ||
| FULL_END_TO_END=1 | ||
| ;; | ||
| --no-build) | ||
| SKIP_BUILD=1 | ||
| ;; | ||
| --cases=*) | ||
| PYLUCENE_CASES="${arg#--cases=}" | ||
| ;; | ||
| --rows=*) | ||
| PYLUCENE_ROWS="${arg#--rows=}" | ||
| ;; | ||
| --dims=*) | ||
| PYLUCENE_DIMS="${arg#--dims=}" | ||
| ;; | ||
| --topk=*) | ||
| PYLUCENE_TOPK="${arg#--topk=}" | ||
| ;; | ||
| --min-recall=*) | ||
| PYLUCENE_MIN_RECALL="${arg#--min-recall=}" | ||
| ;; | ||
| --) | ||
| PYTEST_ARGS+=("$@") | ||
| break | ||
| ;; | ||
| -h|--help) | ||
| echo "Usage: ./test_pylucene.sh [OPTIONS] [-- PYTEST_ARGS...]" | ||
| echo | ||
| echo "Prepares the PyLucene JVM, jar, classpath, and native-library inputs, then runs pytest." | ||
| echo | ||
| echo "Options:" | ||
| echo " --no-build Use existing Maven artifacts." | ||
| echo " --full-e2e Run the complete CPU/GPU end-to-end suite." | ||
| echo " --cases=CASE[,CASE...] Select case names or groups." | ||
| echo " --rows=N Set the minimum document count per scenario." | ||
| echo " --dims=N Set vector dimensions." | ||
| echo " --topk=N Set requested neighbor count." | ||
| echo " --min-recall=FLOAT Set the brute-force recall floor (default: 0.75)." | ||
| echo " -- PYTEST_ARGS Forward remaining arguments to pytest." | ||
| echo | ||
| echo "Execution-path groups:" | ||
| echo " cpu-hnsw, gpu-cagra-built-hnsw, gpu-cagra-search, gpu" | ||
| echo | ||
| echo "Behavior groups:" | ||
| echo " execution-paths, segment-topologies, force-merges," | ||
| echo " hnsw-layer-counts, cagra-search-widths," | ||
| echo " deleted-documents, document-filter, all" | ||
| echo | ||
| echo "Environment overrides:" | ||
| echo " CUVS_LUCENE_JAR, CUVS_LUCENE_CUVS_JAVA_JAR," | ||
| echo " CUVS_LUCENE_PYLUCENE_TEST_CLASSES," | ||
| echo " CUVS_LUCENE_PYLUCENE_CASES, CUVS_LUCENE_PYLUCENE_ROWS," | ||
| echo " CUVS_LUCENE_PYLUCENE_DIMS, CUVS_LUCENE_PYLUCENE_TOPK," | ||
| echo " CUVS_LUCENE_PYLUCENE_MIN_RECALL, PYTHON, MVN" | ||
| exit 0 | ||
| ;; | ||
| *) | ||
| echo "Unknown argument: ${arg}" >&2 | ||
| echo "Use -- before arguments intended for pytest." >&2 | ||
| exit 2 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| require_command() { | ||
| if ! command -v "$1" >/dev/null 2>&1; then | ||
| echo "Required command not found: $1" >&2 | ||
| exit 127 | ||
| fi | ||
| } | ||
|
|
||
| absolute_from_repo_root() { | ||
| case "$1" in | ||
| /*) | ||
| printf '%s\n' "$1" | ||
| ;; | ||
| *) | ||
| printf '%s/%s\n' "${REPO_ROOT}" "$1" | ||
| ;; | ||
| esac | ||
| } | ||
|
|
||
| find_cuvs_java_jar() { | ||
| if [[ -n "${CUVS_LUCENE_CUVS_JAVA_JAR:-}" ]]; then | ||
| printf '%s\n' "${CUVS_LUCENE_CUVS_JAVA_JAR}" | ||
| return | ||
| fi | ||
|
|
||
| local versioned_jar="${HOME}/.m2/repository/com/nvidia/cuvs/cuvs-java/${project_version}/cuvs-java-${project_version}.jar" | ||
| if [[ -f "${versioned_jar}" ]]; then | ||
| printf '%s\n' "${versioned_jar}" | ||
| return | ||
| fi | ||
|
|
||
| local m2_repo="${HOME}/.m2/repository/com/nvidia/cuvs/cuvs-java" | ||
| if [[ ! -d "${m2_repo}" ]]; then | ||
| return | ||
| fi | ||
|
|
||
| find "${m2_repo}" \ | ||
| -type f \ | ||
| -name 'cuvs-java-*.jar' \ | ||
| ! -name '*sources*' \ | ||
| ! -name '*javadoc*' \ | ||
| ! -name '*x86_64*' \ | ||
| | sort -V \ | ||
| | tail -n 1 | ||
| } | ||
|
|
||
| require_command "${PYTHON_BIN}" | ||
|
|
||
| if [[ "${SKIP_BUILD}" -eq 0 && -z "${CUVS_LUCENE_JAR_PATH}" ]]; then | ||
| require_command "${MVN_BIN}" | ||
| "${MVN_BIN}" clean package -DskipTests | ||
| fi | ||
|
|
||
| project_version="$( | ||
| sed -n 's/.*CUVS_LUCENE#VERSION_UPDATE_MARKER_START--><version>\([^<]*\)<\/version>.*/\1/p' pom.xml \ | ||
| | head -n 1 | ||
| )" | ||
| if [[ -z "${project_version}" ]]; then | ||
| echo "Unable to determine project version from pom.xml" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ -n "${CUVS_LUCENE_JAR_PATH}" ]]; then | ||
| cuvs_lucene_jar="${CUVS_LUCENE_JAR_PATH}" | ||
| else | ||
| cuvs_lucene_jar="target/cuvs-lucene-${project_version}.jar" | ||
| fi | ||
| cuvs_lucene_jar_abs="$(absolute_from_repo_root "${cuvs_lucene_jar}")" | ||
| if [[ ! -f "${cuvs_lucene_jar_abs}" ]]; then | ||
| echo "cuvs-lucene jar not found: ${cuvs_lucene_jar_abs}" >&2 | ||
| echo "Run without --no-build, or set CUVS_LUCENE_JAR." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| cuvs_java_jar="$(find_cuvs_java_jar)" | ||
| if [[ -z "${cuvs_java_jar}" || ! -f "${cuvs_java_jar}" ]]; then | ||
| echo "Base cuvs-java jar not found." >&2 | ||
| echo "Set CUVS_LUCENE_CUVS_JAVA_JAR to the base jar, not a native classifier jar." >&2 | ||
| exit 1 | ||
| fi | ||
| cuvs_java_jar_abs="$(absolute_from_repo_root "${cuvs_java_jar}")" | ||
|
|
||
| pylucene_test_classes_abs="$( | ||
| absolute_from_repo_root "${PYLUCENE_TEST_CLASSES_PATH}" | ||
| )" | ||
| if [[ ! -d "${pylucene_test_classes_abs}" ]]; then | ||
| echo "PyLucene test classes not found: ${pylucene_test_classes_abs}" >&2 | ||
| echo "Run Maven test compilation, or set CUVS_LUCENE_PYLUCENE_TEST_CLASSES." >&2 | ||
| exit 1 | ||
| fi | ||
| pylucene_test_classes_abs="$( | ||
| cd "${pylucene_test_classes_abs}" && pwd -P | ||
| )" | ||
|
|
||
| "${PYTHON_BIN}" -c "import lucene" >/dev/null 2>&1 || { | ||
| echo "Python cannot import PyLucene's lucene module." >&2 | ||
| echo "Activate a PyLucene environment compatible with this project's Lucene version." >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| "${PYTHON_BIN}" -m pytest --version >/dev/null 2>&1 || { | ||
| echo "Python cannot run pytest. Install pytest in the active PyLucene environment." >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| pytest_env=( | ||
| "CUVS_LUCENE_JAR=${cuvs_lucene_jar_abs}" | ||
| "CUVS_LUCENE_CUVS_JAVA_JAR=${cuvs_java_jar_abs}" | ||
| "CUVS_LUCENE_PYLUCENE_TEST_CLASSES=${pylucene_test_classes_abs}" | ||
| "CUVS_LUCENE_VERIFY_ALL_CODECS=${CUVS_LUCENE_VERIFY_ALL_CODECS:-1}" | ||
| ) | ||
|
|
||
| if [[ "${FULL_END_TO_END}" -eq 1 ]]; then | ||
| pytest_env+=( | ||
| "CUVS_LUCENE_PYLUCENE_CASES=${PYLUCENE_CASES:-all}" | ||
| "CUVS_LUCENE_PYLUCENE_ROWS=${PYLUCENE_ROWS:-2000}" | ||
| "CUVS_LUCENE_PYLUCENE_DIMS=${PYLUCENE_DIMS:-32}" | ||
| "CUVS_LUCENE_PYLUCENE_TOPK=${PYLUCENE_TOPK:-20}" | ||
| ) | ||
| else | ||
| if [[ -n "${PYLUCENE_CASES}" ]]; then | ||
| pytest_env+=("CUVS_LUCENE_PYLUCENE_CASES=${PYLUCENE_CASES}") | ||
| fi | ||
| if [[ -n "${PYLUCENE_ROWS}" ]]; then | ||
| pytest_env+=("CUVS_LUCENE_PYLUCENE_ROWS=${PYLUCENE_ROWS}") | ||
| fi | ||
| if [[ -n "${PYLUCENE_DIMS}" ]]; then | ||
| pytest_env+=("CUVS_LUCENE_PYLUCENE_DIMS=${PYLUCENE_DIMS}") | ||
| fi | ||
| if [[ -n "${PYLUCENE_TOPK}" ]]; then | ||
| pytest_env+=("CUVS_LUCENE_PYLUCENE_TOPK=${PYLUCENE_TOPK}") | ||
| fi | ||
| fi | ||
|
|
||
| if [[ -n "${PYLUCENE_MIN_RECALL}" ]]; then | ||
| pytest_env+=("CUVS_LUCENE_PYLUCENE_MIN_RECALL=${PYLUCENE_MIN_RECALL}") | ||
| fi | ||
|
|
||
| env "${pytest_env[@]}" \ | ||
| "${PYTHON_BIN}" -m pytest -q -s \ | ||
| src/test/python/test_pylucene_end_to_end.py \ | ||
| "${PYTEST_ARGS[@]}" |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.