Skip to content

Commit 7e0cc3d

Browse files
Rename GpuVectorsFormat to EsGpuHnswVectorsFormat
We want to introduce a new int8 format for GPU, with its anticipation rename GpuVectorsFormat to EsGpuHnswVectorsFormat
1 parent f452dfc commit 7e0cc3d

File tree

8 files changed

+32
-30
lines changed

8 files changed

+32
-30
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +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;
34+
import org.elasticsearch.xpack.gpu.codec.ESGpuHnswVectorsFormat;
3535

3636
import java.io.InputStream;
3737
import java.lang.management.ThreadInfo;
@@ -95,7 +95,7 @@ static Codec createCodec(CmdLineArgs args) {
9595
if (args.indexType() == IndexType.IVF) {
9696
format = new IVFVectorsFormat(args.ivfClusterSize());
9797
} else if (args.indexType() == IndexType.GPU) {
98-
format = new GPUVectorsFormat();
98+
format = new ESGpuHnswVectorsFormat();
9999
} else {
100100
if (args.quantizeBits() == 1) {
101101
if (args.indexType() == IndexType.FLAT) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616

1717
exports org.elasticsearch.xpack.gpu.codec;
1818

19-
provides org.apache.lucene.codecs.KnnVectorsFormat with org.elasticsearch.xpack.gpu.codec.GPUVectorsFormat;
19+
provides org.apache.lucene.codecs.KnnVectorsFormat with org.elasticsearch.xpack.gpu.codec.ESGpuHnswVectorsFormat;
2020
provides org.elasticsearch.features.FeatureSpecification with org.elasticsearch.xpack.gpu.GPUFeatures;
2121
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import org.elasticsearch.index.mapper.vectors.VectorsFormatProvider;
1515
import org.elasticsearch.plugins.MapperPlugin;
1616
import org.elasticsearch.plugins.Plugin;
17-
import org.elasticsearch.xpack.gpu.codec.GPUVectorsFormat;
17+
import org.elasticsearch.xpack.gpu.codec.ESGpuHnswVectorsFormat;
1818

1919
public class GPUPlugin extends Plugin implements MapperPlugin {
2020

@@ -60,9 +60,9 @@ private static KnnVectorsFormat getVectorsFormat(DenseVectorFieldMapper.DenseVec
6060
DenseVectorFieldMapper.HnswIndexOptions hnswIndexOptions = (DenseVectorFieldMapper.HnswIndexOptions) indexOptions;
6161
int efConstruction = hnswIndexOptions.efConstruction();
6262
if (efConstruction == HnswGraphBuilder.DEFAULT_BEAM_WIDTH) {
63-
efConstruction = GPUVectorsFormat.DEFAULT_BEAM_WIDTH; // default value for GPU graph construction is 128
63+
efConstruction = ESGpuHnswVectorsFormat.DEFAULT_BEAM_WIDTH; // default value for GPU graph construction is 128
6464
}
65-
return new GPUVectorsFormat(hnswIndexOptions.m(), efConstruction);
65+
return new ESGpuHnswVectorsFormat(hnswIndexOptions.m(), efConstruction);
6666
} else {
6767
throw new IllegalArgumentException(
6868
"GPU vector indexing is not supported on this vector type: [" + indexOptions.getType() + "]"

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@
1919

2020
import java.io.IOException;
2121

22+
import static org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper.MAX_DIMS_COUNT;
23+
2224
/**
2325
* Codec format for GPU-accelerated vector indexes. This format is designed to
2426
* leverage GPU processing capabilities for vector search operations.
2527
*/
26-
public class GPUVectorsFormat extends KnnVectorsFormat {
27-
public static final String NAME = "GPUVectorsFormat";
28+
public class ESGpuHnswVectorsFormat extends KnnVectorsFormat {
29+
public static final String NAME = "ESGpuHnswVectorsFormat";
2830
public static final int VERSION_START = 0;
2931

3032
static final String LUCENE99_HNSW_META_CODEC_NAME = "Lucene99HnswVectorsFormatMeta";
@@ -47,15 +49,15 @@ public class GPUVectorsFormat extends KnnVectorsFormat {
4749
private final int beamWidth;
4850
final CuVSResourceManager cuVSResourceManager;
4951

50-
public GPUVectorsFormat() {
52+
public ESGpuHnswVectorsFormat() {
5153
this(CuVSResourceManager.pooling(), DEFAULT_MAX_CONN, DEFAULT_BEAM_WIDTH);
5254
}
5355

54-
public GPUVectorsFormat(int maxConn, int beamWidth) {
56+
public ESGpuHnswVectorsFormat(int maxConn, int beamWidth) {
5557
this(CuVSResourceManager.pooling(), maxConn, beamWidth);
5658
};
5759

58-
public GPUVectorsFormat(CuVSResourceManager cuVSResourceManager, int maxConn, int beamWidth) {
60+
public ESGpuHnswVectorsFormat(CuVSResourceManager cuVSResourceManager, int maxConn, int beamWidth) {
5961
super(NAME);
6062
this.cuVSResourceManager = cuVSResourceManager;
6163
this.maxConn = maxConn;
@@ -64,7 +66,7 @@ public GPUVectorsFormat(CuVSResourceManager cuVSResourceManager, int maxConn, in
6466

6567
@Override
6668
public KnnVectorsWriter fieldsWriter(SegmentWriteState state) throws IOException {
67-
return new GPUToHNSWVectorsWriter(cuVSResourceManager, state, maxConn, beamWidth, flatVectorsFormat.fieldsWriter(state));
69+
return new ESGpuHnswVectorsWriter(cuVSResourceManager, state, maxConn, beamWidth, flatVectorsFormat.fieldsWriter(state));
6870
}
6971

7072
@Override
@@ -74,7 +76,7 @@ public KnnVectorsReader fieldsReader(SegmentReadState state) throws IOException
7476

7577
@Override
7678
public int getMaxDimensions(String fieldName) {
77-
return 4096;
79+
return MAX_DIMS_COUNT;
7880
}
7981

8082
@Override
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,20 @@
5050

5151
import static org.apache.lucene.codecs.lucene99.Lucene99HnswVectorsReader.SIMILARITY_FUNCTIONS;
5252
import static org.apache.lucene.search.DocIdSetIterator.NO_MORE_DOCS;
53-
import static org.elasticsearch.xpack.gpu.codec.GPUVectorsFormat.LUCENE99_HNSW_META_CODEC_NAME;
54-
import static org.elasticsearch.xpack.gpu.codec.GPUVectorsFormat.LUCENE99_HNSW_META_EXTENSION;
55-
import static org.elasticsearch.xpack.gpu.codec.GPUVectorsFormat.LUCENE99_HNSW_VECTOR_INDEX_CODEC_NAME;
56-
import static org.elasticsearch.xpack.gpu.codec.GPUVectorsFormat.LUCENE99_HNSW_VECTOR_INDEX_EXTENSION;
57-
import static org.elasticsearch.xpack.gpu.codec.GPUVectorsFormat.LUCENE99_VERSION_CURRENT;
58-
import static org.elasticsearch.xpack.gpu.codec.GPUVectorsFormat.MIN_NUM_VECTORS_FOR_GPU_BUILD;
53+
import static org.elasticsearch.xpack.gpu.codec.ESGpuHnswVectorsFormat.LUCENE99_HNSW_META_CODEC_NAME;
54+
import static org.elasticsearch.xpack.gpu.codec.ESGpuHnswVectorsFormat.LUCENE99_HNSW_META_EXTENSION;
55+
import static org.elasticsearch.xpack.gpu.codec.ESGpuHnswVectorsFormat.LUCENE99_HNSW_VECTOR_INDEX_CODEC_NAME;
56+
import static org.elasticsearch.xpack.gpu.codec.ESGpuHnswVectorsFormat.LUCENE99_HNSW_VECTOR_INDEX_EXTENSION;
57+
import static org.elasticsearch.xpack.gpu.codec.ESGpuHnswVectorsFormat.LUCENE99_VERSION_CURRENT;
58+
import static org.elasticsearch.xpack.gpu.codec.ESGpuHnswVectorsFormat.MIN_NUM_VECTORS_FOR_GPU_BUILD;
5959

6060
/**
6161
* Writer that builds a Nvidia Carga Graph on GPU and than writes it into the Lucene99 HNSW format,
6262
* so that it can be searched on CPU with Lucene99HNSWVectorReader.
6363
*/
64-
final class GPUToHNSWVectorsWriter extends KnnVectorsWriter {
65-
private static final Logger logger = LogManager.getLogger(GPUToHNSWVectorsWriter.class);
66-
private static final long SHALLOW_RAM_BYTES_USED = RamUsageEstimator.shallowSizeOfInstance(GPUToHNSWVectorsWriter.class);
64+
final class ESGpuHnswVectorsWriter extends KnnVectorsWriter {
65+
private static final Logger logger = LogManager.getLogger(ESGpuHnswVectorsWriter.class);
66+
private static final long SHALLOW_RAM_BYTES_USED = RamUsageEstimator.shallowSizeOfInstance(ESGpuHnswVectorsWriter.class);
6767
private static final int LUCENE99_HNSW_DIRECT_MONOTONIC_BLOCK_SHIFT = 16;
6868

6969
private final CuVSResourceManager cuVSResourceManager;
@@ -76,7 +76,7 @@ final class GPUToHNSWVectorsWriter extends KnnVectorsWriter {
7676
private final List<FieldWriter> fields = new ArrayList<>();
7777
private boolean finished;
7878

79-
GPUToHNSWVectorsWriter(
79+
ESGpuHnswVectorsWriter(
8080
CuVSResourceManager cuVSResourceManager,
8181
SegmentWriteState state,
8282
int M,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11

2-
org.elasticsearch.xpack.gpu.codec.GPUVectorsFormat
2+
org.elasticsearch.xpack.gpu.codec.ESGpuHnswVectorsFormat

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import org.elasticsearch.xpack.gpu.GPUSupport;
1818
import org.junit.BeforeClass;
1919

20-
public class GPUVectorsFormatTests extends BaseKnnVectorsFormatTestCase {
20+
public class ESGpuHnswVectorsFormatTests extends BaseKnnVectorsFormatTestCase {
2121

2222
static {
2323
LogConfigurator.loadLog4jPlugins();
@@ -29,7 +29,7 @@ public static void beforeClass() {
2929
assumeTrue("cuvs not supported", GPUSupport.isSupported(false));
3030
}
3131

32-
static final Codec codec = TestUtil.alwaysKnnVectorsFormat(new GPUVectorsFormat());
32+
static final Codec codec = TestUtil.alwaysKnnVectorsFormat(new ESGpuHnswVectorsFormat());
3333

3434
@Override
3535
protected Codec getCodec() {
@@ -80,10 +80,10 @@ public void testToString() {
8080
FilterCodec customCodec = new FilterCodec("foo", Codec.getDefault()) {
8181
@Override
8282
public KnnVectorsFormat knnVectorsFormat() {
83-
return new GPUVectorsFormat();
83+
return new ESGpuHnswVectorsFormat();
8484
}
8585
};
86-
String expectedPattern = "GPUVectorsFormat(maxConn=16, beamWidth=128, flatVectorFormat=Lucene99FlatVectorsFormat)";
86+
String expectedPattern = "ESGpuHnswVectorsFormat(maxConn=16, beamWidth=128, flatVectorFormat=Lucene99FlatVectorsFormat)";
8787
assertEquals(expectedPattern, customCodec.knnVectorsFormat().toString());
8888
}
8989

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected Collection<Plugin> getPlugins() {
3939
return Collections.singletonList(plugin);
4040
}
4141

42-
public void testKnnGPUVectorsFormat() throws IOException {
42+
public void testKnnESGPUHnswVectorsFormat() throws IOException {
4343
final int dims = randomIntBetween(128, 4096);
4444
MapperService mapperService = createMapperService(fieldMapping(b -> {
4545
b.field("type", "dense_vector");
@@ -63,7 +63,7 @@ public void testKnnGPUVectorsFormat() throws IOException {
6363
assertThat(codec, instanceOf(LegacyPerFieldMapperCodec.class));
6464
knnVectorsFormat = ((LegacyPerFieldMapperCodec) codec).getKnnVectorsFormatForField("field");
6565
}
66-
String expectedString = "GPUVectorsFormat()";
66+
String expectedString = "ESGpuHnswVectorsFormat(maxConn=16, beamWidth=128, flatVectorFormat=Lucene99FlatVectorsFormat)";
6767
assertEquals(expectedString, knnVectorsFormat.toString());
6868
}
6969
}

0 commit comments

Comments
 (0)