Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
4367f36
Refactor merge to call CAGRA's merge(), implement CAGRA prefiltering
chatman Aug 11, 2025
f136334
Handle CAGRA merge with deletions and code cleanup
narangvivek10 Aug 13, 2025
283e2cf
Code refactoring
narangvivek10 Aug 13, 2025
e19b628
Adding tests for BF and CAG+BF merge
chatman Aug 14, 2025
2d96c71
Slight fix to IntStream usage
chatman Aug 14, 2025
53d326c
Merge branch 'branch-25.10' into searchscale/merge-and-prefiltering
chatman Aug 14, 2025
3f0a03b
Move createFloatMatrix to Utils
narangvivek10 Aug 14, 2025
433c485
Merge branch 'branch-25.10' into searchscale/merge-and-prefiltering
chatman Aug 28, 2025
84eae2f
Fail tests if cuVS libraries not found
Sep 4, 2025
9498678
Debugging on CI to see where to find libcuvs_c.so
Sep 4, 2025
40e21f1
Merge branch 'branch-25.10' into searchscale/merge-and-prefiltering
chatman Sep 4, 2025
31f1dab
Revert "Debugging on CI to see where to find libcuvs_c.so"
Sep 4, 2025
6f8bebd
Upgrade to latest cuvs-java & pulling libcuvs from nightly if not fou…
Sep 11, 2025
5692496
Merge branch 'branch-25.10' into searchscale/merge-and-prefiltering
chatman Sep 11, 2025
41a0124
CI Style check fix
Sep 11, 2025
221de3d
CI shellcheck fixes
Sep 11, 2025
5de9cc9
Disabling shellcheck SC1091
Sep 11, 2025
00947ef
Error finding .so file in CI, adding debug logging
Sep 11, 2025
3d9de2d
find command was failing for non-existent paths that were present in …
Sep 11, 2025
5b1313b
Removing CUDA 12.9 build and debug-printing libcudart.so location
Sep 11, 2025
5b90792
Debug-printing libcudart.so location
Sep 11, 2025
6c0fb70
Adding the conda's lib dir to LD_LIBRARY_PATH
Sep 11, 2025
1b9ce64
Removing the loading of cudart to see if tests still pass
Sep 11, 2025
f0efa86
Revert "Removing the loading of cudart to see if tests still pass"
Sep 11, 2025
4b09035
Update build.sh - to build cuvs from source instead, revert pr.yaml
narangvivek10 Sep 21, 2025
8c8e009
Add --build-cuvs-from-source argument
narangvivek10 Sep 21, 2025
c4f1abb
Update ci/build_java.sh - to handle additional argument
narangvivek10 Sep 21, 2025
fa7cdb1
Update build.sh - change cuvs repo
narangvivek10 Sep 21, 2025
f4bc2e6
Update build.sh - get cmake if not available
narangvivek10 Sep 21, 2025
06e39dd
Revert build from source changes.
narangvivek10 Sep 22, 2025
76010c0
Merge branch 'branch-25.10' into searchscale/merge-and-prefiltering
narangvivek10 Sep 22, 2025
d8bb38d
Use libcuvs from conda environment instead
narangvivek10 Sep 22, 2025
f27f907
Update log message in ci/build_java.sh
narangvivek10 Sep 24, 2025
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
21 changes: 21 additions & 0 deletions ci/build_java.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,27 @@ set -u

rapids-print-env

# Locates the libcuvs.so file path and appends it to LD_LIBRARY_PATH
rapids-logger "Find libcuvs so file and prepend paths to LD_LIBRARY_PATH"

CONDA_PKG_CACHE_DIR="/opt/conda/pkgs" # comes from `conda info`. Dont know if this ever changes.
if [ -d "$CONDA_PKG_CACHE_DIR" ]; then
echo "==> Directory '$CONDA_PKG_CACHE_DIR' exists."
LIBCUVS_SO_FILE="libcuvs.so"
LIBCUVS_PATH=$(find $CONDA_PKG_CACHE_DIR -name $LIBCUVS_SO_FILE)
if [ -z "$LIBCUVS_PATH" ]; then
echo "==> Could not find the so file. Not updating LD_LIBRARY_PATH"
exit 1
else
LIBCUVS_DIR=$(dirname "$LIBCUVS_PATH")
export LD_LIBRARY_PATH="$LIBCUVS_DIR:$LD_LIBRARY_PATH"
echo "LD_LIBRARY_PATH is: $LD_LIBRARY_PATH"
fi
else
echo "==> Directory '$CONDA_PKG_CACHE_DIR' does not exist. Not updating LD_LIBRARY_PATH"
exit 1
fi

rapids-logger "Run Java build"

bash ./build.sh "${EXTRA_BUILD_ARGS[@]}"
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 @@ -2,6 +2,7 @@
# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
channels:
- conda-forge
- rapidsai-nightly
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to be careful because this could tie our release packaging to nightly dependencies. Will let the build team comment on the best way to do this

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other RAPIDS packages, these environment files are used to create the test environment. They do not go into built packages. I think the same is true for you here, but you know better than me.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, to the best of my understanding, my reasoning behind setting this to rapidsai-nightly was to make sure that the latest changes happening in the cuvs level should be used, so that all required updates (especially the ones needed due to breaking changes in cuvs) at the cuvs-lucene level are attended to in time (if not taken care of, already).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a mix. There's benefits and drawbacks to each method. With nightlies, you will catch new issues. You may spend more time fixing breaking changes in smaller chunks. You might update your software in ways that are incompatible with the previous release. This last issue is not a concern for us, because we do not support mixing different release versions of different packages.

I think your setting here is fine and safe. If you find the breaks come too often and you want to sort them out in larger batches, then remove it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree w/ @msarahan. I think this is fine.

dependencies:
- cuda-cudart-dev
- cuda-nvtx-dev
Expand All @@ -11,6 +12,7 @@ dependencies:
- libcurand-dev
- libcusolver-dev
- libcusparse-dev
- libcuvs
- maven
- openjdk=22.*
name: all_cuda-129_arch-aarch64
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 @@ -2,6 +2,7 @@
# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
channels:
- conda-forge
- rapidsai-nightly
dependencies:
- cuda-cudart-dev
- cuda-nvtx-dev
Expand All @@ -11,6 +12,7 @@ dependencies:
- libcurand-dev
- libcusolver-dev
- libcusparse-dev
- libcuvs
- maven
- openjdk=22.*
name: all_cuda-129_arch-x86_64
2 changes: 2 additions & 0 deletions conda/environments/all_cuda-130_arch-aarch64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
channels:
- conda-forge
- rapidsai-nightly
dependencies:
- cuda-cudart-dev
- cuda-nvtx-dev
Expand All @@ -11,6 +12,7 @@ dependencies:
- libcurand-dev
- libcusolver-dev
- libcusparse-dev
- libcuvs
- maven
- openjdk=22.*
name: all_cuda-130_arch-aarch64
2 changes: 2 additions & 0 deletions conda/environments/all_cuda-130_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
channels:
- conda-forge
- rapidsai-nightly
dependencies:
- cuda-cudart-dev
- cuda-nvtx-dev
Expand All @@ -11,6 +12,7 @@ dependencies:
- libcurand-dev
- libcusolver-dev
- libcusparse-dev
- libcuvs
- maven
- openjdk=22.*
name: all_cuda-130_arch-x86_64
2 changes: 2 additions & 0 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ files:
- java
channels:
- conda-forge
- rapidsai-nightly
dependencies:
checks:
common:
Expand Down Expand Up @@ -66,6 +67,7 @@ dependencies:
- libcurand-dev
- libcusolver-dev
- libcusparse-dev
- libcuvs
java:
common:
- output_types: conda
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<groupId>com.nvidia.cuvs</groupId>
<artifactId>cuvs-java</artifactId>
<!-- Note: This is temporary measure (artifact coming from https://maven.searchscale.com/snapshots, for now) and will get updated in subsequent PRs. -->
<version>25.8.0-4f53f-SNAPSHOT</version>
<version>25.10.0-2c0e1-SNAPSHOT</version>
</dependency>
</dependencies>

Expand Down
10 changes: 4 additions & 6 deletions src/main/java/com/nvidia/cuvs/lucene/CuVSIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package com.nvidia.cuvs.lucene;

import static com.nvidia.cuvs.lucene.CuVSVectorsReader.handleThrowable;

import com.nvidia.cuvs.BruteForceIndex;
import com.nvidia.cuvs.CagraIndex;
import com.nvidia.cuvs.HnswIndex;
Expand Down Expand Up @@ -103,16 +101,16 @@ public void close() throws IOException {
private void destroyIndices() throws IOException {
try {
if (cagraIndex != null) {
cagraIndex.destroyIndex();
cagraIndex.close();
}
if (bruteforceIndex != null) {
bruteforceIndex.destroyIndex();
bruteforceIndex.close();
}
if (hnswIndex != null) {
hnswIndex.destroyIndex();
hnswIndex.close();
}
} catch (Throwable t) {
handleThrowable(t);
Utils.handleThrowable(t);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.KnnFloatVectorQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.knn.KnnCollectorManager;
import org.apache.lucene.util.Bits;
Expand All @@ -29,8 +30,9 @@ public class CuVSKnnFloatVectorQuery extends KnnFloatVectorQuery {
private final int iTopK;
private final int searchWidth;

public CuVSKnnFloatVectorQuery(String field, float[] target, int k, int iTopK, int searchWidth) {
super(field, target, k);
public CuVSKnnFloatVectorQuery(
String field, float[] target, int k, Query filter, int iTopK, int searchWidth) {
super(field, target, k, filter);
this.iTopK = iTopK;
this.searchWidth = searchWidth;
}
Expand All @@ -46,7 +48,7 @@ protected TopDocs approximateSearch(
PerLeafCuVSKnnCollector results = new PerLeafCuVSKnnCollector(k, iTopK, searchWidth);

LeafReader reader = context.reader();
reader.searchNearestVectors(field, this.getTargetCopy(), results, null);
reader.searchNearestVectors(field, this.getTargetCopy(), results, acceptDocs);
return results.topDocs();
}
}
6 changes: 6 additions & 0 deletions src/main/java/com/nvidia/cuvs/lucene/CuVSVectorsFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ public CuVSVectorsFormat(
}

private static CuVSResources cuVSResourcesOrNull() {
try {
System.loadLibrary(
Copy link

@msarahan msarahan Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can pass arguments to loadLibrary in your Java code and not rely on LD_LIBRARY_PATH, things will probably be more robust. The hard part is that it must be recursive. Loading a conda library should load all conda dependencies, or else you get weird runtime errors. This is especially problematic with libstdc++.

One way to ensure that libstdc++ does not accidentally come from the system is to explicitly load it from the conda environment before loading any other (conda-based) libraries.

I don't know much at all about Java, but this site seemed to have some helpful alternatives to LD_LIBRARY_PATH. The more you can change just your process and not the environment, the fewer strange issues you'll have. LD_LIBRARY_PATH is a foot gun. Use it if you must, but only after exhausting other options.

"cudart"); // nocommit: this is here so as to pass CI, should goto cuvs-java
} catch (UnsatisfiedLinkError e) {
LOG.warning("Could not load CUDA runtime library: " + e.getMessage());
}
try {
resources = CuVSResources.create();
return resources;
Expand Down
23 changes: 13 additions & 10 deletions src/main/java/com/nvidia/cuvs/lucene/CuVSVectorsReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ private CuVSIndex loadCuVSIndex(FieldEntry fieldEntry) throws IOException {
}
}
} catch (Throwable t) {
handleThrowable(t);
Utils.handleThrowable(t);
}
return new CuVSIndex(cagraIndex, bruteForceIndex, hnswIndex);
}
Expand Down Expand Up @@ -367,7 +367,7 @@ public void search(String field, float[] target, KnnCollector knnCollector, Bits
try {
searchResult = cagraIndex.search(query).getResults();
} catch (Throwable t) {
handleThrowable(t);
Utils.handleThrowable(t);
}
// List expected to have only one entry because of single query "target".
assert searchResult.size() == 1;
Expand All @@ -385,7 +385,7 @@ public void search(String field, float[] target, KnnCollector knnCollector, Bits
try {
searchResult = bruteforceIndex.search(query).getResults();
} catch (Throwable t) {
handleThrowable(t);
Utils.handleThrowable(t);
}
assert searchResult.size() == 1;
result = searchResult.getFirst();
Expand Down Expand Up @@ -472,12 +472,15 @@ static void checkVersion(int versionMeta, int versionVectorData, IndexInput in)
}
}

static void handleThrowable(Throwable t) throws IOException {
switch (t) {
case IOException ioe -> throw ioe;
case Error error -> throw error;
case RuntimeException re -> throw re;
case null, default -> throw new RuntimeException("UNEXPECTED: exception type", t);
}
public FieldInfos getFieldInfos() {
return fieldInfos;
}

public IntObjectHashMap<CuVSIndex> getCuvsIndexes() {
return cuvsIndices;
}

public IntObjectHashMap<FieldEntry> getFieldEntries() {
return fields;
}
}
Loading