-
Notifications
You must be signed in to change notification settings - Fork 232
Expose Vamana build and serialize through cuvs-java #2555
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
shaunakkapur
wants to merge
1
commit into
NVIDIA:main
Choose a base branch
from
shaunakkapur:feat/java-vamana-index
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
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
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
201 changes: 201 additions & 0 deletions
201
fern/pages/java_api/java-api-com-nvidia-cuvs-vamanaindex.md
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,201 @@ | ||
| --- | ||
| slug: api-reference/java-api-com-nvidia-cuvs-vamanaindex | ||
| --- | ||
|
|
||
| # VamanaIndex | ||
|
|
||
| _Java package: `com.nvidia.cuvs`_ | ||
|
|
||
| ```java | ||
| public interface VamanaIndex extends AutoCloseable | ||
| ``` | ||
|
|
||
| `VamanaIndex` encapsulates a Vamana index, along with methods to build | ||
| it on the GPU and serialize it in the DiskANN file format. | ||
|
|
||
| Vamana is the graph construction algorithm behind DiskANN. cuVS currently | ||
| provides build and serialize only. There is no Vamana search API, so a | ||
| serialized index is searched by loading it with DiskANN. | ||
|
|
||
| ## Public Members | ||
|
|
||
| ### getDimensions | ||
|
|
||
| ```java | ||
| int getDimensions() throws Throwable | ||
| ``` | ||
|
|
||
| Gets the dimensionality of the vectors in this index. | ||
|
|
||
| **Returns** | ||
|
|
||
| the number of dimensions | ||
|
|
||
| _Source: `java/cuvs-java/src/main/java/com/nvidia/cuvs/VamanaIndex.java:30`_ | ||
|
|
||
| ### serialize | ||
|
|
||
| ```java | ||
| default void serialize(Path filePrefix) throws Throwable | ||
| ``` | ||
|
|
||
| Serializes the index in the DiskANN file format, including the dataset. | ||
|
|
||
| This writes two files, `filePrefix` holding the graph and | ||
| `filePrefix + ".data"` holding the dataset. | ||
|
|
||
| **Parameters** | ||
|
|
||
| | Name | Description | | ||
| | --- | --- | | ||
| | `filePrefix` | the prefix that output file names are derived from | | ||
|
|
||
| _Source: `java/cuvs-java/src/main/java/com/nvidia/cuvs/VamanaIndex.java:40`_ | ||
|
|
||
| ### serialize | ||
|
|
||
| ```java | ||
| void serialize(Path filePrefix, boolean includeDataset) throws Throwable | ||
| ``` | ||
|
|
||
| Serializes the index in the DiskANN file format. | ||
|
|
||
| When `includeDataset` is true this writes `filePrefix` holding | ||
| the graph and `filePrefix + ".data"` holding the dataset. When it is | ||
| false only `filePrefix` is written. | ||
|
|
||
| The argument is a prefix and not a complete file name, matching the native | ||
| `file_prefix` parameter. | ||
|
|
||
| **Parameters** | ||
|
|
||
| | Name | Description | | ||
| | --- | --- | | ||
| | `filePrefix` | the prefix that output file names are derived from | | ||
| | `includeDataset` | whether to write the dataset alongside the graph | | ||
|
|
||
| _Source: `java/cuvs-java/src/main/java/com/nvidia/cuvs/VamanaIndex.java:57`_ | ||
|
|
||
| ### getCuVSResources | ||
|
|
||
| ```java | ||
| CuVSResources getCuVSResources() | ||
| ``` | ||
|
|
||
| Gets an instance of `CuVSResources` | ||
|
|
||
| **Returns** | ||
|
|
||
| an instance of `CuVSResources` | ||
|
|
||
| _Source: `java/cuvs-java/src/main/java/com/nvidia/cuvs/VamanaIndex.java:64`_ | ||
|
|
||
| ### newBuilder | ||
|
|
||
| ```java | ||
| static Builder newBuilder(CuVSResources cuvsResources) | ||
| ``` | ||
|
|
||
| Creates a new Builder with an instance of `CuVSResources`. | ||
|
|
||
| **Parameters** | ||
|
|
||
| | Name | Description | | ||
| | --- | --- | | ||
| | `cuvsResources` | an instance of `CuVSResources` | | ||
|
|
||
| **Throws** | ||
|
|
||
| | Type | Description | | ||
| | --- | --- | | ||
| | `UnsupportedOperationException` | if the provider does not support cuvs | | ||
|
|
||
| _Source: `java/cuvs-java/src/main/java/com/nvidia/cuvs/VamanaIndex.java:72`_ | ||
|
|
||
| ### withDataset | ||
|
|
||
| ```java | ||
| Builder withDataset(float[][] vectors) | ||
| ``` | ||
|
|
||
| Sets the dataset for building the `VamanaIndex`. | ||
|
|
||
| **Parameters** | ||
|
|
||
| | Name | Description | | ||
| | --- | --- | | ||
| | `vectors` | a two-dimensional float array | | ||
|
|
||
| **Returns** | ||
|
|
||
| an instance of this Builder | ||
|
|
||
| _Source: `java/cuvs-java/src/main/java/com/nvidia/cuvs/VamanaIndex.java:88`_ | ||
|
|
||
| ### withDataset | ||
|
|
||
| ```java | ||
| Builder withDataset(CuVSMatrix dataset) | ||
| ``` | ||
|
|
||
| Sets the dataset for building the `VamanaIndex`. | ||
|
|
||
| The native builder accepts `float`, `half`, `uint8`, | ||
| and `int8` datasets. Of those, `CuVSMatrix.DataType#FLOAT`, | ||
| `CuVSMatrix.DataType#HALF`, and `CuVSMatrix.DataType#BYTE` | ||
| are reachable from Java today, where `BYTE` is unsigned. | ||
| `int8` has no corresponding `DataType`. | ||
|
|
||
| The native index may retain a non-owning device view of the dataset | ||
| rather than copying it, so the caller must keep this matrix open for at | ||
| least as long as the index and close it afterwards. A dataset supplied as | ||
| a `float[][]` is created and closed by the index instead. | ||
|
|
||
| **Parameters** | ||
|
|
||
| | Name | Description | | ||
| | --- | --- | | ||
| | `dataset` | a `CuVSMatrix` object containing the vectors | | ||
|
|
||
| **Returns** | ||
|
|
||
| an instance of this Builder | ||
|
|
||
| _Source: `java/cuvs-java/src/main/java/com/nvidia/cuvs/VamanaIndex.java:107`_ | ||
|
|
||
| ### withIndexParams | ||
|
|
||
| ```java | ||
| Builder withIndexParams(VamanaIndexParams vamanaIndexParameters) | ||
| ``` | ||
|
|
||
| Registers an instance of configured `VamanaIndexParams` with this | ||
| Builder. | ||
|
|
||
| **Parameters** | ||
|
|
||
| | Name | Description | | ||
| | --- | --- | | ||
| | `vamanaIndexParameters` | An instance of VamanaIndexParams | | ||
|
|
||
| **Returns** | ||
|
|
||
| An instance of this Builder | ||
|
|
||
| _Source: `java/cuvs-java/src/main/java/com/nvidia/cuvs/VamanaIndex.java:116`_ | ||
|
|
||
| ### build | ||
|
|
||
| ```java | ||
| VamanaIndex build() throws Throwable | ||
| ``` | ||
|
|
||
| Builds and returns an instance of `VamanaIndex`. | ||
|
|
||
| **Returns** | ||
|
|
||
| an instance of `VamanaIndex` | ||
|
|
||
| _Source: `java/cuvs-java/src/main/java/com/nvidia/cuvs/VamanaIndex.java:123`_ | ||
|
|
||
| _Source: `java/cuvs-java/src/main/java/com/nvidia/cuvs/VamanaIndex.java:21`_ |
Oops, something went wrong.
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.
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.
These two should probably go to the Nearest Neighbors section. Might require updating with this list
cuvs/fern/scripts/generate_api_reference.py
Lines 3034 to 3041 in 279febc