diff --git a/core/src/scheduler/SchedInst.h b/core/src/scheduler/SchedInst.h index eaf180e574..27a173c68a 100644 --- a/core/src/scheduler/SchedInst.h +++ b/core/src/scheduler/SchedInst.h @@ -19,10 +19,7 @@ #include "Utils.h" #include "selector/BuildIndexPass.h" #include "selector/FaissFlatPass.h" -#include "selector/FaissIVFFlatPass.h" -#include "selector/FaissIVFPQPass.h" -#include "selector/FaissIVFSQ8HPass.h" -#include "selector/FaissIVFSQ8Pass.h" +#include "selector/FaissIVFPass.h" #include "selector/FallbackPass.h" #include "selector/Optimizer.h" @@ -122,10 +119,7 @@ class OptimizerInst { pass_list.push_back(std::make_shared()); pass_list.push_back(std::make_shared()); - pass_list.push_back(std::make_shared()); - pass_list.push_back(std::make_shared()); - pass_list.push_back(std::make_shared()); - pass_list.push_back(std::make_shared()); + pass_list.push_back(std::make_shared()); } #endif pass_list.push_back(std::make_shared()); diff --git a/core/src/scheduler/selector/FaissIVFFlatPass.h b/core/src/scheduler/selector/FaissIVFFlatPass.h deleted file mode 100644 index 2c1b4e7ebb..0000000000 --- a/core/src/scheduler/selector/FaissIVFFlatPass.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2019-2020 Zilliz. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software distributed under the License -// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -// or implied. See the License for the specific language governing permissions and limitations under the License. -#ifdef MILVUS_GPU_VERSION -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "config/handler/GpuResourceConfigHandler.h" -#include "scheduler/selector/Pass.h" - -namespace milvus { -namespace scheduler { - -class FaissIVFFlatPass : public Pass, public server::GpuResourceConfigHandler { - public: - FaissIVFFlatPass() = default; - - public: - void - Init() override; - - bool - Run(const TaskPtr& task) override; - - private: - int64_t idx_ = 0; -}; - -using FaissIVFFlatPassPtr = std::shared_ptr; - -} // namespace scheduler -} // namespace milvus -#endif diff --git a/core/src/scheduler/selector/FaissIVFPQPass.cpp b/core/src/scheduler/selector/FaissIVFPQPass.cpp deleted file mode 100644 index dc7fbd851f..0000000000 --- a/core/src/scheduler/selector/FaissIVFPQPass.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (C) 2019-2020 Zilliz. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software distributed under the License -// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -// or implied. See the License for the specific language governing permissions and limitations under the License. -#ifdef MILVUS_GPU_VERSION -#include "scheduler/selector/FaissIVFPQPass.h" -#include "cache/GpuCacheMgr.h" -#include "config/Config.h" -#include "knowhere/index/vector_index/helpers/IndexParameter.h" -#include "scheduler/SchedInst.h" -#include "scheduler/Utils.h" -#include "scheduler/task/SearchTask.h" -#include "scheduler/tasklabel/SpecResLabel.h" -#include "utils/Log.h" -#include "utils/ValidationUtil.h" - -#include - -namespace milvus { -namespace scheduler { - -void -FaissIVFPQPass::Init() { -#ifdef MILVUS_GPU_VERSION - server::Config& config = server::Config::GetInstance(); - Status s = config.GetGpuResourceConfigGpuSearchThreshold(threshold_); - if (!s.ok()) { - threshold_ = std::numeric_limits::max(); - } - s = config.GetGpuResourceConfigSearchResources(search_gpus_); - if (!s.ok()) { - throw std::exception(); - } - - SetIdentity("FaissIVFPQPass"); - AddGpuEnableListener(); - AddGpuSearchThresholdListener(); - AddGpuSearchResourcesListener(); -#endif -} - -bool -FaissIVFPQPass::Run(const TaskPtr& task) { - if (task->Type() != TaskType::SearchTask) { - return false; - } - - auto search_task = std::static_pointer_cast(task); - if (search_task->file_->engine_type_ != (int)engine::EngineType::FAISS_PQ) { - return false; - } - - auto search_job = std::static_pointer_cast(search_task->job_.lock()); - ResourcePtr res_ptr; - if (!gpu_enable_) { - LOG_SERVER_DEBUG_ << LogOut("[%s][%d] FaissIVFPQPass: gpu disable, specify cpu to search!", "search", 0); - res_ptr = ResMgrInst::GetInstance()->GetResource("cpu"); - } else if (search_job->nq() < (uint64_t)threshold_) { - LOG_SERVER_DEBUG_ << LogOut("[%s][%d] FaissIVFPQPass: nq < gpu_search_threshold, specify cpu to search!", - "search", 0); - res_ptr = ResMgrInst::GetInstance()->GetResource("cpu"); - } else if (search_job->extra_params()[knowhere::IndexParams::nprobe].get() < - milvus::server::QUERY_MAX_TOPK) { - LOG_SERVER_DEBUG_ << LogOut("[%s][%d] FaissIVFFlatPass: nprobe > gpu_nprobe_threshold, specify cpu to search!", - "search", 0); - res_ptr = ResMgrInst::GetInstance()->GetResource("cpu"); - } else { - LOG_SERVER_DEBUG_ << LogOut("[%s][%d] FaissIVFPQPass: nq >= gpu_search_threshold, specify gpu %d to search!", - "search", 0, search_gpus_[idx_]); - res_ptr = ResMgrInst::GetInstance()->GetResource(ResourceType::GPU, search_gpus_[idx_]); - idx_ = (idx_ + 1) % search_gpus_.size(); - } - auto label = std::make_shared(res_ptr); - task->label() = label; - return true; -} - -} // namespace scheduler -} // namespace milvus -#endif diff --git a/core/src/scheduler/selector/FaissIVFFlatPass.cpp b/core/src/scheduler/selector/FaissIVFPass.cpp similarity index 71% rename from core/src/scheduler/selector/FaissIVFFlatPass.cpp rename to core/src/scheduler/selector/FaissIVFPass.cpp index b67650d5c0..458186fc0c 100644 --- a/core/src/scheduler/selector/FaissIVFFlatPass.cpp +++ b/core/src/scheduler/selector/FaissIVFPass.cpp @@ -9,7 +9,7 @@ // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express // or implied. See the License for the specific language governing permissions and limitations under the License. #ifdef MILVUS_GPU_VERSION -#include "scheduler/selector/FaissIVFFlatPass.h" +#include "scheduler/selector/FaissIVFPass.h" #include "cache/GpuCacheMgr.h" #include "config/Config.h" #include "knowhere/index/vector_index/helpers/IndexParameter.h" @@ -24,8 +24,7 @@ namespace milvus { namespace scheduler { void -FaissIVFFlatPass::Init() { -#ifdef MILVUS_GPU_VERSION +FaissIVFPass::Init() { server::Config& config = server::Config::GetInstance(); Status s = config.GetGpuResourceConfigGpuSearchThreshold(threshold_); if (!s.ok()) { @@ -36,40 +35,45 @@ FaissIVFFlatPass::Init() { throw std::exception(); } - SetIdentity("FaissIVFFlatPass"); + SetIdentity("FaissIVFPass"); AddGpuEnableListener(); AddGpuSearchThresholdListener(); AddGpuSearchResourcesListener(); -#endif } bool -FaissIVFFlatPass::Run(const TaskPtr& task) { +FaissIVFPass::Run(const TaskPtr& task) { if (task->Type() != TaskType::SearchTask) { return false; } auto search_task = std::static_pointer_cast(task); - if (search_task->file_->engine_type_ != (int)engine::EngineType::FAISS_IVFFLAT) { - return false; + switch (static_cast(search_task->file_->engine_type_)) { + case engine::EngineType::FAISS_IVFFLAT: + case engine::EngineType::FAISS_PQ: + case engine::EngineType::FAISS_IVFSQ8: + case engine::EngineType::FAISS_IVFSQ8H: + break; + default: + return false; } auto search_job = std::static_pointer_cast(search_task->job_.lock()); ResourcePtr res_ptr; if (!gpu_enable_) { - LOG_SERVER_DEBUG_ << LogOut("[%s][%d] FaissIVFFlatPass: gpu disable, specify cpu to search!", "search", 0); + LOG_SERVER_DEBUG_ << LogOut("[%s][%d] FaissIVFPass: gpu disable, specify cpu to search!", "search", 0); res_ptr = ResMgrInst::GetInstance()->GetResource("cpu"); } else if (search_job->nq() < (uint64_t)threshold_) { - LOG_SERVER_DEBUG_ << LogOut("[%s][%d] FaissIVFFlatPass: nq < gpu_search_threshold, specify cpu to search!", + LOG_SERVER_DEBUG_ << LogOut("[%s][%d] FaissIVFPass: nq < gpu_search_threshold, specify cpu to search!", "search", 0); res_ptr = ResMgrInst::GetInstance()->GetResource("cpu"); - } else if (search_job->extra_params()[knowhere::IndexParams::nprobe].get() < - milvus::server::QUERY_MAX_TOPK) { - LOG_SERVER_DEBUG_ << LogOut("[%s][%d] FaissIVFFlatPass: nprobe > gpu_nprobe_threshold, specify cpu to search!", + } else if (search_job->extra_params()[knowhere::IndexParams::nprobe].get() > + milvus::server::GPU_QUERY_MAX_NPROBE) { + LOG_SERVER_DEBUG_ << LogOut("[%s][%d] FaissIVFPass: nprobe > gpu_nprobe_threshold, specify cpu to search!", "search", 0); res_ptr = ResMgrInst::GetInstance()->GetResource("cpu"); } else { - LOG_SERVER_DEBUG_ << LogOut("[%s][%d] FaissIVFFlatPass: nq >= gpu_search_threshold, specify gpu %d to search!", + LOG_SERVER_DEBUG_ << LogOut("[%s][%d] FaissIVFPass: nq >= gpu_search_threshold, specify gpu %d to search!", "search", 0, search_gpus_[idx_]); res_ptr = ResMgrInst::GetInstance()->GetResource(ResourceType::GPU, search_gpus_[idx_]); idx_ = (idx_ + 1) % search_gpus_.size(); diff --git a/core/src/scheduler/selector/FaissIVFPQPass.h b/core/src/scheduler/selector/FaissIVFPass.h similarity index 87% rename from core/src/scheduler/selector/FaissIVFPQPass.h rename to core/src/scheduler/selector/FaissIVFPass.h index b4fa296537..c02f039b0c 100644 --- a/core/src/scheduler/selector/FaissIVFPQPass.h +++ b/core/src/scheduler/selector/FaissIVFPass.h @@ -29,14 +29,15 @@ namespace milvus { namespace scheduler { -class FaissIVFPQPass : public Pass, public server::GpuResourceConfigHandler { +class FaissIVFPass : public Pass, public server::GpuResourceConfigHandler { public: - FaissIVFPQPass() = default; + FaissIVFPass() = default; public: void Init() override; + public: bool Run(const TaskPtr& task) override; @@ -44,7 +45,7 @@ class FaissIVFPQPass : public Pass, public server::GpuResourceConfigHandler { int64_t idx_ = 0; }; -using FaissIVFPQPassPtr = std::shared_ptr; +using FaissIVFPassPtr = std::shared_ptr; } // namespace scheduler } // namespace milvus diff --git a/core/src/scheduler/selector/FaissIVFSQ8HPass.cpp b/core/src/scheduler/selector/FaissIVFSQ8HPass.cpp deleted file mode 100644 index 4e9eb2401c..0000000000 --- a/core/src/scheduler/selector/FaissIVFSQ8HPass.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (C) 2019-2020 Zilliz. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software distributed under the License -// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -// or implied. See the License for the specific language governing permissions and limitations under the License. - -#ifdef MILVUS_GPU_VERSION -#include "scheduler/selector/FaissIVFSQ8HPass.h" -#include "cache/GpuCacheMgr.h" -#include "config/Config.h" -#include "knowhere/index/vector_index/helpers/IndexParameter.h" -#include "scheduler/SchedInst.h" -#include "scheduler/Utils.h" -#include "scheduler/task/SearchTask.h" -#include "scheduler/tasklabel/SpecResLabel.h" -#include "utils/Log.h" -#include "utils/ValidationUtil.h" - -namespace milvus { -namespace scheduler { - -void -FaissIVFSQ8HPass::Init() { - server::Config& config = server::Config::GetInstance(); - Status s = config.GetGpuResourceConfigGpuSearchThreshold(threshold_); - if (!s.ok()) { - threshold_ = std::numeric_limits::max(); - } - s = config.GetGpuResourceConfigSearchResources(search_gpus_); - if (!s.ok()) { - throw std::exception(); - } - - SetIdentity("FaissIVFSQ8HPass"); - AddGpuEnableListener(); - AddGpuSearchThresholdListener(); - AddGpuSearchResourcesListener(); -} - -bool -FaissIVFSQ8HPass::Run(const TaskPtr& task) { - if (task->Type() != TaskType::SearchTask) { - return false; - } - - auto search_task = std::static_pointer_cast(task); - if (search_task->file_->engine_type_ != (int)engine::EngineType::FAISS_IVFSQ8H) { - return false; - } - - auto search_job = std::static_pointer_cast(search_task->job_.lock()); - ResourcePtr res_ptr; - if (!gpu_enable_) { - LOG_SERVER_DEBUG_ << LogOut("[%s][%d] FaissIVFSQ8HPass: gpu disable, specify cpu to search!", "search", 0); - res_ptr = ResMgrInst::GetInstance()->GetResource("cpu"); - } - if (search_job->nq() < (uint64_t)threshold_) { - LOG_SERVER_DEBUG_ << LogOut("[%s][%d] FaissIVFSQ8HPass: nq < gpu_search_threshold, specify cpu to search!", - "search", 0); - res_ptr = ResMgrInst::GetInstance()->GetResource("cpu"); - } else if (search_job->extra_params()[knowhere::IndexParams::nprobe].get() < - milvus::server::QUERY_MAX_TOPK) { - LOG_SERVER_DEBUG_ << LogOut("[%s][%d] FaissIVFFlatPass: nprobe > gpu_nprobe_threshold, specify cpu to search!", - "search", 0); - res_ptr = ResMgrInst::GetInstance()->GetResource("cpu"); - } else { - LOG_SERVER_DEBUG_ << LogOut("[%s][%d] FaissIVFSQ8HPass: nq >= gpu_search_threshold, specify gpu %d to search!", - "search", 0, search_gpus_[idx_]); - res_ptr = ResMgrInst::GetInstance()->GetResource(ResourceType::GPU, search_gpus_[idx_]); - idx_ = (idx_ + 1) % search_gpus_.size(); - } - auto label = std::make_shared(res_ptr); - task->label() = label; - return true; -} - -} // namespace scheduler -} // namespace milvus -#endif diff --git a/core/src/scheduler/selector/FaissIVFSQ8HPass.h b/core/src/scheduler/selector/FaissIVFSQ8HPass.h deleted file mode 100644 index 1050352c01..0000000000 --- a/core/src/scheduler/selector/FaissIVFSQ8HPass.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2019-2020 Zilliz. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software distributed under the License -// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -// or implied. See the License for the specific language governing permissions and limitations under the License. -#ifdef MILVUS_GPU_VERSION -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "config/handler/GpuResourceConfigHandler.h" -#include "scheduler/selector/Pass.h" - -namespace milvus { -namespace scheduler { - -class FaissIVFSQ8HPass : public Pass, public server::GpuResourceConfigHandler { - public: - FaissIVFSQ8HPass() = default; - - public: - void - Init() override; - - bool - Run(const TaskPtr& task) override; - - private: - int64_t idx_ = 0; -}; - -using FaissIVFSQ8HPassPtr = std::shared_ptr; - -} // namespace scheduler -} // namespace milvus -#endif diff --git a/core/src/scheduler/selector/FaissIVFSQ8Pass.cpp b/core/src/scheduler/selector/FaissIVFSQ8Pass.cpp deleted file mode 100644 index 29f4def366..0000000000 --- a/core/src/scheduler/selector/FaissIVFSQ8Pass.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (C) 2019-2020 Zilliz. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software distributed under the License -// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -// or implied. See the License for the specific language governing permissions and limitations under the License. -#ifdef MILVUS_GPU_VERSION -#include "scheduler/selector/FaissIVFSQ8Pass.h" -#include "cache/GpuCacheMgr.h" -#include "config/Config.h" -#include "knowhere/index/vector_index/helpers/IndexParameter.h" -#include "scheduler/SchedInst.h" -#include "scheduler/Utils.h" -#include "scheduler/task/SearchTask.h" -#include "scheduler/tasklabel/SpecResLabel.h" -#include "utils/Log.h" -#include "utils/ValidationUtil.h" - -namespace milvus { -namespace scheduler { - -void -FaissIVFSQ8Pass::Init() { -#ifdef MILVUS_GPU_VERSION - server::Config& config = server::Config::GetInstance(); - Status s = config.GetGpuResourceConfigGpuSearchThreshold(threshold_); - if (!s.ok()) { - threshold_ = std::numeric_limits::max(); - } - s = config.GetGpuResourceConfigSearchResources(search_gpus_); - if (!s.ok()) { - throw std::exception(); - } - - SetIdentity("FaissIVFSQ8Pass"); - AddGpuEnableListener(); - AddGpuSearchThresholdListener(); - AddGpuSearchResourcesListener(); -#endif -} - -bool -FaissIVFSQ8Pass::Run(const TaskPtr& task) { - if (task->Type() != TaskType::SearchTask) { - return false; - } - - auto search_task = std::static_pointer_cast(task); - if (search_task->file_->engine_type_ != (int)engine::EngineType::FAISS_IVFSQ8) { - return false; - } - - auto search_job = std::static_pointer_cast(search_task->job_.lock()); - ResourcePtr res_ptr; - if (!gpu_enable_) { - LOG_SERVER_DEBUG_ << LogOut("[%s][%d] FaissIVFSQ8Pass: gpu disable, specify cpu to search!", "search", 0); - res_ptr = ResMgrInst::GetInstance()->GetResource("cpu"); - } else if (search_job->nq() < (uint64_t)threshold_) { - LOG_SERVER_DEBUG_ << LogOut("[%s][%d] FaissIVFSQ8Pass: nq < gpu_search_threshold, specify cpu to search!", - "search", 0); - res_ptr = ResMgrInst::GetInstance()->GetResource("cpu"); - } else if (search_job->extra_params()[knowhere::IndexParams::nprobe].get() < - milvus::server::QUERY_MAX_TOPK) { - LOG_SERVER_DEBUG_ << LogOut("[%s][%d] FaissIVFFlatPass: nprobe > gpu_nprobe_threshold, specify cpu to search!", - "search", 0); - res_ptr = ResMgrInst::GetInstance()->GetResource("cpu"); - } else { - LOG_SERVER_DEBUG_ << LogOut("[%s][%d] FaissIVFSQ8Pass: nq >= gpu_search_threshold, specify gpu %d to search!", - "search", 0, search_gpus_[idx_]); - res_ptr = ResMgrInst::GetInstance()->GetResource(ResourceType::GPU, search_gpus_[idx_]); - idx_ = (idx_ + 1) % search_gpus_.size(); - } - auto label = std::make_shared(res_ptr); - task->label() = label; - return true; -} - -} // namespace scheduler -} // namespace milvus -#endif diff --git a/core/src/scheduler/selector/FaissIVFSQ8Pass.h b/core/src/scheduler/selector/FaissIVFSQ8Pass.h deleted file mode 100644 index 99530c7635..0000000000 --- a/core/src/scheduler/selector/FaissIVFSQ8Pass.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2019-2020 Zilliz. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software distributed under the License -// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -// or implied. See the License for the specific language governing permissions and limitations under the License. -#ifdef MILVUS_GPU_VERSION -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "config/handler/GpuResourceConfigHandler.h" -#include "scheduler/selector/Pass.h" - -namespace milvus { -namespace scheduler { - -class FaissIVFSQ8Pass : public Pass, public server::GpuResourceConfigHandler { - public: - FaissIVFSQ8Pass() = default; - - public: - void - Init() override; - - bool - Run(const TaskPtr& task) override; - - private: - int64_t idx_ = 0; -}; - -using FaissIVFSQ8PassPtr = std::shared_ptr; - -} // namespace scheduler -} // namespace milvus -#endif diff --git a/core/src/utils/ValidationUtil.h b/core/src/utils/ValidationUtil.h index 27a9f85566..97276afa17 100644 --- a/core/src/utils/ValidationUtil.h +++ b/core/src/utils/ValidationUtil.h @@ -23,6 +23,7 @@ namespace milvus { namespace server { constexpr int64_t QUERY_MAX_TOPK = 2048; +constexpr int64_t GPU_QUERY_MAX_NPROBE = 2048; class ValidationUtil { private: diff --git a/core/unittest/scheduler/test_action.cpp b/core/unittest/scheduler/test_action.cpp index 87f9eed341..b37bcb0c65 100644 --- a/core/unittest/scheduler/test_action.cpp +++ b/core/unittest/scheduler/test_action.cpp @@ -13,13 +13,10 @@ #include #include #include -#include #include "scheduler/optimizer/BuildIndexPass.h" #include "scheduler/optimizer/FaissFlatPass.h" -#include "scheduler/optimizer/FaissIVFPQPass.h" -#include "scheduler/optimizer/FaissIVFSQ8HPass.h" -#include "scheduler/optimizer/FaissIVFSQ8Pass.h" +#include "scheduler/optimizer/FaissIVFPass.h" namespace milvus { namespace scheduler { diff --git a/core/unittest/scheduler/test_selector.cpp b/core/unittest/scheduler/test_selector.cpp index 71a97ff516..27e9ef96b1 100644 --- a/core/unittest/scheduler/test_selector.cpp +++ b/core/unittest/scheduler/test_selector.cpp @@ -18,10 +18,7 @@ #include "scheduler/resource/CpuResource.h" #include "scheduler/selector/BuildIndexPass.h" #include "scheduler/selector/FaissFlatPass.h" -#include "scheduler/selector/FaissIVFFlatPass.h" -#include "scheduler/selector/FaissIVFPQPass.h" -#include "scheduler/selector/FaissIVFSQ8HPass.h" -#include "scheduler/selector/FaissIVFSQ8Pass.h" +#include "scheduler/selector/FaissIVFPass.h" #include "scheduler/selector/FallbackPass.h" namespace milvus { @@ -47,42 +44,20 @@ TEST(OptimizerTest, TEST_OPTIMIZER) { fiu_disable("get_gpu_config_search_resources.disable_gpu_resource_fail"); fiu_disable("check_config_gpu_search_threshold_fail"); - FaissIVFFlatPass faiss_ivf_flat_pass; + FaissIVFPass faiss_ivf_pass; fiu_enable("check_config_gpu_search_threshold_fail", 1, NULL, 0); fiu_enable("get_gpu_config_search_resources.disable_gpu_resource_fail", 1, NULL, 0); - ASSERT_ANY_THROW(faiss_ivf_flat_pass.Init();); - fiu_disable("get_gpu_config_search_resources.disable_gpu_resource_fail"); - fiu_disable("check_config_gpu_search_threshold_fail"); - - FaissIVFPQPass faiss_ivf_pq_pass; - fiu_enable("check_config_gpu_search_threshold_fail", 1, NULL, 0); - fiu_enable("get_gpu_config_search_resources.disable_gpu_resource_fail", 1, NULL, 0); - ASSERT_ANY_THROW(faiss_ivf_pq_pass.Init();); + ASSERT_ANY_THROW(faiss_ivf_pass.Init();); fiu_disable("get_gpu_config_search_resources.disable_gpu_resource_fail"); fiu_disable("check_config_gpu_search_threshold_fail"); auto file = std::make_shared(); - file->engine_type_ = (int)engine::EngineType::FAISS_IVFFLAT; - file->index_params_ = "{ \"nlist\": 100 }"; + file->engine_type_ = (int)engine::EngineType::FAISS_IDMAP; + file->index_params_ = ""; file->dimension_ = 64; auto search_task = std::make_shared(nullptr, file, nullptr); - ASSERT_FALSE(faiss_ivf_pq_pass.Run(search_task)); - - FaissIVFSQ8HPass faiss_ivf_q8h_pass; - fiu_enable("check_config_gpu_search_threshold_fail", 1, NULL, 0); - faiss_ivf_q8h_pass.Init(); - fiu_disable("check_config_gpu_search_threshold_fail"); - - auto search_task2 = std::make_shared(nullptr, file, nullptr); - ASSERT_FALSE(faiss_ivf_q8h_pass.Run(build_index_task)); - ASSERT_FALSE(faiss_ivf_q8h_pass.Run(search_task2)); - - FaissIVFSQ8Pass faiss_ivf_q8_pass; - fiu_enable("check_config_gpu_search_threshold_fail", 1, NULL, 0); - fiu_enable("get_gpu_config_search_resources.disable_gpu_resource_fail", 1, NULL, 0); - ASSERT_ANY_THROW(faiss_ivf_q8_pass.Init();); - fiu_disable("get_gpu_config_search_resources.disable_gpu_resource_fail"); - fiu_disable("check_config_gpu_search_threshold_fail"); + ASSERT_FALSE(faiss_ivf_pass.Run(search_task)); + ASSERT_FALSE(faiss_ivf_pass.Run(build_index_task)); FallbackPass fall_back_pass; fall_back_pass.Init(); diff --git a/tests/milvus_python_test/entity/test_search.py b/tests/milvus_python_test/entity/test_search.py index e98287af59..6955cefeb0 100644 --- a/tests/milvus_python_test/entity/test_search.py +++ b/tests/milvus_python_test/entity/test_search.py @@ -1223,7 +1223,11 @@ class TestSearchParamsInvalid(object): search_param = {"nprobe": nprobe} query_vecs = gen_vectors(nprobe, dim) status, result = connect.search(collection, top_k, query_vecs, params=search_param) - assert not status.OK() + # IVFSQ8H supported later + if index["index_type"] == IndexType.IVF_SQ8H: + assert not status.OK() + else: + assert status.OK() @pytest.fixture( scope="function",