Skip to content

Commit 3b336ac

Browse files
Revert "Adjust default params for Cagra Index build (#136650)"
Recall is very bad on high dimensional data:openai_vector This reverts commit 7c0d2eb.
1 parent d9d0650 commit 3b336ac

File tree

5 files changed

+14
-18
lines changed

5 files changed

+14
-18
lines changed

docs/changelog/136650.yaml

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

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,21 +94,23 @@ private static KnnVectorsFormat getVectorsFormat(DenseVectorFieldMapper.DenseVec
9494
if (indexOptions.getType() == DenseVectorFieldMapper.VectorIndexType.HNSW) {
9595
DenseVectorFieldMapper.HnswIndexOptions hnswIndexOptions = (DenseVectorFieldMapper.HnswIndexOptions) indexOptions;
9696
int efConstruction = hnswIndexOptions.efConstruction();
97-
int m = hnswIndexOptions.m();
9897
if (efConstruction == HnswGraphBuilder.DEFAULT_BEAM_WIDTH) {
99-
m = ES92GpuHnswVectorsFormat.DEFAULT_MAX_CONN;
100-
efConstruction = ES92GpuHnswVectorsFormat.DEFAULT_BEAM_WIDTH; // default value for GPU graph construction
98+
efConstruction = ES92GpuHnswVectorsFormat.DEFAULT_BEAM_WIDTH; // default value for GPU graph construction is 128
10199
}
102-
return new ES92GpuHnswVectorsFormat(m, efConstruction);
100+
return new ES92GpuHnswVectorsFormat(hnswIndexOptions.m(), efConstruction);
103101
} else if (indexOptions.getType() == DenseVectorFieldMapper.VectorIndexType.INT8_HNSW) {
104102
DenseVectorFieldMapper.Int8HnswIndexOptions int8HnswIndexOptions = (DenseVectorFieldMapper.Int8HnswIndexOptions) indexOptions;
105103
int efConstruction = int8HnswIndexOptions.efConstruction();
106-
int m = int8HnswIndexOptions.m();
107104
if (efConstruction == HnswGraphBuilder.DEFAULT_BEAM_WIDTH) {
108-
m = ES92GpuHnswVectorsFormat.DEFAULT_MAX_CONN;
109-
efConstruction = ES92GpuHnswVectorsFormat.DEFAULT_BEAM_WIDTH; // default value for GPU graph construction
105+
efConstruction = ES92GpuHnswVectorsFormat.DEFAULT_BEAM_WIDTH; // default value for GPU graph construction is 128
110106
}
111-
return new ES92GpuHnswSQVectorsFormat(m, efConstruction, int8HnswIndexOptions.confidenceInterval(), 7, false);
107+
return new ES92GpuHnswSQVectorsFormat(
108+
int8HnswIndexOptions.m(),
109+
efConstruction,
110+
int8HnswIndexOptions.confidenceInterval(),
111+
7,
112+
false
113+
);
112114
} else {
113115
throw new IllegalArgumentException(
114116
"GPU vector indexing is not supported on this vector type: [" + indexOptions.getType() + "]"

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public class ES92GpuHnswVectorsFormat extends KnnVectorsFormat {
3636
static final String LUCENE99_HNSW_VECTOR_INDEX_EXTENSION = "vex";
3737
static final int LUCENE99_VERSION_CURRENT = VERSION_GROUPVARINT;
3838

39-
public static final int DEFAULT_MAX_CONN = 10; // graph degree
40-
public static final int DEFAULT_BEAM_WIDTH = 16; // intermediate graph degree
39+
static final int DEFAULT_MAX_CONN = 16; // graph degree
40+
public static final int DEFAULT_BEAM_WIDTH = 128; // intermediate graph degree
4141
static final int MIN_NUM_VECTORS_FOR_GPU_BUILD = 2;
4242

4343
private static final FlatVectorsFormat flatVectorsFormat = new Lucene99FlatVectorsFormat(

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@ private CagraIndex buildGPUIndex(
323323
.withCagraGraphBuildAlgo(CagraIndexParams.CagraGraphBuildAlgo.NN_DESCENT)
324324
.withGraphDegree(M)
325325
.withIntermediateGraphDegree(beamWidth)
326-
.withNNDescentNumIterations(5)
327326
.withMetric(distanceType)
328327
.build();
329328

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
@@ -44,7 +44,7 @@ public void testKnnVectorsFormat() throws IOException {
4444
// TODO improve test with custom parameters
4545
KnnVectorsFormat knnVectorsFormat = getKnnVectorsFormat("hnsw");
4646
String expectedStr = "Lucene99HnswVectorsFormat(name=Lucene99HnswVectorsFormat, "
47-
+ "maxConn=10, beamWidth=16, flatVectorFormat=Lucene99FlatVectorsFormat)";
47+
+ "maxConn=16, beamWidth=128, flatVectorFormat=Lucene99FlatVectorsFormat)";
4848
assertEquals(expectedStr, knnVectorsFormat.toString());
4949
}
5050

@@ -53,7 +53,7 @@ public void testKnnQuantizedHNSWVectorsFormat() throws IOException {
5353
// TOD improve the test with custom parameters
5454
KnnVectorsFormat knnVectorsFormat = getKnnVectorsFormat("int8_hnsw");
5555
String expectedStr = "Lucene99HnswVectorsFormat(name=Lucene99HnswVectorsFormat, "
56-
+ "maxConn=10, beamWidth=16, flatVectorFormat=ES814ScalarQuantizedVectorsFormat";
56+
+ "maxConn=16, beamWidth=128, flatVectorFormat=ES814ScalarQuantizedVectorsFormat";
5757
assertTrue(knnVectorsFormat.toString().startsWith(expectedStr));
5858
}
5959

0 commit comments

Comments
 (0)