diff --git a/CHANGELOG.md b/CHANGELOG.md index ee008d269a..d4d139f79b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Please mark all change in change log and use the issue from GitHub # Milvus 0.7.0 (TBD) ## Bug +- \#715 - Milvus crash when searching and building index simultaneously using SQ8H - \#744 - Don't return partition table for show_tables ## Feature diff --git a/core/src/index/knowhere/knowhere/index/vector_index/IndexIVFSQHybrid.cpp b/core/src/index/knowhere/knowhere/index/vector_index/IndexIVFSQHybrid.cpp index 4fecfb9dc5..0caf849756 100644 --- a/core/src/index/knowhere/knowhere/index/vector_index/IndexIVFSQHybrid.cpp +++ b/core/src/index/knowhere/knowhere/index/vector_index/IndexIVFSQHybrid.cpp @@ -19,6 +19,7 @@ #include "knowhere/index/vector_index/IndexIVFSQHybrid.h" #include "knowhere/adapter/VectorAdapter.h" #include "knowhere/common/Exception.h" +#include "knowhere/index/vector_index/helpers/FaissIO.h" #include @@ -77,6 +78,13 @@ IVFSQHybrid::CopyGpuToCpu(const Config& config) { faiss::Index* device_index = index_.get(); faiss::Index* host_index = faiss::gpu::index_gpu_to_cpu(device_index); + if (auto* ivf_index = dynamic_cast(host_index)) { + if (ivf_index != nullptr) { + ivf_index->to_readonly(); + } + ivf_index->backup_quantizer(); + } + std::shared_ptr new_index; new_index.reset(host_index); return std::make_shared(new_index); @@ -287,6 +295,30 @@ IVFSQHybrid::set_index_model(IndexModelPtr model) { } } +BinarySet +IVFSQHybrid::SerializeImpl() { + if (!index_ || !index_->is_trained) { + KNOWHERE_THROW_MSG("index not initialize or trained"); + } + + if (gpu_mode == 0) { + MemoryIOWriter writer; + faiss::write_index(index_.get(), &writer); + + auto data = std::make_shared(); + data.reset(writer.data_); + + BinarySet res_set; + res_set.Append("IVF", data, writer.rp); + + return res_set; + } else if (gpu_mode == 2) { + return GPUIVF::SerializeImpl(); + } else { + KNOWHERE_THROW_MSG("Can't serialize IVFSQ8Hybrid"); + } +} + FaissIVFQuantizer::~FaissIVFQuantizer() { if (quantizer != nullptr) { delete quantizer; diff --git a/core/src/index/knowhere/knowhere/index/vector_index/IndexIVFSQHybrid.h b/core/src/index/knowhere/knowhere/index/vector_index/IndexIVFSQHybrid.h index 5846d3e5ce..75292fcf5c 100644 --- a/core/src/index/knowhere/knowhere/index/vector_index/IndexIVFSQHybrid.h +++ b/core/src/index/knowhere/knowhere/index/vector_index/IndexIVFSQHybrid.h @@ -81,6 +81,9 @@ class IVFSQHybrid : public GPUIVFSQ { VectorIndexPtr CopyCpuToGpu(const int64_t& device_id, const Config& config) override; + BinarySet + SerializeImpl(); + protected: void search_impl(int64_t n, const float* data, int64_t k, float* distances, int64_t* labels, const Config& cfg) override;