CuVSProvider

View as Markdown

Java package: com.nvidia.cuvs.spi

1public interface CuVSProvider

A provider of low-level cuvs resources and builders.

Public Members

tempDirectory

1static Path tempDirectory()

The temporary directory to use for intermediate operations. Defaults to {@systemProperty java.io.tmpdir}.

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:22

nativeLibraryPath

1default Path nativeLibraryPath()

The directory where to extract and install the native library. Defaults to {@systemProperty java.io.tmpdir}.

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:30

newCuVSResources

1CuVSResources newCuVSResources(Path tempDirectory) throws Throwable

Creates a new CuVSResources.

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:35

newHostMatrixBuilder

1CuVSMatrix.Builder<CuVSHostMatrix> newHostMatrixBuilder( long size, long dimensions, CuVSMatrix.DataType dataType)

Create a CuVSMatrix.Builder instance for a host memory matrix *

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:38

newHostMatrixBuilder

1CuVSMatrix.Builder<CuVSHostMatrix> newHostMatrixBuilder( long size, long columns, int rowStride, int columnStride, CuVSMatrix.DataType dataType)

Create a CuVSMatrix.Builder instance for a host memory matrix *

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:42

newDeviceMatrixBuilder

1CuVSMatrix.Builder<CuVSDeviceMatrix> newDeviceMatrixBuilder( CuVSResources cuVSResources, long size, long dimensions, CuVSMatrix.DataType dataType)

Create a CuVSMatrix.Builder instance for a device memory matrix *

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:46

newDeviceMatrixBuilder

1CuVSMatrix.Builder<CuVSDeviceMatrix> newDeviceMatrixBuilder( CuVSResources cuVSResources, long size, long dimensions, int rowStride, int columnStride, CuVSMatrix.DataType dataType)

Create a CuVSMatrix.Builder instance for a device memory matrix *

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:50

newNativeMatrixBuilder

1MethodHandle newNativeMatrixBuilder()

Returns the factory method used to build a CuVSMatrix from native memory. The factory method will have this signature: CuVSMatrix createNativeMatrix(memorySegment, size, dimensions, dataType), where memorySegment is a java.lang.foreign.MemorySegment containing int size vectors of int dimensions length of type CuVSMatrix.DataType.

In order to expose this factory in a way that is compatible with Java 21, the factory method is returned as a MethodHandle with MethodType equal to (CuVSMatrix.class, MemorySegment.class, int.class, int.class, CuVSMatrix.DataType.class). The caller will need to invoke the factory via the MethodHandle#invokeExact method: var matrix = (CuVSMatrix)newNativeMatrixBuilder().invokeExact(memorySegment, size, dimensions, dataType)

Returns

a MethodHandle which can be invoked to build a CuVSMatrix from an external MemorySegment

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:73

newNativeMatrixBuilderWithStrides

1MethodHandle newNativeMatrixBuilderWithStrides()

Returns the factory method used to build a CuVSMatrix from native memory, with strides. The factory method will have this signature: CuVSMatrix createNativeMatrix(memorySegment, size, dimensions, rowStride, columnStride, dataType), where memorySegment is a java.lang.foreign.MemorySegment containing int size vectors of int dimensions length of type CuVSMatrix.DataType. Rows have a stride of rowStride, where 0 indicates “no stride” (a stride equal to the number of columns), and columns have a stride of columnStride

In order to expose this factory in a way that is compatible with Java 21, the factory method is returned as a MethodHandle with MethodType equal to (CuVSMatrix.class, MemorySegment.class, int.class, int.class, int.class, int.class, DataType.class). The caller will need to invoke the factory via the MethodHandle#invokeExact method: var matrix = (CuVSMatrix)newNativeMatrixBuilder().invokeExact(memorySegment, size, dimensions, rowStride, columnStride, dataType)

Returns

a MethodHandle which can be invoked to build a CuVSMatrix from an external MemorySegment

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:92

newMatrixFromArray

1CuVSMatrix newMatrixFromArray(float[][] vectors)

Create a CuVSMatrix from an on-heap array *

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:95

newMatrixFromArray

1CuVSMatrix newMatrixFromArray(int[][] vectors)

Create a CuVSMatrix from an on-heap array *

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:98

newMatrixFromArray

1CuVSMatrix newMatrixFromArray(byte[][] vectors)

Create a CuVSMatrix from an on-heap array *

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:101

newBruteForceIndexBuilder

1BruteForceIndex.Builder newBruteForceIndexBuilder(CuVSResources cuVSResources) throws UnsupportedOperationException

Creates a new BruteForceIndex Builder.

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:104

newCagraIndexBuilder

1CagraIndex.Builder newCagraIndexBuilder(CuVSResources cuVSResources) throws UnsupportedOperationException

Creates a new CagraIndex Builder.

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:108

newHnswIndexBuilder

1HnswIndex.Builder newHnswIndexBuilder(CuVSResources cuVSResources) throws UnsupportedOperationException

Creates a new HnswIndex Builder.

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:112

hnswIndexFromCagra

1HnswIndex hnswIndexFromCagra(HnswIndexParams hnswParams, CagraIndex cagraIndex) throws Throwable

Creates an HNSW index from an existing CAGRA index.

Parameters

NameDescription
hnswParamsParameters for the HNSW index
cagraIndexThe CAGRA index to convert from

Returns

A new HNSW index

Throws

TypeDescription
Throwableif an error occurs during conversion

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:123

hnswIndexBuild

1HnswIndex hnswIndexBuild(CuVSResources resources, HnswIndexParams hnswParams, CuVSMatrix dataset) throws Throwable

Builds an HNSW index using the ACE (Augmented Core Extraction) algorithm.

Parameters

NameDescription
resourcesThe CuVS resources
hnswParamsParameters for the HNSW index with ACE configuration
datasetThe dataset to build the index from

Returns

A new HNSW index ready for search

Throws

TypeDescription
Throwableif an error occurs during building

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:134

newTieredIndexBuilder

1TieredIndex.Builder newTieredIndexBuilder(CuVSResources cuVSResources) throws UnsupportedOperationException

Creates a new TieredIndex Builder.

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:138

mergeCagraIndexes

1CagraIndex mergeCagraIndexes(CagraIndex[] indexes) throws Throwable

Merges multiple CAGRA indexes into a single index.

Parameters

NameDescription
indexesArray of CAGRA indexes to merge

Returns

A new merged CAGRA index

Throws

TypeDescription
Throwableif an error occurs during the merge operation

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:148

mergeCagraIndexes

1default CagraIndex mergeCagraIndexes(CagraIndex[] indexes, CagraIndexParams mergeParams) throws Throwable

Merges multiple CAGRA indexes into a single index with the specified merge parameters.

Parameters

NameDescription
indexesArray of CAGRA indexes to merge
mergeParamsParameters to control the merge operation, or null to use defaults

Returns

A new merged CAGRA index

Throws

TypeDescription
Throwableif an error occurs during the merge operation

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:158

gpuInfoProvider

1GPUInfoProvider gpuInfoProvider()

Returns a GPUInfoProvider to query the system for GPU related information

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:165

enableRMMPooledMemory

1void enableRMMPooledMemory(int initialPoolSizePercent, int maxPoolSizePercent)

Switch RMM allocations (used internally by various cuVS algorithms and by the default implementation of CuVSDeviceMatrix) to use pooled memory. This operation has a global effect, and will affect all resources on the current device.

Parameters

NameDescription
initialPoolSizePercentThe initial pool size, in percentage of the total GPU memory
maxPoolSizePercentThe maximum pool size, in percentage of the total GPU memory

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:179

enableRMMManagedPooledMemory

1void enableRMMManagedPooledMemory(int initialPoolSizePercent, int maxPoolSizePercent)

Switch RMM allocations (used internally by various cuVS algorithms and by the default implementation of CuVSDeviceMatrix) to use pooled memory. This operation has a global effect, and will affect all resources on the current device.

Parameters

NameDescription
initialPoolSizePercentThe initial pool size, in percentage of the total GPU memory
maxPoolSizePercentThe maximum pool size, in percentage of the total GPU memory

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:189

resetRMMPooledMemory

1void resetRMMPooledMemory()

Disables pooled memory on the current device, reverting back to the default setting.

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:192

provider

1static CuVSProvider provider()

Retrieves the system-wide provider.

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:195

cagraIndexParamsFromHnswParams

1CagraIndexParams cagraIndexParamsFromHnswParams( long rows, long dim, int m, int efConstruction, CagraIndexParams.HnswHeuristicType heuristic, CagraIndexParams.CuvsDistanceType metric)

Create a CAGRA index parameters compatible with HNSW index

Note: The reference HNSW index and the corresponding from-CAGRA generated HNSW index will NOT produce exactly the same recalls and QPS for the same parameter ef. The graphs are different internally. Depending on the selected heuristics, the CAGRA-produced graph’s QPS-Recall curve may be shifted along the curve right or left. See the heuristics descriptions for more details.

Parameters

NameDescription
rowsThe number of rows in the input dataset
dimThe number of dimensions in the input dataset
mHNSW index parameter M
efConstructionHNSW index parameter ef_construction
heuristicThe heuristic to use for selecting the graph build parameters
metricThe distance metric to search

Returns

A new CAGRA index parameters object

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:215

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java:15