feat(turbo): add int8/int4/fp16 record quantizers with scalar kernels, rework kernel dispatch - #624
Open
JalinWang wants to merge 4 commits into
Open
feat(turbo): add int8/int4/fp16 record quantizers with scalar kernels, rework kernel dispatch#624JalinWang wants to merge 4 commits into
JalinWang wants to merge 4 commits into
Conversation
JalinWang
force-pushed
the
feat/turbo-int8
branch
from
July 28, 2026 08:49
4a6cfd4 to
943aab1
Compare
iaojnh
reviewed
Jul 30, 2026
|
|
||
| // Cache the distance dispatch for the new Quantizer interface. | ||
| auto kernels = | ||
| get_distance_kernels(metric_from_name(metric_name), DataType::kInt8, |
Collaborator
There was a problem hiding this comment.
这里应该需要校验get_distance_kernels是否成功了。
如果失败的话dp_query_func_/dp_query_batch_func_应该全是nullptr,是否符合预期?
| // monotonically equivalent distance (same convention as Fp32Quantizer). | ||
| distance_offset_ = 1.0f; | ||
| extra_meta_size_ += EXTRA_META_SIZE_COSINE; | ||
| } |
Collaborator
There was a problem hiding this comment.
else的情况下,distance_offset_和extra_meta_size_是否需要初始化?
|
|
||
| // Aggregate lookup: resolves dist/batch/preprocess in one pass so callers | ||
| // cannot pair functions from different kernel families. | ||
| DistanceKernels get_distance_kernels( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates the int8/int4 (record-quantized) and fp16 quantizers to the turbo framework, adds portable scalar distance kernels for them, and reworks the kernel dispatch registry so every row serves exactly one explicit
QuantizeType.QuantizeType::kDefaultis now deprecated.What's Changed
Kernel dispatch rework (
turbo.cc)FindKernelarch semantics tightened: scalar rows only matchkAuto/kScalarrequests. An explicit SIMD arch request returns null when that ISA is unavailable, so callers keep their own (possibly SIMD-enabled) fallbacks instead of silently degrading to turbo scalar.kDefaultretirement:QuantizedIntegerMetricnow requestskRecord + CpuArchType::kAVX512VNNIexplicitly. Behavior is unchanged: VNNI machines get the same VNNI kernels as before; non-VNNI machines get null and keep the legacy ailego AVX2-dispatched fallback path.New turbo quantizers
Int8Quantizer/Int4Quantizer(QuantizeType::kRecord): per-record scale/bias tail encoding, distance dispatch cached atinit().Fp16Quantizer(QuantizeType::kFp16).Quantizerbase: ctor now requires an explicitQuantizeType(explicit Quantizer(QuantizeType)); no more implicitkDefault.New scalar distance kernels (universal fallback for non-VNNI targets)
scalar/fp16: cosine / inner-product / squared-euclidean.scalar/record_quantized_int8: same three metrics,dim-20(l2/ip) anddim-24(cosine) record tail layout, formula-identical to the AVX512-VNNI kernels.scalar/record_quantized_int4: same three metrics.Testing
turbo_int8_quantizer_test,turbo_int4_quantizer_test,turbo_fp16_quantizer_test.quantized_integer_metric_test(20),turbo_int8/int4/fp32/fp16_quantizer_test(3/4/2/3), built and run on an AVX512-VNNI machine (covers the VNNI dispatch path).