Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
59eea4c
refactor: add extra meta size
richyreachy Mar 24, 2026
517ce50
feat: turbo distances
richyreachy Mar 24, 2026
51cc10e
refactor: fix int4 ip
richyreachy Mar 25, 2026
12395f6
refactor: add avx2 int4 l2
richyreachy Mar 25, 2026
1ed3209
refactor: add dist funcs
richyreachy Mar 26, 2026
c6f37d2
refactor: add ut for march
richyreachy Mar 26, 2026
573d585
feat: add turbo ut
richyreachy Mar 27, 2026
fdc0f35
feat: add int8/int4 avx2 sse
richyreachy Mar 27, 2026
7be94e0
feat: add dist
richyreachy Mar 30, 2026
4d21dd8
feat: add dist func
richyreachy Mar 31, 2026
42dd299
feat: add scalar dist funcs
richyreachy Mar 31, 2026
04d86ff
feat: add scalar dist funcs
richyreachy Mar 31, 2026
1958a82
feat: add ut
richyreachy Mar 31, 2026
92340b9
feat: add dist funcs
richyreachy Mar 31, 2026
b748222
feat: add dist funcs
richyreachy Mar 31, 2026
4f885b9
feat: add dist funcs
richyreachy Mar 31, 2026
cf017bc
feat: add dist funcs
richyreachy Mar 31, 2026
faa7e64
feat: add fp16 funcs
richyreachy Mar 31, 2026
c073035
feat: add dist funcs
richyreachy Mar 31, 2026
b6baa89
feat: update ut
richyreachy Apr 1, 2026
83b172c
feat: add dist ut
richyreachy Apr 2, 2026
f9fe8ae
feat: add dist funcs
richyreachy Apr 2, 2026
2b23284
feat: add dist funcs
richyreachy Apr 2, 2026
950c7fd
feat: add cosine and euclidean dist func
richyreachy Apr 2, 2026
5a3bec9
feat: merge main
richyreachy Apr 8, 2026
000a199
refactor: change makefile
richyreachy Apr 9, 2026
27ec0f0
refactor: change makefile
richyreachy Apr 9, 2026
08d995e
fix: fix single dist
richyreachy Apr 10, 2026
b4f4bdc
fix: fix single dist
richyreachy Apr 10, 2026
97455f6
fix: avx512fp16 dist func
richyreachy Apr 13, 2026
1f2b66f
feat: support arm
richyreachy Apr 13, 2026
50fc6d7
feat: add armv8
richyreachy Apr 13, 2026
b0bfa89
feat: add armv8
richyreachy Apr 13, 2026
ebd51ef
feat: add armv8
richyreachy Apr 13, 2026
fe8d72a
fix: armv8
richyreachy Apr 13, 2026
f29d6dd
fix: fix typo
richyreachy Apr 13, 2026
53ffc8e
fix: fix dist
richyreachy Apr 13, 2026
85f8cc6
Merge branch 'main' into refactor/turbo
richyreachy Apr 13, 2026
3e45b87
fix: fix dist
richyreachy Apr 13, 2026
e26610a
fix: vnni inner product
richyreachy Apr 13, 2026
b433e6b
fix: fix batch ut
richyreachy Apr 14, 2026
36c4f4c
feat: add batch ut
richyreachy Apr 14, 2026
895cd78
feat: add batch dist
richyreachy Apr 14, 2026
41efb29
fix: fix batch dist
richyreachy Apr 15, 2026
1d02de3
feat: add quantizer
richyreachy Apr 16, 2026
8686780
feat: add quantizer
richyreachy Apr 16, 2026
7aa0b62
refactor: add quantizer definition
richyreachy Apr 17, 2026
5568416
feat: add record int8 quantizer
richyreachy Apr 17, 2026
37e15ad
feat: add record quantizer
richyreachy Apr 20, 2026
2eb881a
feat: add quantizer
richyreachy Apr 20, 2026
eb91962
feat: add quantizer
richyreachy Apr 20, 2026
7725683
feat: add quantizer
richyreachy Apr 20, 2026
711199e
feat: add int8 quantizer
richyreachy Apr 21, 2026
ad174ba
feat: int8 quantizer
richyreachy Apr 21, 2026
75991a5
feat: int8 quantizer
richyreachy Apr 21, 2026
c5e8236
feat: int8 quantizer
richyreachy Apr 21, 2026
0cd3001
feat: add int4 quantizer
richyreachy Apr 21, 2026
9162016
feat: add int4 quantizer
richyreachy Apr 21, 2026
9839711
feat: add quantizer uts
richyreachy Apr 22, 2026
8ddab15
feat: add quantizer uts
richyreachy Apr 22, 2026
d27026a
feat: add quantizer uts
richyreachy Apr 22, 2026
096eca3
feat: add serialize and deserialize
richyreachy Apr 22, 2026
e71ae68
fix: move distances
richyreachy Apr 22, 2026
daf86d9
fix: update makefile
richyreachy Apr 22, 2026
9a9a6d6
feat: add extra meta size
richyreachy Apr 22, 2026
824ba83
feat: add extra meta size
richyreachy Apr 22, 2026
e1d9314
fix: fix ut
richyreachy Apr 22, 2026
c8b92b5
refactor: meta size
richyreachy Apr 23, 2026
d30c5af
refactor: meta size
richyreachy Apr 23, 2026
717b447
fix: fix uts
richyreachy Apr 24, 2026
aec4665
feat: fix ut bugs
richyreachy Apr 24, 2026
dc0afb5
feat: call distance via quantizer
richyreachy May 8, 2026
eb85056
Merge branch 'main' into refactor/turbo
richyreachy May 8, 2026
ba491ab
feat: call distance via quantizer
richyreachy May 8, 2026
ee48f9e
refactor: use quantizer distance in hnsw
richyreachy May 12, 2026
1a8fce3
refactor: update hnsw
richyreachy May 15, 2026
a4ad022
fix: fix ut errors
richyreachy May 15, 2026
6aef002
fix: fix uts
richyreachy May 19, 2026
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
24 changes: 19 additions & 5 deletions src/core/algorithm/hnsw/hnsw_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,26 @@
namespace zvec {
namespace core {

HnswContext::HnswContext(size_t dimension, const IndexMetric::Pointer &metric,
HnswContext::HnswContext(size_t dimension,
zvec::turbo::Quantizer::Pointer quantizer,
IndexMeta::DataType qmeta_data_type,
const IndexMetric::Pointer &metric,
const HnswEntity::Pointer &entity)
: IndexContext(metric),
entity_(entity),
dc_(entity_.get(), metric, dimension) {}
dc_(entity_.get(), std::move(quantizer), metric, dimension,
qmeta_data_type) {
metric_ = metric;
}

HnswContext::HnswContext(const IndexMetric::Pointer &metric,
HnswContext::HnswContext(zvec::turbo::Quantizer::Pointer quantizer,
const IndexMetric::Pointer &metric,
const HnswEntity::Pointer &entity)
: IndexContext(metric), entity_(entity), dc_(entity_.get(), metric) {}
: IndexContext(metric),
entity_(entity),
dc_(entity_.get(), std::move(quantizer), metric) {
metric_ = metric;
}

HnswContext::~HnswContext() {
visit_filter_.destroy();
Expand Down Expand Up @@ -200,6 +211,7 @@ int HnswContext::update(const ailego::Params &params) {
}

int HnswContext::update_context(ContextType type, const IndexMeta &meta,
zvec::turbo::Quantizer::Pointer quantizer,
const IndexMetric::Pointer &metric,
const HnswEntity::Pointer &entity,
uint32_t magic_num) {
Expand Down Expand Up @@ -251,7 +263,9 @@ int HnswContext::update_context(ContextType type, const IndexMeta &meta,
}

entity_ = entity;
dc_.update(entity_.get(), metric, meta.dimension());
dc_.update(entity_.get(), std::move(quantizer), metric, meta.dimension(),
meta.data_type());
metric_ = metric;
magic_ = magic_num;
level_topks_.clear();

Expand Down
31 changes: 23 additions & 8 deletions src/core/algorithm/hnsw/hnsw_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ class HnswContext : public IndexContext {
kStreamerContext = 3
};

//! Construct
HnswContext(size_t dimension, const IndexMetric::Pointer &metric,
//! Construct with an explicit turbo quantizer (used for building the
//! internal HnswDistCalculator).
HnswContext(size_t dimension, zvec::turbo::Quantizer::Pointer quantizer,
IndexMeta::DataType qmeta_data_type,
const IndexMetric::Pointer &metric,
const HnswEntity::Pointer &entity);

//! Construct
HnswContext(const IndexMetric::Pointer &metric,
//! Construct without dimension (lazy init via update_context).
HnswContext(zvec::turbo::Quantizer::Pointer quantizer,
const IndexMetric::Pointer &metric,
const HnswEntity::Pointer &entity);

//! Destructor
Expand Down Expand Up @@ -113,6 +117,7 @@ class HnswContext : public IndexContext {

//! Update context, the context may be shared by different searcher/streamer
int update_context(ContextType type, const IndexMeta &meta,
zvec::turbo::Quantizer::Pointer quantizer,
const IndexMetric::Pointer &metric,
const HnswEntity::Pointer &entity, uint32_t magic_num);

Expand Down Expand Up @@ -444,10 +449,20 @@ class HnswContext : public IndexContext {
return debug_mode_;
}

inline void update_dist_caculator_distance(
const IndexMetric::MatrixDistance &distance,
const IndexMetric::MatrixBatchDistance &batch_distance) {
dc_.update_distance(distance, batch_distance);
//! Swap the turbo quantizer used by the dist calculator (e.g. when
//! switching between add/search metrics). Caller must then invoke
//! reset_query before using the calculator.
inline void update_dist_caculator_quantizer(
zvec::turbo::Quantizer::Pointer quantizer) {
dc_.update_quantizer(std::move(quantizer));
}

//! Swap the IndexMetric fallback used by the dist calculator (e.g. when
//! switching between add/search metrics for MipsSquaredEuclidean, whose
//! query-time metric is InnerProduct). Caller must then invoke
//! reset_query before using the calculator.
inline void update_dist_caculator_metric(IndexMetric::Pointer metric) {
dc_.update_metric(std::move(metric));
}

//! Get topk
Expand Down
Loading