-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:add new gpu index:GPU_BRUTE_FORCE and limit gpu index metric type (
#29590) issue: #29230 this pr do these things: 1. add gpu brute force; 2. limit gpu index only support l2 / ip; Signed-off-by: cqy123456 <qianya.cheng@zilliz.com>
- Loading branch information
Showing
10 changed files
with
281 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package indexparamcheck | ||
|
||
import "fmt" | ||
|
||
type raftBruteForceChecker struct { | ||
floatVectorBaseChecker | ||
} | ||
|
||
// raftBrustForceChecker checks if a Brute_Force index can be built. | ||
func (c raftBruteForceChecker) CheckTrain(params map[string]string) error { | ||
if err := c.floatVectorBaseChecker.CheckTrain(params); err != nil { | ||
return err | ||
} | ||
if !CheckStrByValues(params, Metric, RaftMetrics) { | ||
return fmt.Errorf("metric type not found or not supported, supported: %v", RaftMetrics) | ||
} | ||
return nil | ||
} | ||
|
||
func newRaftBruteForceChecker() IndexChecker { | ||
return &raftBruteForceChecker{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package indexparamcheck | ||
|
||
import ( | ||
"strconv" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/milvus-io/milvus/pkg/util/metric" | ||
) | ||
|
||
func Test_raftbfChecker_CheckTrain(t *testing.T) { | ||
p1 := map[string]string{ | ||
DIM: strconv.Itoa(128), | ||
Metric: metric.L2, | ||
} | ||
p2 := map[string]string{ | ||
DIM: strconv.Itoa(128), | ||
Metric: metric.IP, | ||
} | ||
p3 := map[string]string{ | ||
DIM: strconv.Itoa(128), | ||
Metric: metric.COSINE, | ||
} | ||
|
||
p4 := map[string]string{ | ||
DIM: strconv.Itoa(128), | ||
Metric: metric.HAMMING, | ||
} | ||
p5 := map[string]string{ | ||
DIM: strconv.Itoa(128), | ||
Metric: metric.JACCARD, | ||
} | ||
p6 := map[string]string{ | ||
DIM: strconv.Itoa(128), | ||
Metric: metric.SUBSTRUCTURE, | ||
} | ||
p7 := map[string]string{ | ||
DIM: strconv.Itoa(128), | ||
Metric: metric.SUPERSTRUCTURE, | ||
} | ||
cases := []struct { | ||
params map[string]string | ||
errIsNil bool | ||
}{ | ||
{p1, true}, | ||
{p2, true}, | ||
{p3, false}, | ||
{p4, false}, | ||
{p5, false}, | ||
{p6, false}, | ||
{p7, false}, | ||
} | ||
|
||
c := newRaftBruteForceChecker() | ||
for _, test := range cases { | ||
err := c.CheckTrain(test.params) | ||
if test.errIsNil { | ||
assert.NoError(t, err) | ||
} else { | ||
assert.Error(t, err) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package indexparamcheck | ||
|
||
import "fmt" | ||
|
||
// raftIVFChecker checks if a RAFT_IVF_Flat index can be built. | ||
type raftIVFFlatChecker struct { | ||
ivfBaseChecker | ||
} | ||
|
||
// CheckTrain checks if ivf-flat index can be built with the specific index parameters. | ||
func (c *raftIVFFlatChecker) CheckTrain(params map[string]string) error { | ||
if err := c.ivfBaseChecker.CheckTrain(params); err != nil { | ||
return err | ||
} | ||
if !CheckStrByValues(params, Metric, RaftMetrics) { | ||
return fmt.Errorf("metric type not found or not supported, supported: %v", RaftMetrics) | ||
} | ||
return nil | ||
} | ||
|
||
func newRaftIVFFlatChecker() IndexChecker { | ||
return &raftIVFFlatChecker{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
package indexparamcheck | ||
|
||
import ( | ||
"strconv" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb" | ||
"github.com/milvus-io/milvus/pkg/util/metric" | ||
) | ||
|
||
func Test_raftIvfFlatChecker_CheckTrain(t *testing.T) { | ||
validParams := map[string]string{ | ||
DIM: strconv.Itoa(128), | ||
NLIST: strconv.Itoa(1024), | ||
Metric: metric.L2, | ||
} | ||
|
||
p1 := map[string]string{ | ||
DIM: strconv.Itoa(128), | ||
NLIST: strconv.Itoa(1024), | ||
Metric: metric.L2, | ||
} | ||
p2 := map[string]string{ | ||
DIM: strconv.Itoa(128), | ||
NLIST: strconv.Itoa(1024), | ||
Metric: metric.IP, | ||
} | ||
p3 := map[string]string{ | ||
DIM: strconv.Itoa(128), | ||
NLIST: strconv.Itoa(1024), | ||
Metric: metric.COSINE, | ||
} | ||
|
||
p4 := map[string]string{ | ||
DIM: strconv.Itoa(128), | ||
NLIST: strconv.Itoa(1024), | ||
Metric: metric.HAMMING, | ||
} | ||
p5 := map[string]string{ | ||
DIM: strconv.Itoa(128), | ||
NLIST: strconv.Itoa(1024), | ||
Metric: metric.JACCARD, | ||
} | ||
p6 := map[string]string{ | ||
DIM: strconv.Itoa(128), | ||
NLIST: strconv.Itoa(1024), | ||
Metric: metric.SUBSTRUCTURE, | ||
} | ||
p7 := map[string]string{ | ||
DIM: strconv.Itoa(128), | ||
NLIST: strconv.Itoa(1024), | ||
Metric: metric.SUPERSTRUCTURE, | ||
} | ||
|
||
cases := []struct { | ||
params map[string]string | ||
errIsNil bool | ||
}{ | ||
{validParams, true}, | ||
{invalidIVFParamsMin(), false}, | ||
{invalidIVFParamsMax(), false}, | ||
{p1, true}, | ||
{p2, true}, | ||
{p3, false}, | ||
{p4, false}, | ||
{p5, false}, | ||
{p6, false}, | ||
{p7, false}, | ||
} | ||
|
||
c := newRaftIVFFlatChecker() | ||
for _, test := range cases { | ||
err := c.CheckTrain(test.params) | ||
if test.errIsNil { | ||
assert.NoError(t, err) | ||
} else { | ||
assert.Error(t, err) | ||
} | ||
} | ||
} | ||
|
||
func Test_raftIvfFlatChecker_CheckValidDataType(t *testing.T) { | ||
cases := []struct { | ||
dType schemapb.DataType | ||
errIsNil bool | ||
}{ | ||
{ | ||
dType: schemapb.DataType_Bool, | ||
errIsNil: false, | ||
}, | ||
{ | ||
dType: schemapb.DataType_Int8, | ||
errIsNil: false, | ||
}, | ||
{ | ||
dType: schemapb.DataType_Int16, | ||
errIsNil: false, | ||
}, | ||
{ | ||
dType: schemapb.DataType_Int32, | ||
errIsNil: false, | ||
}, | ||
{ | ||
dType: schemapb.DataType_Int64, | ||
errIsNil: false, | ||
}, | ||
{ | ||
dType: schemapb.DataType_Float, | ||
errIsNil: false, | ||
}, | ||
{ | ||
dType: schemapb.DataType_Double, | ||
errIsNil: false, | ||
}, | ||
{ | ||
dType: schemapb.DataType_String, | ||
errIsNil: false, | ||
}, | ||
{ | ||
dType: schemapb.DataType_VarChar, | ||
errIsNil: false, | ||
}, | ||
{ | ||
dType: schemapb.DataType_Array, | ||
errIsNil: false, | ||
}, | ||
{ | ||
dType: schemapb.DataType_JSON, | ||
errIsNil: false, | ||
}, | ||
{ | ||
dType: schemapb.DataType_FloatVector, | ||
errIsNil: true, | ||
}, | ||
{ | ||
dType: schemapb.DataType_BinaryVector, | ||
errIsNil: false, | ||
}, | ||
} | ||
|
||
c := newRaftIVFFlatChecker() | ||
for _, test := range cases { | ||
err := c.CheckValidDataType(test.dType) | ||
if test.errIsNil { | ||
assert.NoError(t, err) | ||
} else { | ||
assert.Error(t, err) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters