feat(turbo): add int8/int4/fp16 record quantizers with scalar kernels, rework kernel dispatch - #624
Merged
Merged
Conversation
JalinWang
force-pushed
the
feat/turbo-int8
branch
from
July 28, 2026 08:49
4a6cfd4 to
943aab1
Compare
iaojnh
reviewed
Jul 30, 2026
richyreachy
reviewed
Jul 30, 2026
Per review: if get_distance_kernels returns an incomplete kernel set (dist or batch missing, e.g. Euclidean/MipsSquaredEuclidean have no dispatch rows), init() now logs an error and returns kErrUnsupported instead of leaving the cached distance functions null and silently returning 0 distances.
Per review: - Remove the deprecated kDefault enumerator (no references remain); remaining enumerators keep their numeric values (kUniform = 1) since QuantizerSerHeader.quant_type reserves them for serialization. - Add missing ZVEC_TURBO_API to get_distance_kernels and get_rotator_kernels for consistent symbol export.
# Conflicts: # src/include/zvec/turbo/turbo.h # src/turbo/distance/scalar/fp16/cosine.cc # src/turbo/distance/scalar/fp16/cosine.h # src/turbo/distance/scalar/fp16/inner_product.cc # src/turbo/distance/scalar/fp16/inner_product.h # src/turbo/distance/scalar/fp16/squared_euclidean.cc # src/turbo/distance/scalar/fp16/squared_euclidean.h # src/turbo/turbo.cc
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).