From 2fcf2855ce0052e9b3facea00b13e93649101c6b Mon Sep 17 00:00:00 2001 From: Xiaohai Xu Date: Wed, 1 Apr 2020 20:50:48 +0800 Subject: [PATCH] fix sq8h deletion (#1830) Signed-off-by: sahuang --- .../faiss/gpu/GpuIndexIVFSQHybrid.cu | 11 ++++++++--- core/src/index/unittest/test_ivf.cpp | 18 ++++++++---------- .../delivery/request/DeleteByIDRequest.cpp | 3 ++- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/core/src/index/thirdparty/faiss/gpu/GpuIndexIVFSQHybrid.cu b/core/src/index/thirdparty/faiss/gpu/GpuIndexIVFSQHybrid.cu index bfee9bcf99..975f72d70d 100644 --- a/core/src/index/thirdparty/faiss/gpu/GpuIndexIVFSQHybrid.cu +++ b/core/src/index/thirdparty/faiss/gpu/GpuIndexIVFSQHybrid.cu @@ -340,9 +340,14 @@ GpuIndexIVFSQHybrid::searchImpl_(int n, static_assert(sizeof(long) == sizeof(Index::idx_t), "size mismatch"); Tensor outLabels(const_cast(labels), {n, k}); - auto bitsetDevice = toDevice(resources_, device_, nullptr, stream, {0}); - - index_->query(queries, bitsetDevice, nprobe, k, outDistances, outLabels); + if (!bitset) { + auto bitsetDevice = toDevice(resources_, device_, nullptr, stream, {0}); + index_->query(queries, bitsetDevice, nprobe, k, outDistances, outLabels); + } else { + auto bitsetDevice = toDevice(resources_, device_, + const_cast(bitset->data()), stream,{(int) bitset->size()}); + index_->query(queries, bitsetDevice, nprobe, k, outDistances, outLabels); + } } } } // namespace diff --git a/core/src/index/unittest/test_ivf.cpp b/core/src/index/unittest/test_ivf.cpp index b549fe17fb..f6d9767e4c 100644 --- a/core/src/index/unittest/test_ivf.cpp +++ b/core/src/index/unittest/test_ivf.cpp @@ -166,17 +166,15 @@ TEST_P(IVFTest, ivf_basic_gpu) { AssertAnns(result, nq, k); // PrintResult(result, nq, k); - if (index_type_ != milvus::knowhere::IndexEnum::INDEX_FAISS_IVFSQ8H) { - faiss::ConcurrentBitsetPtr concurrent_bitset_ptr = std::make_shared(nb); - for (int64_t i = 0; i < nq; ++i) { - concurrent_bitset_ptr->set(i); - } - index_->SetBlacklist(concurrent_bitset_ptr); - - auto result_bs_1 = index_->Query(query_dataset, conf_); - AssertAnns(result_bs_1, nq, k, CheckMode::CHECK_NOT_EQUAL); - // PrintResult(result, nq, k); + faiss::ConcurrentBitsetPtr concurrent_bitset_ptr = std::make_shared(nb); + for (int64_t i = 0; i < nq; ++i) { + concurrent_bitset_ptr->set(i); } + index_->SetBlacklist(concurrent_bitset_ptr); + + auto result_bs_1 = index_->Query(query_dataset, conf_); + AssertAnns(result_bs_1, nq, k, CheckMode::CHECK_NOT_EQUAL); + // PrintResult(result, nq, k); #ifdef MILVUS_GPU_VERSION milvus::knowhere::FaissGpuResourceMgr::GetInstance().Dump(); diff --git a/core/src/server/delivery/request/DeleteByIDRequest.cpp b/core/src/server/delivery/request/DeleteByIDRequest.cpp index c5a5e2771c..28e13e7891 100644 --- a/core/src/server/delivery/request/DeleteByIDRequest.cpp +++ b/core/src/server/delivery/request/DeleteByIDRequest.cpp @@ -75,7 +75,8 @@ DeleteByIDRequest::OnExecute() { table_schema.engine_type_ != (int32_t)engine::EngineType::FAISS_IVFFLAT && table_schema.engine_type_ != (int32_t)engine::EngineType::FAISS_BIN_IVFFLAT && table_schema.engine_type_ != (int32_t)engine::EngineType::FAISS_IVFSQ8 && - table_schema.engine_type_ != (int32_t)engine::EngineType::FAISS_PQ) { + table_schema.engine_type_ != (int32_t)engine::EngineType::FAISS_PQ && + table_schema.engine_type_ != (int32_t)engine::EngineType::FAISS_IVFSQ8H) { std::string err_msg = "Index type " + std::to_string(table_schema.engine_type_) + " does not support delete operation"; SERVER_LOG_ERROR << err_msg;