-
Notifications
You must be signed in to change notification settings - Fork 15
Update README.md #136
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
aamijar
wants to merge
7
commits into
rapidsai:release/26.06
Choose a base branch
from
aamijar:update-readme
base: release/26.06
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
Update README.md #136
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1fcd24e
update-readme
aamijar f793f8b
update references
aamijar 8d81c45
update references
aamijar 6ca8e66
em dash
aamijar 3da81d0
fix doc version link to 10.2.0
aamijar 0e068a6
update snippet
aamijar 03e59a9
update code snippet
aamijar 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 |
|---|---|---|
| @@ -1,29 +1,125 @@ | ||
| # Lucene cuVS | ||
| # cuVS Lucene | ||
|
|
||
| This is a project for using [cuVS](https://github.com/rapidsai/cuvs), NVIDIA's GPU accelerated vector search library, with [Apache Lucene](https://github.com/apache/lucene). | ||
|
|
||
| ## Overview | ||
| ## Contents | ||
|
|
||
| This library provides a new [KnnVectorFormat](https://lucene.apache.org/core/10_3_1/core/org/apache/lucene/codecs/KnnVectorsFormat.html) which can be plugged into a Lucene codec. | ||
| 1. [What is cuvs-lucene?](#what-is-cuvs-lucene) | ||
| 2. [Installing cuvs-lucene](#installing-cuvs-lucene) | ||
| 3. [Getting Started](#getting-started) | ||
| 4. [Contributing](#contributing) | ||
| 5. [References](#references) | ||
|
|
||
| ## Building | ||
| ## What is cuvs-lucene? | ||
|
|
||
| `cuvs-lucene` provides a pluggable [KnnVectorsFormat](https://lucene.apache.org/core/10_2_0/core/org/apache/lucene/codecs/KnnVectorsFormat.html) that uses cuVS to offload vector index build — and optionally search — to NVIDIA GPUs. Because it plugs in through a standard Lucene codec, existing Lucene applications can take advantage of GPU acceleration with minimal code changes and gracefully fall back to the default CPU codec when no GPU is present. | ||
|
|
||
| Four codecs are currently provided: | ||
|
|
||
| - `Lucene101AcceleratedHNSWCodec` — GPU-accelerated HNSW build with CPU HNSW search. The on-disk format is standard Lucene HNSW, so indexes built on the GPU can be read by any stock Lucene 10.x reader. | ||
| - `LuceneAcceleratedHNSWScalarQuantizedCodec` — scalar-quantized vectors for a smaller index footprint. | ||
| - `LuceneAcceleratedHNSWBinaryQuantizedCodec` — binary-quantized vectors for an even smaller index footprint. | ||
| - `CuVS2510GPUSearchCodec` — GPU-accelerated HNSW build and GPU search | ||
|
|
||
| ## Installing cuvs-lucene | ||
|
|
||
| ### Prerequisites | ||
| - [CUDA 12.0+](https://developer.nvidia.com/cuda-toolkit-archive), | ||
| - [Maven 3.9.6+](https://maven.apache.org/download.cgi), | ||
| - [CUDA 12.0+](https://developer.nvidia.com/cuda-toolkit-archive) | ||
| - [JDK 22](https://jdk.java.net/archive/) | ||
| - [Maven 3.9.6+](https://maven.apache.org/download.cgi) | ||
| - A compatible cuVS installation (26.04 - 26.06). For Maven usage, install the cuVS tarball and add it to your system library load path. See the cuVS [tarball install instructions](https://docs.rapids.ai/api/cuvs/stable/build/#download-extract). | ||
|
|
||
| ### Maven | ||
|
|
||
| To pull `cuvs-lucene` into a Maven project, add the following dependency to your `pom.xml`: | ||
|
|
||
| ```xml | ||
| <dependency> | ||
| <groupId>com.nvidia.cuvs.lucene</groupId> | ||
| <artifactId>cuvs-lucene</artifactId> | ||
| <version>26.06.0</version> | ||
| </dependency> | ||
| ``` | ||
|
|
||
| ### Building from source | ||
|
|
||
| ```sh | ||
| git clone https://github.com/rapidsai/cuvs-lucene.git | ||
| cd cuvs-lucene | ||
| mvn clean compile package | ||
| ``` | ||
| The artifacts would be built and available in the target / folder. | ||
|
|
||
| ### Running Tests | ||
| The resulting artifacts are written to `target/`. To run the tests, first install cuVS and add it to your system library load path, as described in the cuVS [tarball install instructions](https://docs.rapids.ai/api/cuvs/stable/build/#download-extract), then run: | ||
|
|
||
| ```sh | ||
| mvn clean test | ||
| ``` | ||
|
|
||
| ## Getting Started | ||
|
|
||
| The example below plugs the GPU-accelerated HNSW codec into a standard Lucene `IndexWriter`. Once the codec is set on the `IndexWriterConfig`, indexing proceeds exactly as it would with the default Lucene codec, and search uses the stock `KnnFloatVectorQuery`. | ||
|
|
||
| Before running it, make sure cuVS is installed and available on your system library load path. The cuVS [tarball install instructions](https://docs.rapids.ai/api/cuvs/stable/build/#download-extract) show how to set this up. | ||
|
|
||
| In a Maven project that includes the `cuvs-lucene` dependency shown above, create `src/main/java/com/nvidia/cuvs/lucene/examples/HelloCuvsLucene.java`: | ||
|
|
||
| ```java | ||
| package com.nvidia.cuvs.lucene.examples; | ||
|
|
||
| import static org.apache.lucene.index.VectorSimilarityFunction.EUCLIDEAN; | ||
|
|
||
| import com.nvidia.cuvs.lucene.AcceleratedHNSWParams; | ||
| import com.nvidia.cuvs.lucene.Lucene101AcceleratedHNSWCodec; | ||
| import java.nio.file.Path; | ||
| import java.nio.file.Paths; | ||
| import org.apache.lucene.codecs.Codec; | ||
| import org.apache.lucene.document.Document; | ||
| import org.apache.lucene.document.KnnFloatVectorField; | ||
| import org.apache.lucene.index.IndexWriter; | ||
| import org.apache.lucene.index.IndexWriterConfig; | ||
| import org.apache.lucene.store.Directory; | ||
| import org.apache.lucene.store.FSDirectory; | ||
|
|
||
| public class HelloCuvsLucene { | ||
| public static void main(String[] args) throws Exception { | ||
| AcceleratedHNSWParams params = new AcceleratedHNSWParams.Builder().build(); | ||
| Codec codec = new Lucene101AcceleratedHNSWCodec(params); | ||
| IndexWriterConfig config = new IndexWriterConfig().setCodec(codec); | ||
|
|
||
| Path indexPath = Paths.get("index"); | ||
| float[] embedding = new float[] {0.1f, 0.2f, 0.3f, 0.4f}; | ||
|
|
||
| try (Directory dir = FSDirectory.open(indexPath); | ||
| IndexWriter writer = new IndexWriter(dir, config)) { | ||
| Document doc = new Document(); | ||
| doc.add(new KnnFloatVectorField("vector_field", embedding, EUCLIDEAN)); | ||
| writer.addDocument(doc); | ||
| } | ||
|
|
||
| System.out.println("Hello cuVS Lucene ran successfully."); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Run it: | ||
|
|
||
| ```sh | ||
| export LD_LIBRARY_PATH={ PATH TO YOUR LOCAL libcuvs_c.so }:$LD_LIBRARY_PATH && mvn clean test | ||
| mvn -q compile org.codehaus.mojo:exec-maven-plugin:3.5.1:java \ | ||
| -Dexec.mainClass=com.nvidia.cuvs.lucene.examples.HelloCuvsLucene | ||
| ``` | ||
|
|
||
| For more examples, including one that indexes and searches entirely on the GPU using `CuVS2510GPUSearchCodec`, please refer to the [`examples/`](examples) directory. | ||
|
|
||
| ## Contributing | ||
|
|
||
| If you are interested in contributing to cuvs-lucene, please read our [Contributing guide](CONTRIBUTING.md). | ||
|
|
||
| > [!NOTE] | ||
| > The code style format is automatically enforced (including the missing license header, if any) using the [Spotless maven plugin](https://github.com/diffplug/spotless/tree/main/plugin-maven). This currently happens in the maven's `validate` stage. | ||
|
|
||
| ## References | ||
|
|
||
| - [Bring Massive-Scale Vector Search to the GPU with Apache Lucene](https://www.nvidia.com/en-us/on-demand/session/gtc25-S71286/) — NVIDIA GTC 2025 session video | ||
| - [cuVS and Lucene: GPU-based Vector Search](https://www.youtube.com/watch?v=qiW7iIDFJC0) — Berlin Buzzwords 2024 session video | ||
| - [Exploring GPU-accelerated vector search in Elasticsearch with NVIDIA](https://www.elastic.co/search-labs/blog/gpu-accelerated-vector-search-elasticsearch-nvidia) — Elasticsearch Blog | ||
| - [Apache Lucene Accelerated with the NVIDIA cuVS 25.06 Release](https://searchscale.com/blog/apache-lucene-accelerated-with-nvidia-cuvs-25.06-release/) — SearchScale Blog | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we have a codec for CPU build HNSW search. We have codecs for GPU build CPU search and for GPU build GPU search. Can you verify? @narangvivek10
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess here you mean indexing on the CPU and searching on the CPU for HNSW. No, we do not because Lucene itself has codecs and formats available for that. We, however, have a fallback mechanism in formats like, for example, in Lucene99AcceleratedHNSWVectorsFormat that internally refers to Lucene's index and search on CPU logic. This is helpful for people who use our Codec/format, and they do not have a GPU/cuVS available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the clarification @narangvivek10. So does that mean that the docs above are okay, or should something be changed.