Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ repos:
pass_filenames: false
files: rust/.*
language: rust
- id: spotless-fmt
name: spotless-fmt
entry: mvn --batch-mode --quiet -f java/cuvs-java/pom.xml spotless:apply
pass_filenames: false
files: ^java/cuvs-java/src/.*\.java$
exclude: .*/panama/.*
language: system
- id: clang-format-with-cmake-placeholders
name: clang-format-with-cmake-placeholders
entry: python3 ci/checks/clang_format_with_cmake_placeholders.py
Expand Down
2 changes: 2 additions & 0 deletions conda/environments/all_cuda-129_arch-aarch64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ dependencies:
- libopenblas<=0.3.30
- librmm==26.10.*,>=0.0.0a0
- make
- maven
- nccl>=2.19
- ninja
- nodejs>=22
- numpy>=2.0,<3.0
- openblas
- openjdk=22.*
- pre-commit
- pylibraft==26.10.*,>=0.0.0a0
- pytest
Expand Down
2 changes: 2 additions & 0 deletions conda/environments/all_cuda-129_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ dependencies:
- libnvjitlink-dev
- librmm==26.10.*,>=0.0.0a0
- make
- maven
- nccl>=2.19
- ninja
- nodejs>=22
- numpy>=2.0,<3.0
- openblas
- openjdk=22.*
- pre-commit
- pylibraft==26.10.*,>=0.0.0a0
- pytest
Expand Down
2 changes: 2 additions & 0 deletions conda/environments/all_cuda-133_arch-aarch64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ dependencies:
- libopenblas<=0.3.30
- librmm==26.10.*,>=0.0.0a0
- make
- maven
- nccl>=2.19
- ninja
- nodejs>=22
- numpy>=2.0,<3.0
- openblas
- openjdk=22.*
- pre-commit
- pylibraft==26.10.*,>=0.0.0a0
- pytest
Expand Down
2 changes: 2 additions & 0 deletions conda/environments/all_cuda-133_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ dependencies:
- libnvjitlink-dev
- librmm==26.10.*,>=0.0.0a0
- make
- maven
- nccl>=2.19
- ninja
- nodejs>=22
- numpy>=2.0,<3.0
- openblas
- openjdk=22.*
- pre-commit
- pylibraft==26.10.*,>=0.0.0a0
- pytest
Expand Down
5 changes: 5 additions & 0 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,11 @@ dependencies:
- output_types: [conda]
packages:
- c-compiler
# spotless-fmt pre-commit hook requires Maven and a JDK
- output_types: [conda]
packages:
- maven
- openjdk=22.*
clang:
common:
- output_types: conda
Expand Down
20 changes: 9 additions & 11 deletions java/cuvs-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,6 @@ SPDX-License-Identifier: Apache-2.0
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.44.5</version>
<executions>
<execution>
<goals>
<goal>apply</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
<configuration>
<java>
<includes>
Expand All @@ -268,15 +260,21 @@ SPDX-License-Identifier: Apache-2.0
<excludes>
<exclude>src/**/panama/*.java</exclude>
</excludes>
<!--
TODO: When we have more rules that should go to checkstyle or PMD
Comment thread
imotov marked this conversation as resolved.
(tracking issue: https://github.com/NVIDIA/cuvs/issues/2364)
-->
<replaceRegex>
<name>Use the headers_h facade, not numbered jextract classes</name>
<searchRegex>\bheaders_h_[0-9]+\b</searchRegex>
<replacement>headers_h</replacement>
</replaceRegex>
<googleJavaFormat>
<version>1.27.0</version>
<style>GOOGLE</style>
<reflowLongStrings>true</reflowLongStrings>
<formatJavadoc>false</formatJavadoc>
</googleJavaFormat>
<licenseHeader>
<file>${project.basedir}/../license-header.txt</file>
</licenseHeader>
</java>
</configuration>
</plugin>
Expand Down
15 changes: 10 additions & 5 deletions java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSAceParams.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package com.nvidia.cuvs;
Expand Down Expand Up @@ -75,8 +75,13 @@ public class CuVSAceParams {
*/
private final double maxGpuMemoryGb;

private CuVSAceParams(long npartitions, long efConstruction, String buildDir, boolean useDisk,
double maxHostMemoryGb, double maxGpuMemoryGb) {
private CuVSAceParams(
long npartitions,
long efConstruction,
String buildDir,
boolean useDisk,
double maxHostMemoryGb,
double maxGpuMemoryGb) {
this.npartitions = npartitions;
this.efConstruction = efConstruction;
this.buildDir = buildDir;
Expand Down Expand Up @@ -259,8 +264,8 @@ public Builder withMaxGpuMemoryGb(double maxGpuMemoryGb) {
* @return an instance of {@link CuVSAceParams}
*/
public CuVSAceParams build() {
return new CuVSAceParams(npartitions, efConstruction, buildDir, useDisk,
maxHostMemoryGb, maxGpuMemoryGb);
return new CuVSAceParams(
npartitions, efConstruction, buildDir, useDisk, maxHostMemoryGb, maxGpuMemoryGb);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,9 @@ static CuVSResources create(Path tempDirectory) throws Throwable {
* @throws LibraryException if the native library cannot be loaded
*/
static CuVSResources create(
Path tempDirectory,
Path memoryTrackingCsvPath,
Duration memoryTrackingSampleInterval) throws Throwable {
Path tempDirectory, Path memoryTrackingCsvPath, Duration memoryTrackingSampleInterval)
throws Throwable {
return CuVSProvider.provider()
.newCuVSResources(
tempDirectory, memoryTrackingCsvPath, memoryTrackingSampleInterval);
.newCuVSResources(tempDirectory, memoryTrackingCsvPath, memoryTrackingSampleInterval);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package com.nvidia.cuvs;
Expand All @@ -21,8 +21,12 @@ public class HnswAceParams {
private double maxHostMemoryGb;
private double maxGpuMemoryGb;

private HnswAceParams(long npartitions, String buildDir, boolean useDisk,
double maxHostMemoryGb, double maxGpuMemoryGb) {
private HnswAceParams(
long npartitions,
String buildDir,
boolean useDisk,
double maxHostMemoryGb,
double maxGpuMemoryGb) {
this.npartitions = npartitions;
this.buildDir = buildDir;
this.useDisk = useDisk;
Expand Down Expand Up @@ -188,8 +192,7 @@ public Builder withMaxGpuMemoryGb(double maxGpuMemoryGb) {
* @return an instance of {@link HnswAceParams}
*/
public HnswAceParams build() {
return new HnswAceParams(npartitions, buildDir, useDisk,
maxHostMemoryGb, maxGpuMemoryGb);
return new HnswAceParams(npartitions, buildDir, useDisk, maxHostMemoryGb, maxGpuMemoryGb);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package com.nvidia.cuvs;
Expand Down Expand Up @@ -283,13 +283,7 @@ public Builder withAceParams(HnswAceParams aceParams) {
*/
public HnswIndexParams build() {
return new HnswIndexParams(
hierarchy,
efConstruction,
numThreads,
vectorDimension,
m,
metric,
aceParams);
hierarchy, efConstruction, numThreads, vectorDimension, m, metric, aceParams);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ default Path nativeLibraryPath() {
* CSV samples
*/
default CuVSResources newCuVSResources(
Path tempDirectory,
Path memoryTrackingCsvPath,
Duration memoryTrackingSampleInterval) throws Throwable {
Path tempDirectory, Path memoryTrackingCsvPath, Duration memoryTrackingSampleInterval)
throws Throwable {
throw new UnsupportedOperationException(
"Memory-tracking resources are not supported by this provider");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ public CuVSResources newCuVSResources(Path tempDirectory) {

@Override
public CuVSResources newCuVSResources(
Path tempDirectory,
Path memoryTrackingCsvPath,
Duration memoryTrackingSampleInterval) {
Path tempDirectory, Path memoryTrackingCsvPath, Duration memoryTrackingSampleInterval) {
throw new UnsupportedOperationException(reasons);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package com.nvidia.cuvs.internal;
Expand Down Expand Up @@ -632,8 +632,10 @@ private static void populateNativeIndexParams(
cuvsAceParams.npartitions(cuvsAceParamsMemorySegment, cuVSAceParams.getNpartitions());
cuvsAceParams.ef_construction(cuvsAceParamsMemorySegment, cuVSAceParams.getEfConstruction());
cuvsAceParams.use_disk(cuvsAceParamsMemorySegment, cuVSAceParams.isUseDisk());
cuvsAceParams.max_host_memory_gb(cuvsAceParamsMemorySegment, cuVSAceParams.getMaxHostMemoryGb());
cuvsAceParams.max_gpu_memory_gb(cuvsAceParamsMemorySegment, cuVSAceParams.getMaxGpuMemoryGb());
cuvsAceParams.max_host_memory_gb(
cuvsAceParamsMemorySegment, cuVSAceParams.getMaxHostMemoryGb());
cuvsAceParams.max_gpu_memory_gb(
cuvsAceParamsMemorySegment, cuVSAceParams.getMaxGpuMemoryGb());

String buildDir = cuVSAceParams.getBuildDir();
if (buildDir != null && !buildDir.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import static com.nvidia.cuvs.internal.common.Util.checkCuVSError;
import static com.nvidia.cuvs.internal.panama.headers_h.*;
import static com.nvidia.cuvs.internal.panama.headers_h_1.C_INT;

import com.nvidia.cuvs.CuVSResources;
import com.nvidia.cuvs.DelegatingScopedAccess;
Expand Down Expand Up @@ -68,17 +67,13 @@ public CuVSResourcesImpl(Path tempDirectory) {
* CSV samples
*/
public CuVSResourcesImpl(
Path tempDirectory,
Path memoryTrackingCsvPath,
Duration memoryTrackingSampleInterval) {
Path tempDirectory, Path memoryTrackingCsvPath, Duration memoryTrackingSampleInterval) {
this.tempDirectory = tempDirectory;
try (var localArena = Arena.ofConfined()) {
var resourcesMemorySegment = localArena.allocate(cuvsResources_t);
byte[] pathBytes =
memoryTrackingCsvPath.toString().getBytes(StandardCharsets.UTF_8);
byte[] pathBytes = memoryTrackingCsvPath.toString().getBytes(StandardCharsets.UTF_8);
var pathSegment = localArena.allocate(pathBytes.length + 1L);
MemorySegment.copy(
pathBytes, 0, pathSegment, ValueLayout.JAVA_BYTE, 0, pathBytes.length);
MemorySegment.copy(pathBytes, 0, pathSegment, ValueLayout.JAVA_BYTE, 0, pathBytes.length);
pathSegment.set(ValueLayout.JAVA_BYTE, pathBytes.length, (byte) 0);
long sampleIntervalMs = memoryTrackingSampleInterval.toMillis();
checkCuVSError(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package com.nvidia.cuvs.internal;

import static com.nvidia.cuvs.internal.common.LinkerHelper.C_INT;
import static com.nvidia.cuvs.internal.common.Util.checkCudaError;
import static com.nvidia.cuvs.internal.common.Util.cudaGetDeviceProperties;
import static com.nvidia.cuvs.internal.panama.headers_h.cudaMemGetInfo;
import static com.nvidia.cuvs.internal.panama.headers_h_1.*;
import static com.nvidia.cuvs.internal.panama.headers_h.*;

import com.nvidia.cuvs.CuVSResources;
import com.nvidia.cuvs.CuVSResourcesInfo;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package com.nvidia.cuvs.internal;
Expand Down Expand Up @@ -251,8 +251,8 @@ public static HnswIndex.Builder newBuilder(CuVSResources cuvsResources) {
* @return A new HNSW index ready for search
* @throws Throwable if an error occurs during building
*/
public static HnswIndex build(CuVSResources resources, HnswIndexParams hnswParams, CuVSMatrix dataset)
throws Throwable {
public static HnswIndex build(
CuVSResources resources, HnswIndexParams hnswParams, CuVSMatrix dataset) throws Throwable {
Objects.requireNonNull(resources);
Objects.requireNonNull(hnswParams);
Objects.requireNonNull(dataset);
Expand Down Expand Up @@ -288,7 +288,8 @@ public static HnswIndex build(CuVSResources resources, HnswIndexParams hnswParam
return new HnswIndexImpl(new IndexReference(hnswIndex), resources, hnswParams);
}

private static CloseableHandle createHnswIndexParamsForBuild(Arena arena, HnswIndexParams params) {
private static CloseableHandle createHnswIndexParamsForBuild(
Arena arena, HnswIndexParams params) {
var hnswParams = createHnswIndexParams();
MemorySegment seg = hnswParams.handle();

Expand Down Expand Up @@ -324,7 +325,7 @@ private static MemorySegment prepareTensorFromMatrix(Arena arena, CuVSMatrix dat
return prepareTensor(
arena,
matrixInternal.memorySegment(),
new long[]{dataset.size(), dataset.columns()},
new long[] {dataset.size(), dataset.columns()},
matrixInternal.code(),
matrixInternal.bits(),
kDLCPU());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package com.nvidia.cuvs.internal.common;
Expand All @@ -9,7 +9,6 @@
import static com.nvidia.cuvs.internal.common.LinkerHelper.C_INT;
import static com.nvidia.cuvs.internal.common.LinkerHelper.C_LONG;
import static com.nvidia.cuvs.internal.panama.headers_h.*;
import static com.nvidia.cuvs.internal.panama.headers_h_1.cudaStream_t;

import com.nvidia.cuvs.CuVSResources;
import com.nvidia.cuvs.internal.panama.DLDataType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,7 @@ public CuVSResources newCuVSResources(Path tempDirectory) {

@Override
public CuVSResources newCuVSResources(
Path tempDirectory,
Path memoryTrackingCsvPath,
Duration memoryTrackingSampleInterval) {
Path tempDirectory, Path memoryTrackingCsvPath, Duration memoryTrackingSampleInterval) {
Objects.requireNonNull(tempDirectory);
Objects.requireNonNull(memoryTrackingCsvPath);
Objects.requireNonNull(memoryTrackingSampleInterval);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package com.nvidia.cuvs;
Expand Down Expand Up @@ -187,7 +187,10 @@ public void testAceDiskBasedBuild() throws Throwable {
// Convert CAGRA index to HNSW using fromCagra
// This automatically handles disk-based indices
HnswIndexParams hnswIndexParams =
new HnswIndexParams.Builder().withVectorDimension(2).withHierarchy(HnswHierarchy.GPU).build();
new HnswIndexParams.Builder()
.withVectorDimension(2)
.withHierarchy(HnswHierarchy.GPU)
.build();

try (var hnswIndexSerialized = HnswIndex.fromCagra(hnswIndexParams, index)) {
var hnswIndexSerializedPath = buildDir.resolve("hnsw_index.bin");
Expand Down
Loading
Loading