Skip to content

Commit d0ee7e1

Browse files
committed
Add a supported check for cuVS - can be used in more tests eventually
1 parent 5207bed commit d0ee7e1

File tree

5 files changed

+47
-28
lines changed

5 files changed

+47
-28
lines changed

qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/FullClusterRestartIT.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,11 @@ public void testSnapshotRestore() throws IOException {
10041004
if (minimumIndexVersion().before(IndexVersions.V_8_0_0) && randomBoolean()) {
10051005
settings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), randomBoolean());
10061006
}
1007-
createIndex(index, settings.build());
1007+
System.out.println("HEGO settings=" + settings);
1008+
var resp = createIndex(index, settings.build());
1009+
// Map<String, Object> snapResponse = entityAsMap(resp);
1010+
System.out.println("HEGO createIndex response=" + resp);
1011+
10081012
indexRandomDocuments(count, true, true, randomBoolean(), i -> jsonBuilder().startObject().field("field", "value").endObject());
10091013
} else {
10101014
count = countOfIndexedRandomDocuments();
@@ -1094,9 +1098,18 @@ public void testSnapshotRestore() throws IOException {
10941098
(builder, params) -> builder.field("indices", index)
10951099
);
10961100
createSnapshot.addParameter("wait_for_completion", "true");
1097-
client().performRequest(createSnapshot);
1101+
System.out.println("HEGO createSnapshot=" + createSnapshot);
1102+
1103+
var resp = client().performRequest(createSnapshot);
1104+
1105+
System.out.println("HEGO createSnapshot resp=" + resp);
1106+
1107+
System.out.println("HEGO Build.current().version()=" + Build.current().version());
1108+
System.out.println("HEGO IndexVersion.current()=" + IndexVersion.current());
1109+
System.out.println("HEGO getOldClusterVersion=" + getOldClusterVersion());
1110+
System.out.println("HEGO getOldClusterIndexVersion=" + getOldClusterIndexVersion());
10981111

1099-
checkSnapshot("old_snap", count, getOldClusterVersion(), getOldClusterIndexVersion());
1112+
checkSnapshot("old_snap", count, getOldClusterVersion(), getOldClusterIndexVersion()); // HERE
11001113
if (false == isRunningAgainstOldCluster()) {
11011114
checkSnapshot("new_snap", count, Build.current().version(), IndexVersion.current());
11021115
}
@@ -1282,6 +1295,7 @@ private void checkSnapshot(String snapshotName, int count, String tookOnVersion,
12821295
// Check the snapshot metadata, especially the version
12831296
Request listSnapshotRequest = new Request("GET", "/_snapshot/repo/" + snapshotName);
12841297
Map<String, Object> snapResponse = entityAsMap(client().performRequest(listSnapshotRequest));
1298+
System.out.println("HEGO listSnapshotRequest response=" + snapResponse);
12851299

12861300
assertEquals(singletonList(snapshotName), XContentMapValues.extractValue("snapshots.snapshot", snapResponse));
12871301
assertEquals(singletonList("SUCCESS"), XContentMapValues.extractValue("snapshots.state", snapResponse));
@@ -1290,6 +1304,7 @@ private void checkSnapshot(String snapshotName, int count, String tookOnVersion,
12901304
// which could affect the top range of the index release version
12911305
String firstReleaseVersion = tookOnIndexVersion.toReleaseVersion().split("-")[0];
12921306
assertThat(
1307+
// HERE
12931308
(Iterable<String>) XContentMapValues.extractValue("snapshots.version", snapResponse),
12941309
anyOf(
12951310
contains(tookOnVersion),

x-pack/plugin/gpu/src/main/java/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
/** Provides GPU-accelerated support for vector search. */
99
module org.elasticsearch.gpu {
10+
requires org.elasticsearch.logging;
1011
requires org.apache.lucene.core;
1112
requires org.elasticsearch.xcontent;
1213
requires org.elasticsearch.server;

x-pack/plugin/gpu/src/main/java/org/elasticsearch/xpack/gpu/codec/GPUDepsTest.java

Lines changed: 0 additions & 25 deletions
This file was deleted.

x-pack/plugin/gpu/src/main/java/org/elasticsearch/xpack/gpu/codec/GPUVectorsFormat.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
package org.elasticsearch.xpack.gpu.codec;
99

10+
import com.nvidia.cuvs.CuVSResources;
11+
1012
import org.apache.lucene.codecs.KnnVectorsFormat;
1113
import org.apache.lucene.codecs.KnnVectorsReader;
1214
import org.apache.lucene.codecs.KnnVectorsWriter;
@@ -16,6 +18,8 @@
1618
import org.apache.lucene.codecs.perfield.PerFieldKnnVectorsFormat;
1719
import org.apache.lucene.index.SegmentReadState;
1820
import org.apache.lucene.index.SegmentWriteState;
21+
import org.elasticsearch.logging.LogManager;
22+
import org.elasticsearch.logging.Logger;
1923

2024
import java.io.IOException;
2125

@@ -25,6 +29,8 @@
2529
*/
2630
public class GPUVectorsFormat extends KnnVectorsFormat {
2731

32+
private static final Logger LOG = LogManager.getLogger(GPUVectorsFormat.class);
33+
2834
public static final String NAME = "GPUVectorsFormat";
2935
public static final String GPU_IDX_EXTENSION = "gpuidx";
3036
public static final String GPU_META_EXTENSION = "mgpu";
@@ -69,4 +75,20 @@ static GPUVectorsReader getGPUReader(KnnVectorsReader vectorsReader, String fiel
6975
}
7076
return null;
7177
}
78+
79+
/** Tells whether the platform supports cuvs. */
80+
public static boolean supported() {
81+
try (var resources = CuVSResources.create()) {
82+
return true;
83+
} catch (UnsupportedOperationException uoe) {
84+
var msg = uoe.getMessage() == null ? "" : ": " + uoe.getMessage();
85+
LOG.warn("cuvs is not supported on this platform or java version" + msg);
86+
} catch (Throwable t) {
87+
if (t instanceof ExceptionInInitializerError ex) {
88+
t = ex.getCause();
89+
}
90+
LOG.warn("Exception occurred during creation of cuvs resources. " + t);
91+
}
92+
return false;
93+
}
7294
}

x-pack/plugin/gpu/src/test/java/org/elasticsearch/xpack/gpu/codec/GPUVectorsFormatTests.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.apache.lucene.tests.index.BaseKnnVectorsFormatTestCase;
1515
import org.apache.lucene.tests.util.TestUtil;
1616
import org.elasticsearch.common.logging.LogConfigurator;
17+
import org.junit.BeforeClass;
1718

1819
public class GPUVectorsFormatTests extends BaseKnnVectorsFormatTestCase {
1920

@@ -22,6 +23,11 @@ public class GPUVectorsFormatTests extends BaseKnnVectorsFormatTestCase {
2223
LogConfigurator.configureESLogging(); // native access requires logging to be initialized
2324
}
2425

26+
@BeforeClass
27+
public static void beforeClass() {
28+
assumeTrue("cuvs not supported", GPUVectorsFormat.supported());
29+
}
30+
2531
static final Codec codec = TestUtil.alwaysKnnVectorsFormat(new GPUVectorsFormat());
2632

2733
@Override

0 commit comments

Comments
 (0)