Expand description
§slate-simd
SIMD distance kernels for Slate-ANN with runtime CPU-feature dispatch.
Provides L2², inner-product, and cosine distance over f32, plus
asymmetric f32-query vs narrow-stored kernels (distance_f16,
distance_i8) that widen the on-disk representation inside the SIMD
reduction so narrow stores skip a decode-to-f32 pass. Four implementation
tiers are selected at runtime — AVX-512, AVX2+FMA, ARM NEON, and a portable
scalar fallback (also the correctness oracle for the vectorized paths).
§Ranking convention
Mirrors slate_core::Metric: all distances rank by ascending score
(smaller = closer).
l2_sq— squared Euclidean (nosqrt; preserves ordering).inner_product— negated dot product (−⟨a,b⟩).cosine—1 − cos(a,b)over raw inputs;cosine_normalizedis the cheaper1 − ⟨a,b⟩for pre-normalized inputs.
§Safety model
Vectorized kernels use #[target_feature] intrinsics (unsafe). They are
only ever invoked behind the runtime dispatcher in [dispatch], which
confirms CPU support before selecting a tier. The public API below is
entirely safe and validates that input slices have equal length.
Populated in Phase 1 (f32 kernels + dispatch); narrow-store kernels added in the Phase-9.5 deferred clean-ups.
Modules§
- scalar
- Scalar reference kernels.
Enums§
- Tier
- Which implementation tier the dispatcher selected for this CPU.
Functions§
- active_
tier - The cached active tier for this process.
- cosine
- Cosine distance
1 − cos(a,b)over raw (un-normalized) inputs. - cosine_
normalized - Cosine distance for pre-normalized inputs:
1 − ⟨a,b⟩. - detect_
tier - Detect the best tier supported by the current CPU.
- distance
- Dispatch a distance computation by
slate_core::Metric. - distance_
f16 - Distance between an
f32query and anf16-stored vector, byMetric. - distance_
i8 - Distance between an
f32query and ani8-stored vector, byMetric. - dot
- Raw inner product
⟨a,b⟩(not negated), dispatched to the best tier. - inner_
product - Inner-product distance
−⟨a,b⟩, dispatched to the best available tier. - l2_sq
- Squared Euclidean (L2²) distance, dispatched to the best available tier.