3131import org .elasticsearch .xcontent .XContentParser ;
3232import org .elasticsearch .xcontent .XContentParserConfiguration ;
3333import org .elasticsearch .xcontent .XContentType ;
34+ import org .elasticsearch .xpack .gpu .codec .ESGpuHnswSQVectorsFormat ;
3435import org .elasticsearch .xpack .gpu .codec .ESGpuHnswVectorsFormat ;
3536
3637import 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