Skip to content

Commit caf1ea6

Browse files
Revert "Adjust default params for Cagra Index build (elastic#136650) (elastic#136710)"
Bad recall for high dims data such as openai_vector This reverts commit 8b3474e.
1 parent c62e411 commit caf1ea6

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
@@ -92,21 +92,23 @@ private static KnnVectorsFormat getVectorsFormat(DenseVectorFieldMapper.DenseVec
9292
if (indexOptions.getType() == DenseVectorFieldMapper.VectorIndexType.HNSW) {
9393
DenseVectorFieldMapper.HnswIndexOptions hnswIndexOptions = (DenseVectorFieldMapper.HnswIndexOptions) indexOptions;
9494
int efConstruction = hnswIndexOptions.efConstruction();
95-
int m = hnswIndexOptions.m();
9695
if (efConstruction == HnswGraphBuilder.DEFAULT_BEAM_WIDTH) {
97-
m = ES92GpuHnswVectorsFormat.DEFAULT_MAX_CONN;
98-
efConstruction = ES92GpuHnswVectorsFormat.DEFAULT_BEAM_WIDTH; // default value for GPU graph construction
96+
efConstruction = ES92GpuHnswVectorsFormat.DEFAULT_BEAM_WIDTH; // default value for GPU graph construction is 128
9997
}
100-
return new ES92GpuHnswVectorsFormat(m, efConstruction);
98+
return new ES92GpuHnswVectorsFormat(hnswIndexOptions.m(), efConstruction);
10199
} else if (indexOptions.getType() == DenseVectorFieldMapper.VectorIndexType.INT8_HNSW) {
102100
DenseVectorFieldMapper.Int8HnswIndexOptions int8HnswIndexOptions = (DenseVectorFieldMapper.Int8HnswIndexOptions) indexOptions;
103101
int efConstruction = int8HnswIndexOptions.efConstruction();
104-
int m = int8HnswIndexOptions.m();
105102
if (efConstruction == HnswGraphBuilder.DEFAULT_BEAM_WIDTH) {
106-
m = ES92GpuHnswVectorsFormat.DEFAULT_MAX_CONN;
107-
efConstruction = ES92GpuHnswVectorsFormat.DEFAULT_BEAM_WIDTH; // default value for GPU graph construction
103+
efConstruction = ES92GpuHnswVectorsFormat.DEFAULT_BEAM_WIDTH; // default value for GPU graph construction is 128
108104
}
109-
return new ES92GpuHnswSQVectorsFormat(m, efConstruction, int8HnswIndexOptions.confidenceInterval(), 7, false);
105+
return new ES92GpuHnswSQVectorsFormat(
106+
int8HnswIndexOptions.m(),
107+
efConstruction,
108+
int8HnswIndexOptions.confidenceInterval(),
109+
7,
110+
false
111+
);
110112
} else {
111113
throw new IllegalArgumentException(
112114
"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)