← Back to Pull requests

Add PyLucene runtime integration #3033

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Nov 09, 2026 20:32 UTC
Author

Summary

  • Add a checksum-pinned PyLucene 10.2.0 source builder and compatibility patch.

  • Add optional JVM initialization, matching JAR discovery, vector/query adapters, and persisted-index verification for Lucene consumers.

  • Validate CAGRA metadata, checksums, and referenced payload ranges while allowing unreferenced bytes.

  • Add a thin-JAR timing bridge around IndexSearcher.search(Query, int), with generated Java API documentation.

  • Document runtime prerequisites, the pinned source-builder workflow, JVM setup, and Java search timing.
  • This runtime layer is independently based on main; benchmark backend registration is separate. PyLucene remains pinned to 10.2.0 and uses the matching cuvs-lucene-10.2 thin JAR.

    Validation

    Documentation-only follow-up (2026-11-10):

  • fern/build_docs.sh check with Node 22.14.0 and Fern 5.57.0: passed.

  • Navigation, embedded-example syntax, and documentation/implementation ownership checks: passed.

  • Focused runtime/configuration/builder tests rerun: 73 passed.

  • git diff --check: passed.
  • Fern retains the existing unauthenticated-redirect and light-theme contrast warnings.
    No production or test code changed in this follow-up. Earlier implementation
    validation remains recorded below at its tested revision.

    Validated commit 6e54f6193aa9, based on upstream main at 54d576774731:

  • Full ordinary cuVS Bench suite: 236 passed, 26 skipped, no deselections; all 67 runtime/configuration/builder tests passed without skips.

  • Java timing bridge: 8 passed, no skips, across Lucene 10.2.0, 10.3.2, 10.4.0, and 10.5.2; fresh 26.12.0 JARs and thin-JAR contents verified.

  • Real PyLucene 10.2.0 CPU build/search: direct and thin-JAR timing dispatch passed in separate processes, including exact-neighbor and persisted-index checks.

  • Real pinned source-archive preparation and cache reuse, Bash syntax, Ruff, Java formatting, generated Fern references, and whitespace checks passed.
  • The ordinary suite was rerun after strengthening the invalid-range cleanup assertion. Java and live-runtime checks preceded that test-only edit; their production sources are unchanged.

    The skips are 23 unavailable optional Elasticsearch cases and three unreachable OpenSearch cases. Ordinary CLI checks use the existing 26.08 C++ runner. Java builds emitted header-generation, deprecation, Maven, and Vector API warnings; the live CPU checks emitted the incubator-module warning.

    The existing custom PyLucene runtime was reused for live checks; a complete fresh PyLucene compilation, GPU execution, and real ARM64 execution were not repeated. Java module coverage does not imply support for additional PyLucene versions.

    Follow-up PRs

  • Backend integration — implemented and tested (#19, #20): Add a cuVS Bench backend for Lucene CPU HNSW, cuVS-accelerated HNSW, and GPU CAGRA. This includes configuration loading, build/search timing, saved-index validation and provenance, rollback-safe publication, plugin registration, packaging, documentation, and opt-in CPU/GPU integration tests. Validation includes ordinary tests, installed-wheel CPU execution, and live integration on the combined stack.
  • Result-handling optimization — implemented and correctness-tested (#33): Reduce Python/JVM result-conversion overhead through a Java helper and owned NumPy result matrices, while preserving ranked results, distance precision, and compatibility with older JARs. This also fixes an inherited randomized-test fixture issue.
  • Benchmark controls — implemented with focused and live validation (#34–#37): Expose CAGRA search settings, HNSW ef_search, and GPU queries returning more than 1,024 neighbors; configurable graph construction, including HNSW parameters, graph degrees, layers, writer threads, and IVF-PQ construction options; and reproducible retained/merged segment layouts. Persisted configuration and topology checks support reliable index reuse and comparisons, with merge timing reported separately.
  • HNSW entry sampling — experimental and opt-in (#38): Sample entry candidates for single-layer, unquantized HNSW graphs and begin one traversal from the best candidate. Correctness and search-budget behavior are tested; a performance benefit has not been established.
  • Large-segment construction — experimental, unsupported override (#39): Explore larger segments using an explicitly enabled, version-guarded Lucene 10.2 RAM-threshold override. Separate 3 GiB capacity tests provide initial evidence; the override does not guarantee arbitrary segment capacity.
  • Prerequisites to follow-up PRs

  • CAGRA query-resource cleanup — implemented with GPU regression coverage (#2630): Close each device-backed query matrix after synchronous result materialization, including exception cleanup, to prevent retained GPU allocations during repeated searches. Filtered and unfiltered searches share builder setup while preserving routing, filtering, scoring, and public APIs. Validation includes repeated-query allocation checks and GPU query tests across Lucene 10.2–10.4. This fix is a prerequisite for activating the backend’s CAGRA search path.
  • Generic benchmark plugin and CLI support — implemented and tested (#3031): Allow registered backends to supply algorithm defaults and fatal-result summaries; preserve backend configuration consistently throughout each invocation; and protect previous measurements during failed, skipped, dry-run, and partial-sweep execution. Stable search-plan identities support reliable result updates. Validation includes backend-hook/export tests and ordinary Bench tests covering native CLI integration and dry runs. These shared capabilities support the subsequent Lucene backend registration.
  • PyLucene runtime foundation — implemented with live CPU and Java compatibility validation (#3033): [ this PR! ]
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: imotov Review duration: 31340m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #3033"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.7% · Safe to merge
    27.7%
    Repository