diff --git a/CHANGELOG.md b/CHANGELOG.md index d5b4998cb8790dbf5ce35831e62de4734f895830..b4ebd329aa8b43be28503c6a1e1c0cb85bb00e2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ Please mark all change in change log and use the issue from GitHub - \#1546 Move Config.cpp to config directory - \#1547 Rename storage/file to storage/disk and rename classes - \#1548 Move store/Directory to storage/Operation and add FSHandler +- \#1649 Fix Milvus crash on old CPU ## Task diff --git a/core/src/index/thirdparty/faiss/FaissHook.cpp b/core/src/index/thirdparty/faiss/FaissHook.cpp index 0e462e4dd46fb1698fa0ab6ec40b59bcd7de66b4..08e70469426654a1339374cc10d5f3cb7fd965e8 100644 --- a/core/src/index/thirdparty/faiss/FaissHook.cpp +++ b/core/src/index/thirdparty/faiss/FaissHook.cpp @@ -48,7 +48,7 @@ bool support_sse() { return (instruction_set_inst.SSE()); } -std::string hook_init() { +bool hook_init(std::string& cpu_flag) { static std::mutex hook_mutex; std::lock_guard lock(hook_mutex); @@ -64,8 +64,7 @@ std::string hook_init() { sq_get_distance_computer_IP = sq_get_distance_computer_IP_avx512; sq_sel_quantizer = sq_select_quantizer_avx512; - std::cout << "FAISS hook AVX512" << std::endl; - return "AVX512"; + cpu_flag = "AVX512"; } else if (support_avx()) { /* for IVFFLAT */ fvec_inner_product = fvec_inner_product_avx; @@ -78,8 +77,7 @@ std::string hook_init() { sq_get_distance_computer_IP = sq_get_distance_computer_IP_avx; sq_sel_quantizer = sq_select_quantizer_avx; - std::cout << "FAISS hook AVX" << std::endl; - return "AVX"; + cpu_flag = "AVX"; } else if (support_sse()) { /* for IVFFLAT */ fvec_inner_product = fvec_inner_product_sse; @@ -92,12 +90,13 @@ std::string hook_init() { sq_get_distance_computer_IP = sq_get_distance_computer_IP_sse; sq_sel_quantizer = sq_select_quantizer_sse; - std::cout << "FAISS hook SSE" << std::endl; - return "SSE"; + cpu_flag = "SSE"; } else { - FAISS_ASSERT_MSG(false, "CPU not supported!"); - return "UNSUPPORTED"; + cpu_flag = "UNSUPPORTED"; + return false; } + + return true; } } // namespace faiss diff --git a/core/src/index/thirdparty/faiss/FaissHook.h b/core/src/index/thirdparty/faiss/FaissHook.h index 11666f966f7412d9119895d93610d5a2b7bc85ce..ca2a421ccd7cf84c9f16649cc51e683a2e8a2b8c 100644 --- a/core/src/index/thirdparty/faiss/FaissHook.h +++ b/core/src/index/thirdparty/faiss/FaissHook.h @@ -29,6 +29,6 @@ extern sq_sel_func_ptr sq_sel_quantizer; extern bool support_avx512(); -extern std::string hook_init(); +extern bool hook_init(std::string& cpu_flag); } // namespace faiss diff --git a/core/src/wrapper/KnowhereResource.cpp b/core/src/wrapper/KnowhereResource.cpp index 734272abb35ec1911be1868358b45dfd9dbb5f76..3e4888b7d09dc1a0e75d1fd033705f49339d2cc6 100644 --- a/core/src/wrapper/KnowhereResource.cpp +++ b/core/src/wrapper/KnowhereResource.cpp @@ -17,6 +17,7 @@ #include "config/Config.h" #include "faiss/FaissHook.h" #include "scheduler/Utils.h" +#include "utils/Error.h" #include "utils/Log.h" #include @@ -37,8 +38,12 @@ KnowhereResource::Initialize() { bool use_avx512 = true; CONFIG_CHECK(config.GetEngineConfigUseAVX512(use_avx512)); faiss::faiss_use_avx512 = use_avx512; - std::string type = faiss::hook_init(); - ENGINE_LOG_DEBUG << "FAISS hook " << type; + std::string cpu_flag; + if (faiss::hook_init(cpu_flag)) { + ENGINE_LOG_DEBUG << "FAISS hook " << cpu_flag; + } else { + return Status(KNOWHERE_UNEXPECTED_ERROR, "FAISS hook fail, CPU not supported!"); + } #ifdef MILVUS_GPU_VERSION bool enable_gpu = false;