Expand description
v6.0.0 — SQ8 scalar quantization for vector columns.
Per-vector affine f32 → u8 quantization. Each Sq8Vector carries its
own (min, max) so quantization is purely streaming — no two-pass
corpus scan needed to learn global parameters. Trade-off: 8 bytes
overhead per vector (negligible at dim ≥ 64) in exchange for
INSERT-time simplicity.
This file is the v6.0.0 standalone module: types + quantize /
dequantize + ADC distance + serde + recall oracle. Integration with
DataType::Vector + HNSW write path lands in v6.0.1.
Structs§
- Sq8Vector
- SQ8-quantized vector: every dimension stored as one byte plus a shared (min, max) reconstruction frame.
Enums§
- Quantize
Error - Error type for
Sq8Vectorbyte-encoding parse failures.
Functions§
- dequantize
- Reconstruct the approximate f32 vector. For a vector with
max == min(constant or single-element input) every component reconstructs asminexactly. - quantize
- Quantize an f32 vector to SQ8 using per-vector affine mapping.
- sq8_
cosine_ distance - Symmetric cosine distance
1 - dot / (||a|| ||b||). Zero-norm operand yieldsf32::INFINITYso it sorts last (matches the f32cosine_distanceineval.rs). - sq8_
cosine_ distance_ asymmetric - Asymmetric cosine distance against an un-quantized query. v6.0.2: aarch64 NEON path for the three accumulators; norm-sqrt + zero- guard stays in this safe wrapper.
- sq8_
inner_ product - Symmetric inner product, returned negated so smaller = closer
(matches pgvector
<#>and SPG’sNswMetric::InnerProduct). - sq8_
inner_ product_ asymmetric - Asymmetric inner product (negated). v6.0.2: aarch64 NEON path
under the same
dim >= 16 && dim % 16 == 0pre-condition as the L2 asymmetric variant. - sq8_
l2_ distance_ sq - Symmetric L2² distance between two SQ8 vectors of equal dim.
Returns
f32::INFINITYon dim mismatch (mirrorsvec_l2_sq’s behaviour inlib.rs). - sq8_
l2_ distance_ sq_ asymmetric - Asymmetric L2² between a stored SQ8 vector and an un-quantized
query vector. Same semantics as
vec_l2_sqfor the kNN scan case (one query, many vectors).