Skip to content

refactor: turbo quantizer#546

Open
richyreachy wants to merge 25 commits into
alibaba:mainfrom
richyreachy:refactor/turbo_quantizer
Open

refactor: turbo quantizer#546
richyreachy wants to merge 25 commits into
alibaba:mainfrom
richyreachy:refactor/turbo_quantizer

Conversation

@richyreachy

Copy link
Copy Markdown
Collaborator

This PR introduces a pluggable Quantizer abstraction in the Turbo module and provides the first concrete implementation along with scalar fp32 distance kernels.

The goal is to establish a uniform interface that future quantizers (int8 uniform, int8 record, PQ, RaBitQ, …) can implement, decoupling quantization logic from index builders and searchers.

As parts of the initial concept introduction of Turbo, the inclusive changes are as follows:

  1. New Quantizer abstract base class
  2. DistanceImpl callable distance handle
  3. Fp32Quantizer first concrete implementation
  4. Scalar Fp32 distance kernels
  5. IndexMeta and IndexQueryMeta extensions
  6. IndexFactory quantizer support

Comment thread src/include/zvec/turbo/turbo.h Outdated
unit_size_ = format->unit_size;
element_size_ = IndexMeta::ElementSizeof(data_type_, unit_size_, dimension_);
space_id_ = format->space_id;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里为何没有extra_meta_size的解析?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -586,6 +602,7 @@ class IndexMeta {
uint32_t dimension_{0};
uint32_t unit_size_{0};
uint32_t element_size_{0};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么IndexMeta的element_size需要加上extra_meta_size而IndexQueryMeta的不用

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added


#pragma once

#include <turbo/quantizer/quantizer.h>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的依赖关系有点乱,需要关注下

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

turbo/quantizer做为基础类,可以看做和index类是并行的。

Comment thread src/turbo/turbo.cc
}
}
if (quantize_type == QuantizeType::kUniform) {
if (zvec::ailego::internal::CpuFeatures::static_flags_.AVX512_VNNI) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

当调用方显式传 cpu_arch_type = kScalar时,上面的kDefault 会正确回退到nullptr,但 kUniform 仍会返回 VNNI 内核,行为不一致。建议对齐条件,或加注释说明 uniform 为何不受 arch 约束。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants