Skip to content

Commit 4826da6

Browse files
Enable GPU indexing test in KnnIndexTester
1 parent 2ac9d8b commit 4826da6

File tree

5 files changed

+24
-6
lines changed

5 files changed

+24
-6
lines changed

qa/vector/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ tasks.named("dependencyLicenses").configure {
2020
tasks.named('forbiddenApisMain').configure {
2121
enabled = false
2222
}
23+
repositories {
24+
mavenLocal()
25+
}
2326

2427
dependencies {
2528
api "org.apache.lucene:lucene-core:${versions.lucene}"
@@ -29,6 +32,7 @@ dependencies {
2932
implementation project(':libs:native')
3033
implementation project(':libs:logging')
3134
implementation project(':server')
35+
implementation project(':x-pack:plugin:gpu')
3236
}
3337
/**
3438
* Task to run the KnnIndexTester with the provided parameters.
@@ -42,6 +46,9 @@ tasks.register("checkVec", JavaExec) {
4246
systemProperty "es.logger.out", "console"
4347
systemProperty "es.logger.level", "INFO" // Change to DEBUG if needed
4448
systemProperty 'es.nativelibs.path', TestUtil.getTestLibraryPath(file("../../libs/native/libraries/build/platform/").toString())
49+
javaLauncher = project.javaToolchains.launcherFor {
50+
languageVersion = JavaLanguageVersion.of(24)
51+
}
4552
jvmArgs '-Xms4g', '-Xmx4g', '-Djava.util.concurrent.ForkJoinPool.common.parallelism=8', '-XX:+UnlockDiagnosticVMOptions', '-XX:+DebugNonSafepoints', '-XX:+HeapDumpOnOutOfMemoryError'
4653
if (buildParams.getRuntimeJavaVersion().map { it.majorVersion.toInteger() }.get() >= 21) {
4754
jvmArgs '--add-modules=jdk.incubator.vector', '--enable-native-access=ALL-UNNAMED'

qa/vector/src/main/java/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@
1818
requires org.elasticsearch.logging;
1919
requires java.management;
2020
requires jdk.management;
21+
requires org.elasticsearch.gpu;
2122
}

qa/vector/src/main/java/org/elasticsearch/test/knn/KnnIndexTester.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.elasticsearch.xcontent.XContentParser;
3232
import org.elasticsearch.xcontent.XContentParserConfiguration;
3333
import org.elasticsearch.xcontent.XContentType;
34+
import org.elasticsearch.xpack.gpu.codec.GPUVectorsFormat;
3435

3536
import java.io.InputStream;
3637
import java.lang.management.ThreadInfo;
@@ -66,13 +67,16 @@ public class KnnIndexTester {
6667
enum IndexType {
6768
HNSW,
6869
FLAT,
69-
IVF
70+
IVF,
71+
GPU
7072
}
7173

7274
private static String formatIndexPath(CmdLineArgs args) {
7375
List<String> suffix = new ArrayList<>();
7476
if (args.indexType() == IndexType.FLAT) {
7577
suffix.add("flat");
78+
} else if (args.indexType() == IndexType.GPU) {
79+
suffix.add("gpu");
7680
} else if (args.indexType() == IndexType.IVF) {
7781
suffix.add("ivf");
7882
suffix.add(Integer.toString(args.ivfClusterSize()));
@@ -90,6 +94,8 @@ static Codec createCodec(CmdLineArgs args) {
9094
final KnnVectorsFormat format;
9195
if (args.indexType() == IndexType.IVF) {
9296
format = new IVFVectorsFormat(args.ivfClusterSize());
97+
} else if (args.indexType() == IndexType.GPU) {
98+
format = new GPUVectorsFormat();
9399
} else {
94100
if (args.quantizeBits() == 1) {
95101
if (args.indexType() == IndexType.FLAT) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@
1414
requires org.elasticsearch.base;
1515
requires com.nvidia.cuvs;
1616

17+
exports org.elasticsearch.xpack.gpu.codec;
18+
1719
provides org.apache.lucene.codecs.KnnVectorsFormat with org.elasticsearch.xpack.gpu.codec.GPUVectorsFormat;
1820
}

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,13 @@ public class GPUVectorsFormat extends KnnVectorsFormat {
3232
private static final Logger LOG = LogManager.getLogger(GPUVectorsFormat.class);
3333

3434
public static final String NAME = "GPUVectorsFormat";
35-
public static final String GPU_IDX_EXTENSION = "gpuidx";
36-
public static final String GPU_META_EXTENSION = "mgpu";
3735
public static final int VERSION_START = 0;
3836

3937
static final String LUCENE99_HNSW_META_CODEC_NAME = "Lucene99HnswVectorsFormatMeta";
4038
static final String LUCENE99_HNSW_VECTOR_INDEX_CODEC_NAME = "Lucene99HnswVectorsFormatIndex";
4139
static final String LUCENE99_HNSW_META_EXTENSION = "vem";
4240
static final String LUCENE99_HNSW_VECTOR_INDEX_EXTENSION = "vex";
4341
static final int LUCENE99_VERSION_CURRENT = VERSION_START;
44-
public static final int VERSION_CURRENT = VERSION_START;
4542

4643
static final int DEFAULT_MAX_CONN = 16;
4744
static final int DEFAULT_BEAM_WIDTH = 100;
@@ -91,8 +88,13 @@ public static CuVSResources cuVSResourcesOrNull() {
9188
var resources = CuVSResources.create();
9289
return resources;
9390
} catch (UnsupportedOperationException uoe) {
94-
var msg = uoe.getMessage() == null ? "" : ": " + uoe.getMessage();
95-
LOG.warn("GPU based vector search is not supported on this platform or java version" + msg);
91+
String msg = "";
92+
if (uoe.getMessage() == null) {
93+
msg = "Runtime Java version: " + Runtime.version().feature();
94+
} else {
95+
msg = ": " + uoe.getMessage();
96+
}
97+
LOG.warn("GPU based vector search is not supported on this platform or java version; " + msg);
9698
} catch (Throwable t) {
9799
if (t instanceof ExceptionInInitializerError ex) {
98100
t = ex.getCause();

0 commit comments

Comments
 (0)