From bee37170f4b755f7b739152a6c24ddfdf4e202e5 Mon Sep 17 00:00:00 2001 From: Yukikaze-CZR Date: Mon, 2 Dec 2019 14:40:16 +0800 Subject: [PATCH] IP search metric_type shouldn't be supported by IVF_PQ index on GPU version #616 #636 --- CHANGELOG.md | 2 ++ .../knowhere/index/vector_index/IndexGPUIVFPQ.cpp | 4 ++++ core/src/wrapper/gpu/GPUVecImpl.cpp | 2 ++ core/unittest/db/test_db.cpp | 13 +++++++++++++ 4 files changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19a9c451..7956e513 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,7 +43,9 @@ Please mark all change in change log and use the ticket from JIRA. - \#599 - Build index log is incorrect - \#602 - Optimizer specify wrong gpu_id - \#606 - No log generated during building index with CPU +- \#616 - IP search metric_type is not supported by IVF_PQ index - \#631 - FAISS isn't compiled with O3 option +- \#636 - [CPU] Create index PQ should be failed if table metric type set Inner Product ## Feature - \#12 - Pure CPU version for Milvus diff --git a/core/src/index/knowhere/knowhere/index/vector_index/IndexGPUIVFPQ.cpp b/core/src/index/knowhere/knowhere/index/vector_index/IndexGPUIVFPQ.cpp index cbd4f4f0..a4693d80 100644 --- a/core/src/index/knowhere/knowhere/index/vector_index/IndexGPUIVFPQ.cpp +++ b/core/src/index/knowhere/knowhere/index/vector_index/IndexGPUIVFPQ.cpp @@ -32,6 +32,10 @@ namespace knowhere { IndexModelPtr GPUIVFPQ::Train(const DatasetPtr& dataset, const Config& config) { auto build_cfg = std::dynamic_pointer_cast(config); + if (build_cfg->metric_type == knowhere::METRICTYPE::IP) { + KNOWHERE_LOG_ERROR << "PQ not support IP in GPU version!"; + throw KnowhereException("PQ not support IP in GPU version!"); + } if (build_cfg != nullptr) { build_cfg->CheckValid(); // throw exception } diff --git a/core/src/wrapper/gpu/GPUVecImpl.cpp b/core/src/wrapper/gpu/GPUVecImpl.cpp index e40f5038..99fa7589 100644 --- a/core/src/wrapper/gpu/GPUVecImpl.cpp +++ b/core/src/wrapper/gpu/GPUVecImpl.cpp @@ -16,6 +16,7 @@ // under the License. #include "wrapper/gpu/GPUVecImpl.h" +#include #include "knowhere/common/Exception.h" #include "knowhere/index/vector_index/IndexGPUIDMAP.h" #include "knowhere/index/vector_index/IndexGPUIVF.h" @@ -58,6 +59,7 @@ IVFMixIndex::BuildAll(const int64_t& nb, const float* xb, const int64_t* ids, co } } catch (knowhere::KnowhereException& e) { WRAPPER_LOG_ERROR << e.what(); + throw WrapperException(e.what()); return Status(KNOWHERE_UNEXPECTED_ERROR, e.what()); } catch (std::exception& e) { WRAPPER_LOG_ERROR << e.what(); diff --git a/core/unittest/db/test_db.cpp b/core/unittest/db/test_db.cpp index 0a47ac1b..6c14b86b 100644 --- a/core/unittest/db/test_db.cpp +++ b/core/unittest/db/test_db.cpp @@ -336,6 +336,19 @@ TEST_F(DBTest, SEARCH_TEST) { } #endif + index.engine_type_ = (int)milvus::engine::EngineType::FAISS_PQ; + db_->CreateIndex(TABLE_NAME, index); // wait until build index finish + + { + std::vector tags; + milvus::engine::ResultIds result_ids; + milvus::engine::ResultDistances result_distances; + stat = db_->Query(TABLE_NAME, tags, k, nq, 10, xq.data(), result_ids, result_distances); + ASSERT_TRUE(stat.ok()); + stat = db_->Query(TABLE_NAME, tags, k, 1100, 10, xq.data(), result_ids, result_distances); + ASSERT_TRUE(stat.ok()); + } + { // search by specify index file milvus::engine::meta::DatesT dates; std::vector file_ids = {"1", "2", "3", "4", "5", "6"}; -- GitLab