Skip to content

feat(quantization): add uniform uint4 reformer/quantizer - #698

Open
JalinWang wants to merge 3 commits into
alibaba:mainfrom
JalinWang:feat/uniform-uint4-main
Open

feat(quantization): add uniform uint4 reformer/quantizer#698
JalinWang wants to merge 3 commits into
alibaba:mainfrom
JalinWang:feat/uniform-uint4-main

Conversation

@JalinWang

Copy link
Copy Markdown
Collaborator

Followup of #608. Provide better precision & performance trade-off on some datasets along with refining.

@JalinWang
JalinWang requested a review from luoxiaojian August 25, 2026 07:39
@JalinWang
JalinWang marked this pull request as ready for review August 26, 2026 09:15
@JalinWang
JalinWang force-pushed the feat/uniform-uint4-main branch from 077333b to ed8c3a3 Compare August 26, 2026 11:20
const auto source_type = source_meta.data_type();
const bool is_fp32 = source_type == IndexMeta::DataType::DT_FP32;
const bool is_native_flat =
accept_native_flat && source_type == IndexMeta::DataType::DT_FP16;

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.

same wrapper for fp16 as fp32 does?

}
row = decoded.data();
} else {
const auto *input = static_cast<const uint8_t *>(source_row);

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.

这段代码执行不到,上面限定了fp32和fp16,可以先删除,如果限定放开,再添加

Comment thread src/turbo/turbo.cc

UniformQuantizeFunc get_uniform_quantize_func(DataType data_type) {
if (data_type == DataType::kInt8) {
if (data_type == DataType::kUint7) {

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.

pass out:

if (zvec::ailego::internal::CpuFeatures::static_flags_.AVX512_VNNI) {
  return avx512_vnni::uniform_uint7_quantize;
}


#include "avx512_vnni/uniform_uint4/quantize.h"

#if defined(__AVX512F__) || (defined(_MSC_VER) && defined(__AVX512F__))

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.

the second part is redundant. can remove it.

~UniformUint4Converter() override = default;

int init(const IndexMeta &index_meta, const ailego::Params &params) override {
if (index_meta.data_type() != IndexMeta::DataType::DT_FP32 ||

@richyreachy richyreachy Aug 27, 2026

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.

in uint8 uniform, there is a valid check statement as follows:

if (original_dimension_ == 0 || original_dimension_ > MAX_DIMENSION) {
  LOG_ERROR("UniformUint8Converter: dimension=%zu must be in [1, %d]",
                original_dimension_, MAX_DIMENSION);
      return IndexError_InvalidArgument;
}

better check it overall in this pr to keep consistency:

  1. return value: IndexError_InvalidArgument
  2. MAX DIMENSION check

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.

2 participants