Skip to content

Commit cc3c2eb

Browse files
authored
[GPU] Move gpu core code (support + codec) to :libs (elastic#138273) (elastic#138411)
Split the gpu plugin code into a support lib (GPU/cuvs interfacing classes + codecs) and a lightweight plugin.
1 parent ba1448e commit cc3c2eb

File tree

42 files changed

+279
-174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+279
-174
lines changed

libs/gpu-codec/build.gradle

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
apply plugin: 'elasticsearch.build'
11+
apply plugin: 'elasticsearch.mrjar'
12+
13+
dependencies {
14+
api project(':libs:core')
15+
api project(":libs:x-content")
16+
api project(':libs:logging')
17+
compileOnly "org.apache.lucene:lucene-core:${versions.lucene}"
18+
compileOnly project(':server')
19+
implementation('com.nvidia.cuvs:cuvs-java:25.10.0')
20+
21+
testImplementation(project(":test:framework")) {
22+
exclude group: 'org.elasticsearch', module: 'gpu-codec'
23+
}
24+
testImplementation "junit:junit:${versions.junit}"
25+
}
26+
27+
tasks.named('forbiddenApisMain').configure {
28+
replaceSignatureFiles 'jdk-signatures'
29+
}
30+
File renamed without changes.
File renamed without changes.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
/** Provides GPU-accelerated support for vector indexing. */
11+
module org.elasticsearch.gpu {
12+
requires org.elasticsearch.logging;
13+
requires org.apache.lucene.core;
14+
requires org.elasticsearch.xcontent;
15+
requires org.elasticsearch.base;
16+
requires com.nvidia.cuvs;
17+
requires org.elasticsearch.server;
18+
19+
exports org.elasticsearch.gpu;
20+
exports org.elasticsearch.gpu.codec;
21+
22+
provides org.apache.lucene.codecs.KnnVectorsFormat
23+
with
24+
org.elasticsearch.gpu.codec.ES92GpuHnswVectorsFormat,
25+
org.elasticsearch.gpu.codec.ES92GpuHnswSQVectorsFormat;
26+
}

x-pack/plugin/gpu/src/main/java/org/elasticsearch/xpack/gpu/GPUSupport.java renamed to libs/gpu-codec/src/main/java/org/elasticsearch/gpu/GPUSupport.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
/*
22
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3-
* or more contributor license agreements. Licensed under the Elastic License
4-
* 2.0; you may not use this file except in compliance with the Elastic License
5-
* 2.0.
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
68
*/
79

8-
package org.elasticsearch.xpack.gpu;
10+
package org.elasticsearch.gpu;
911

1012
import com.nvidia.cuvs.CuVSResources;
1113
import com.nvidia.cuvs.GPUInfoProvider;

x-pack/plugin/gpu/src/main/java/org/elasticsearch/xpack/gpu/codec/CuVSIvfPqParamsFactory.java renamed to libs/gpu-codec/src/main/java/org/elasticsearch/gpu/codec/CuVSIvfPqParamsFactory.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
/*
22
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3-
* or more contributor license agreements. Licensed under the Elastic License
4-
* 2.0; you may not use this file except in compliance with the Elastic License
5-
* 2.0.
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
68
*/
79

8-
package org.elasticsearch.xpack.gpu.codec;
10+
package org.elasticsearch.gpu.codec;
911

1012
import com.nvidia.cuvs.CagraIndexParams;
1113
import com.nvidia.cuvs.CuVSIvfPqIndexParams;
@@ -24,7 +26,7 @@
2426
*
2527
* TODO: Remove this class when cuvs 25.12 is available and use functions from there directly.
2628
*/
27-
public class CuVSIvfPqParamsFactory {
29+
class CuVSIvfPqParamsFactory {
2830

2931
/**
3032
* Creates {@link CuVSIvfPqParams} with automatically calculated parameters based on the
@@ -40,7 +42,7 @@ public class CuVSIvfPqParamsFactory {
4042
* @return a {@link CuVSIvfPqParams} instance with calculated parameters
4143
* @throws IllegalArgumentException if dimensions are invalid
4244
*/
43-
public static CuVSIvfPqParams create(int numVectors, int dims, CagraIndexParams.CuvsDistanceType distanceType, int efConstruction) {
45+
static CuVSIvfPqParams create(int numVectors, int dims, CagraIndexParams.CuvsDistanceType distanceType, int efConstruction) {
4446
long nRows = numVectors;
4547
long nFeatures = dims;
4648

@@ -65,7 +67,7 @@ public static CuVSIvfPqParams create(int numVectors, int dims, CagraIndexParams.
6567
* @return a {@link CuVSIvfPqParams} instance with calculated parameters
6668
* @throws IllegalArgumentException if dimensions are invalid
6769
*/
68-
public static CuVSIvfPqParams createFromDimensions(
70+
static CuVSIvfPqParams createFromDimensions(
6971
long nRows,
7072
long nFeatures,
7173
CagraIndexParams.CuvsDistanceType distanceType,

x-pack/plugin/gpu/src/main/java/org/elasticsearch/xpack/gpu/codec/CuVSResourceManager.java renamed to libs/gpu-codec/src/main/java/org/elasticsearch/gpu/codec/CuVSResourceManager.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
/*
22
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3-
* or more contributor license agreements. Licensed under the Elastic License
4-
* 2.0; you may not use this file except in compliance with the Elastic License
5-
* 2.0.
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
68
*/
79

8-
package org.elasticsearch.xpack.gpu.codec;
10+
package org.elasticsearch.gpu.codec;
911

1012
import com.nvidia.cuvs.CagraIndexParams;
1113
import com.nvidia.cuvs.CuVSMatrix;
1214
import com.nvidia.cuvs.CuVSResources;
1315
import com.nvidia.cuvs.spi.CuVSProvider;
1416

1517
import org.elasticsearch.core.Strings;
18+
import org.elasticsearch.gpu.GPUSupport;
1619
import org.elasticsearch.logging.LogManager;
1720
import org.elasticsearch.logging.Logger;
18-
import org.elasticsearch.xpack.gpu.GPUSupport;
1921

2022
import java.nio.file.Path;
2123
import java.util.Objects;

x-pack/plugin/gpu/src/main/java/org/elasticsearch/xpack/gpu/codec/DatasetUtils.java renamed to libs/gpu-codec/src/main/java/org/elasticsearch/gpu/codec/DatasetUtils.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
/*
22
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3-
* or more contributor license agreements. Licensed under the Elastic License
4-
* 2.0; you may not use this file except in compliance with the Elastic License
5-
* 2.0.
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
68
*/
79

8-
package org.elasticsearch.xpack.gpu.codec;
10+
package org.elasticsearch.gpu.codec;
911

1012
import com.nvidia.cuvs.CuVSMatrix;
1113

1214
import org.apache.lucene.store.MemorySegmentAccessInput;
1315

1416
import java.io.IOException;
1517

16-
public interface DatasetUtils {
18+
interface DatasetUtils {
1719

1820
static DatasetUtils getInstance() {
1921
return DatasetUtilsImpl.getInstance();

x-pack/plugin/gpu/src/main/java/org/elasticsearch/xpack/gpu/codec/DatasetUtilsImpl.java renamed to libs/gpu-codec/src/main/java/org/elasticsearch/gpu/codec/DatasetUtilsImpl.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
/*
22
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3-
* or more contributor license agreements. Licensed under the Elastic License
4-
* 2.0; you may not use this file except in compliance with the Elastic License
5-
* 2.0.
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
68
*/
79

8-
package org.elasticsearch.xpack.gpu.codec;
10+
package org.elasticsearch.gpu.codec;
911

1012
import com.nvidia.cuvs.CuVSMatrix;
1113
import com.nvidia.cuvs.spi.CuVSProvider;
@@ -16,7 +18,7 @@
1618
import java.lang.foreign.MemorySegment;
1719
import java.lang.invoke.MethodHandle;
1820

19-
public class DatasetUtilsImpl implements DatasetUtils {
21+
class DatasetUtilsImpl implements DatasetUtils {
2022

2123
private static final DatasetUtils INSTANCE = new DatasetUtilsImpl();
2224

0 commit comments

Comments
 (0)