Skip to content

Commit 1a727fa

Browse files
Add int8 to KnnIndexTester
1 parent 0d51a86 commit 1a727fa

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

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

Lines changed: 14 additions & 5 deletions
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.ESGpuHnswSQVectorsFormat;
3435
import org.elasticsearch.xpack.gpu.codec.ESGpuHnswVectorsFormat;
3536

3637
import java.io.InputStream;
@@ -68,15 +69,15 @@ enum IndexType {
6869
HNSW,
6970
FLAT,
7071
IVF,
71-
GPU
72+
GPU_HNSW
7273
}
7374

7475
private static String formatIndexPath(CmdLineArgs args) {
7576
List<String> suffix = new ArrayList<>();
7677
if (args.indexType() == IndexType.FLAT) {
7778
suffix.add("flat");
78-
} else if (args.indexType() == IndexType.GPU) {
79-
suffix.add("gpu");
79+
} else if (args.indexType() == IndexType.GPU_HNSW) {
80+
suffix.add("gpu_hnsw");
8081
} else if (args.indexType() == IndexType.IVF) {
8182
suffix.add("ivf");
8283
suffix.add(Integer.toString(args.ivfClusterSize()));
@@ -94,8 +95,16 @@ static Codec createCodec(CmdLineArgs args) {
9495
final KnnVectorsFormat format;
9596
if (args.indexType() == IndexType.IVF) {
9697
format = new IVFVectorsFormat(args.ivfClusterSize());
97-
} else if (args.indexType() == IndexType.GPU) {
98-
format = new ESGpuHnswVectorsFormat();
98+
} else if (args.indexType() == IndexType.GPU_HNSW) {
99+
if (args.quantizeBits() == 32) {
100+
format = new ESGpuHnswVectorsFormat();
101+
} else if (args.quantizeBits() == 7) {
102+
format = new ESGpuHnswSQVectorsFormat();
103+
} else {
104+
throw new IllegalArgumentException(
105+
"GPU HNSW index type only supports 7 or 32 bits quantization, but got: " + args.quantizeBits()
106+
);
107+
}
99108
} else {
100109
if (args.quantizeBits() == 1) {
101110
if (args.indexType() == IndexType.FLAT) {

0 commit comments

Comments
 (0)