Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div align=" center">
<div align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://zvec.oss-cn-hongkong.aliyuncs.com/logo/github_log_2.svg" />
<img src="https://zvec.oss-cn-hongkong.aliyuncs.com/logo/github_logo_1.svg" width="400" alt="zvec logo" />
Expand Down
31 changes: 14 additions & 17 deletions cmake/option.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,20 @@ function(_detect_armv8_best)
endfunction()

function(_detect_x86_best)
set(_x86_flags
"graniterapids" "emeraldrapids" "sapphirerapids"
"skylake-avx512" "skylake"
"broadwell" "haswell" "sandybridge" "nehalem"
"znver3" "znver2" "znver1"
)
foreach(_arch IN LISTS _x86_flags)
check_c_compiler_flag("-march=${_arch}" _COMP_SUPP_${_arch})
if(_COMP_SUPP_${_arch})
_AppendFlags(CMAKE_C_FLAGS "-march=${_arch}")
_AppendFlags(CMAKE_CXX_FLAGS "-march=${_arch}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" PARENT_SCOPE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" PARENT_SCOPE)
return()
endif()
endforeach()
message(WARNING "No known x86 microarchitecture flag supported; falling back to generic.")
# Use -march=native to target the actual build machine's CPU.
# The previous approach iterated from highest to lowest arch and checked
# whether the *compiler* accepted the flag β€” but the compiler will accept
# e.g. -march=skylake-avx512 on any machine, which then emits AVX-512
# instructions that crash on CPUs without those extensions (see #128, #92).
check_c_compiler_flag("-march=native" _COMP_SUPP_NATIVE)
if(_COMP_SUPP_NATIVE)
_AppendFlags(CMAKE_C_FLAGS "-march=native")
_AppendFlags(CMAKE_CXX_FLAGS "-march=native")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" PARENT_SCOPE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" PARENT_SCOPE)
return()
endif()
message(WARNING "Compiler does not support -march=native; falling back to generic x86-64.")
endfunction()

if(MSVC)
Expand Down
2 changes: 1 addition & 1 deletion src/ailego/internal/cpu_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ bool CpuFeatures::VMX(void) {
return !!(flags_.L1_ECX & (1u << 5));
}

// !Running on a hypervisor
//! Running on a hypervisor
bool CpuFeatures::HYPERVISOR(void) {
return !!(flags_.L1_ECX & (1u << 31));
}
Expand Down
4 changes: 2 additions & 2 deletions src/ailego/internal/cpu_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class CpuFeatures {
//! Hardware virtualization
static bool VMX(void);

// !Running on a hypervisor
//! Running on a hypervisor
static bool HYPERVISOR(void);

//! Intrinsics of compiling
Expand Down Expand Up @@ -359,7 +359,7 @@ class CpuFeatures {
//! Hardware virtualization
bool VMX = CpuFeatures::VMX();

// !Running on a hypervisor
//! Running on a hypervisor
bool HYPERVISOR = CpuFeatures::HYPERVISOR();
};
static StaticFlags static_flags_;
Expand Down
2 changes: 1 addition & 1 deletion src/core/algorithm/hnsw/hnsw_builder_entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class HnswBuilderEntity : public HnswEntity {
std::string neighbors_buffer_{}; // level 0 neighbors buffer
std::string upper_neighbors_buffer_{}; // upper layer neighbors buffer

std::string sparse_data_buffer_{}; // aligned spase data buffer
std::string sparse_data_buffer_{}; // aligned sparse data buffer
size_t sparse_data_offset_{0}; //

// upper layer offset + level in upper_neighbors_buffer_
Expand Down
2 changes: 1 addition & 1 deletion src/core/algorithm/hnsw/hnsw_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ int HnswContext::init(ContextType type) {
update_heap_.limit(entity_->l0_neighbor_cnt() + 1);
candidates_.limit(max_scan_num_);

check_need_adjuct_ctx();
check_need_adjust_ctx();
break;

default:
Expand Down
6 changes: 3 additions & 3 deletions src/core/algorithm/hnsw/hnsw_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ class HnswContext : public IndexContext {
return level_topks_[level];
}

inline void check_need_adjuct_ctx(void) {
check_need_adjuct_ctx(entity_->doc_cnt());
inline void check_need_adjust_ctx(void) {
check_need_adjust_ctx(entity_->doc_cnt());
}

inline size_t compute_reserve_cnt(uint32_t cur_doc) const {
Expand All @@ -375,7 +375,7 @@ class HnswContext : public IndexContext {
}

//! candidates heap and visitfilter need to resize as doc cnt growing up
inline void check_need_adjuct_ctx(uint32_t doc_cnt) {
inline void check_need_adjust_ctx(uint32_t doc_cnt) {
if (ailego_unlikely(doc_cnt + kTriggerReserveCnt > reserve_max_doc_cnt_)) {
while (doc_cnt + kTriggerReserveCnt > reserve_max_doc_cnt_) {
reserve_max_doc_cnt_ =
Expand Down
8 changes: 4 additions & 4 deletions src/core/algorithm/hnsw/hnsw_streamer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ IndexStreamer::Context::Pointer HnswStreamer::create_context(void) const {
LOG_DEBUG("HnswStreamer doc_count[%zu] estimate[%zu]",
(size_t)entity_.doc_cnt(), (size_t)estimate_doc_count);
}
ctx->check_need_adjuct_ctx(std::max(entity_.doc_cnt(), estimate_doc_count));
ctx->check_need_adjust_ctx(std::max(entity_.doc_cnt(), estimate_doc_count));

return Context::Pointer(ctx);
}
Expand Down Expand Up @@ -466,7 +466,7 @@ int HnswStreamer::add_with_id_impl(uint32_t id, const void *query,
ctx->clear();
ctx->update_dist_caculator_distance(add_distance_, add_batch_distance_);
ctx->reset_query(query);
ctx->check_need_adjuct_ctx(entity_.doc_cnt());
ctx->check_need_adjust_ctx(entity_.doc_cnt());

if (metric_->support_train()) {
const std::lock_guard<std::mutex> lk(mutex_);
Expand Down Expand Up @@ -546,7 +546,7 @@ int HnswStreamer::add_impl(uint64_t pkey, const void *query,
ctx->clear();
ctx->update_dist_caculator_distance(add_distance_, add_batch_distance_);
ctx->reset_query(query);
ctx->check_need_adjuct_ctx(entity_.doc_cnt());
ctx->check_need_adjust_ctx(entity_.doc_cnt());

if (metric_->support_train()) {
const std::lock_guard<std::mutex> lk(mutex_);
Expand Down Expand Up @@ -618,7 +618,7 @@ int HnswStreamer::search_impl(const void *query, const IndexQueryMeta &qmeta,
ctx->clear();
ctx->update_dist_caculator_distance(search_distance_, search_batch_distance_);
ctx->resize_results(count);
ctx->check_need_adjuct_ctx(entity_.doc_cnt());
ctx->check_need_adjust_ctx(entity_.doc_cnt());
for (size_t q = 0; q < count; ++q) {
ctx->reset_query(query);
ret = alg_->search(ctx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class HnswSparseBuilderEntity : public HnswSparseEntity {
std::string neighbors_buffer_{}; // level 0 neighbors buffer
std::string upper_neighbors_buffer_{}; // upper layer neighbors buffer

std::string sparse_data_buffer_{}; // aligned spase data buffer
std::string sparse_data_buffer_{}; // aligned sparse data buffer
size_t sparse_data_offset_{0}; //

// upper layer offset + level in upper_neighbors_buffer_
Expand Down
2 changes: 1 addition & 1 deletion src/core/algorithm/hnsw_sparse/hnsw_sparse_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ int HnswSparseContext::init(ContextType type) {
update_heap_.limit(entity_->l0_neighbor_cnt() + 1);
candidates_.limit(max_scan_num_);

check_need_adjuct_ctx();
check_need_adjust_ctx();
break;

default:
Expand Down
6 changes: 3 additions & 3 deletions src/core/algorithm/hnsw_sparse/hnsw_sparse_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ class HnswSparseContext : public IndexContext {
return level_topks_[level];
}

inline void check_need_adjuct_ctx(void) {
check_need_adjuct_ctx(entity_->doc_cnt());
inline void check_need_adjust_ctx(void) {
check_need_adjust_ctx(entity_->doc_cnt());
}

inline size_t compute_reserve_cnt(uint32_t cur_doc) const {
Expand All @@ -371,7 +371,7 @@ class HnswSparseContext : public IndexContext {
}

//! candidates heap and visitfilter need to resize as doc cnt growing up
inline void check_need_adjuct_ctx(uint32_t doc_cnt) {
inline void check_need_adjust_ctx(uint32_t doc_cnt) {
if (ailego_unlikely(doc_cnt + kTriggerReserveCnt > reserve_max_doc_cnt_)) {
while (doc_cnt + kTriggerReserveCnt > reserve_max_doc_cnt_) {
reserve_max_doc_cnt_ =
Expand Down
6 changes: 3 additions & 3 deletions src/core/algorithm/hnsw_sparse/hnsw_sparse_streamer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ int HnswSparseStreamer::add_with_id_impl(uint32_t id,
sparse_query_buffer);

ctx->reset_query(sparse_query_buffer.data());
ctx->check_need_adjuct_ctx(entity_.doc_cnt());
ctx->check_need_adjust_ctx(entity_.doc_cnt());

level_t level = alg_->get_random_level();
ret =
Expand Down Expand Up @@ -570,7 +570,7 @@ int HnswSparseStreamer::add_impl(uint64_t pkey, const uint32_t sparse_count,
sparse_query_buffer);

ctx->reset_query(sparse_query_buffer.data());
ctx->check_need_adjuct_ctx(entity_.doc_cnt());
ctx->check_need_adjust_ctx(entity_.doc_cnt());

level_t level = alg_->get_random_level();
node_id_t id;
Expand Down Expand Up @@ -637,7 +637,7 @@ int HnswSparseStreamer::search_impl(
ctx->clear();
ctx->update_dist_caculator_distance(search_distance_);
ctx->resize_results(count);
ctx->check_need_adjuct_ctx(entity_.doc_cnt());
ctx->check_need_adjust_ctx(entity_.doc_cnt());

const uint32_t *sparse_indices_tmp = sparse_indices;
const void *sparse_query_tmp = sparse_query;
Expand Down
7 changes: 5 additions & 2 deletions src/core/interface/index.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ int Index::CreateAndInitConverterReformer(const QuantizerParam &param,
} else if (index_param.data_type == DataType::DT_FP32) {
converter_name = "CosineNormalizeConverter";
} else {
LOG_ERROR("Unsupported data type: ");
LOG_ERROR(
"Cosine metric without quantizer only supports FP32 and FP16 "
"data types. For INT8 data, use a quantizer "
"(e.g. QuantizerType::kInt8).");
return core::IndexError_Unsupported;
}
break;
Expand Down Expand Up @@ -769,7 +772,7 @@ int Index::Merge(const std::vector<Index::Pointer> &indexes,
LOG_ERROR("Failed to init reducer");
return core::IndexError_Runtime;
}
if (reducer->set_target_streamer_wiht_info(builder_, streamer_, converter_,
if (reducer->set_target_streamer_with_info(builder_, streamer_, converter_,
reformer_,
input_vector_meta_) != 0) {
LOG_ERROR("Failed to set target streamer");
Expand Down
2 changes: 1 addition & 1 deletion src/core/mixed_reducer/mixed_streamer_reducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int MixedStreamerReducer::cleanup(void) {
return 0;
}

int MixedStreamerReducer::set_target_streamer_wiht_info(
int MixedStreamerReducer::set_target_streamer_with_info(
const IndexBuilder::Pointer builder, const IndexStreamer::Pointer streamer,
const IndexConverter::Pointer converter,
const IndexReformer::Pointer reformer,
Expand Down
2 changes: 1 addition & 1 deletion src/core/mixed_reducer/mixed_streamer_reducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class MixedStreamerReducer : public IndexStreamerReducer {
int dump(const IndexDumper::Pointer &dumper) override;

public: // StreamerReducer's unique methods
int set_target_streamer_wiht_info(
int set_target_streamer_with_info(
const IndexBuilder::Pointer builder,
const IndexStreamer::Pointer streamer,
const IndexConverter::Pointer converter,
Expand Down
2 changes: 1 addition & 1 deletion src/core/quantizer/cosine_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class CosineConverter : public IndexConverter {
IndexMeta::DataType type = meta_.data_type();

if (type != original_type_) {
LOG_ERROR("Orignal Type Not Matched: (%d, %d)", type, original_type_);
LOG_ERROR("Original Type Not Matched: (%d, %d)", type, original_type_);
return IndexError_Mismatch;
}

Expand Down
2 changes: 1 addition & 1 deletion src/db/index/column/vector_column/vector_column_indexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class VectorColumnIndexer {

std::string engine_name_ = "proxima";
bool is_sparse_{false}; // TODO: eliminate the dynamic flag and make it
// static/template/seperate class
// static/template/separate class
};


Expand Down
2 changes: 1 addition & 1 deletion src/include/zvec/core/framework/index_reducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class IndexStreamerReducer : public IndexReducerBase {
//! Index Reducer Pointer
typedef std::shared_ptr<IndexStreamerReducer> Pointer;

virtual int set_target_streamer_wiht_info(
virtual int set_target_streamer_with_info(
const IndexBuilder::Pointer builder,
const IndexStreamer::Pointer streamer,
const IndexConverter::Pointer converter,
Expand Down