mirror of https://github.com/milvus-io/milvus.git
MS-496 Change the top_k limitation from 1024 to 2048
Former-commit-id: fc04ff846d7d4d8b1fb2b16e9dba4f5ddfbe9c9dpull/191/head
parent
380d7ef792
commit
b167b004c7
|
@ -94,7 +94,7 @@ ValidationUtil::ValidateTableIndexMetricType(int32_t metric_type) {
|
|||
|
||||
ErrorCode
|
||||
ValidationUtil::ValidateSearchTopk(int64_t top_k, const engine::meta::TableSchema& table_schema) {
|
||||
if (top_k <= 0) {
|
||||
if (top_k <= 0 || top_k > 2048) {
|
||||
return SERVER_INVALID_TOPK;
|
||||
}
|
||||
|
||||
|
|
|
@ -243,28 +243,8 @@ void AutoGenParams(const IndexType &type, const long &size, zilliz::knowhere::Co
|
|||
#define GPU_MAX_NRPOBE 1024
|
||||
#endif
|
||||
|
||||
#define GPU_MAX_TOP_K GPU_MAX_NRPOBE
|
||||
// TODO(yzb): may be changed latter
|
||||
#define CPU_MAX_TOP_K GPU_MAX_TOP_K
|
||||
#define DEFAULT_MAX_TOP_K GPU_MAX_TOP_K
|
||||
|
||||
void ParameterValidation(const IndexType &type, Config &cfg) {
|
||||
switch (type) {
|
||||
case IndexType::FAISS_IVFFLAT_CPU:
|
||||
case IndexType::FAISS_IVFPQ_CPU:
|
||||
case IndexType::FAISS_IVFSQ8_CPU: {
|
||||
//search on CPU
|
||||
if (cfg.get_with_default("k", 0) != 0) {
|
||||
auto k = cfg["k"].as<int>();
|
||||
if (k > CPU_MAX_TOP_K) {
|
||||
WRAPPER_LOG_WARNING << "When search with CPU, top_k shoud be no more than " << CPU_MAX_TOP_K
|
||||
<< ", but you passed " << k
|
||||
<< ". Search with " << CPU_MAX_TOP_K << " instead";
|
||||
cfg.insert_or_assign("k", CPU_MAX_TOP_K);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IndexType::FAISS_IVFSQ8_GPU:
|
||||
case IndexType::FAISS_IVFFLAT_GPU:
|
||||
case IndexType::FAISS_IVFPQ_GPU: {
|
||||
|
@ -278,32 +258,6 @@ void ParameterValidation(const IndexType &type, Config &cfg) {
|
|||
cfg.insert_or_assign("nprobe", GPU_MAX_NRPOBE);
|
||||
}
|
||||
}
|
||||
if (cfg.get_with_default("k", 0) != 0) {
|
||||
auto k = cfg["k"].as<int>();
|
||||
if (k > GPU_MAX_TOP_K) {
|
||||
WRAPPER_LOG_WARNING << "When search with GPU, top_k shoud be no more than " << GPU_MAX_TOP_K
|
||||
<< ", but you passed " << k
|
||||
<< ". Search with " << GPU_MAX_TOP_K << " instead";
|
||||
cfg.insert_or_assign("k", GPU_MAX_TOP_K);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IndexType::FAISS_IDMAP:
|
||||
case IndexType::FAISS_IVFFLAT_MIX:
|
||||
case IndexType::SPTAG_KDT_RNT_CPU:
|
||||
case IndexType::FAISS_IVFSQ8_MIX:
|
||||
case IndexType::NSG_MIX: {
|
||||
// TODO(yzb): need to figure out where it search
|
||||
if (cfg.get_with_default("k", 0) != 0) {
|
||||
auto k = cfg["k"].as<int>();
|
||||
if (k > DEFAULT_MAX_TOP_K) {
|
||||
WRAPPER_LOG_WARNING << "top_k shoud be no more than " << DEFAULT_MAX_TOP_K << ", but you passed "
|
||||
<< k
|
||||
<< ". Search with " << DEFAULT_MAX_TOP_K << " instead";
|
||||
cfg.insert_or_assign("k", DEFAULT_MAX_TOP_K);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:break;
|
||||
|
|
Loading…
Reference in New Issue