Skip to main content

Module kernel

Module kernel 

Source
Expand description

VectorKernel trait — the pluggable execution backend for RaBitQ scan + rerank. Defined here (ADR-157 §“Where each piece lives”) because kernels are RaBitQ primitives; the cache is a consumer.

Ships with one implementation — CpuKernel — which delegates to the existing RabitqPlusIndex::search_with_rerank. GPU / SIMD / WASM kernels live in separate crates (ruvector-rabitq-cuda etc.) and register themselves with the caller (e.g. ruvector-rulake’s dispatcher) as optional accelerators.

§Determinism contract

Scan-phase output (top-k by 1-bit Hamming distance) must be bit-reproducible across every kernel. Rerank-phase output (exact L2²) may differ in the last ulp on reduction-order-sensitive kernels (GPU with float reduction reorder); these set caps().deterministic = false, and the caller’s dispatch policy filters them out of Consistency::Fresh / Consistency::Frozen paths.

The witness chain is NOT recomputed per kernel; it stays anchored on (data_ref, dim, rotation_seed, rerank_factor, generation). Kernel identity is surfaced in caps + stats, not in the witness.

Structs§

CpuKernel
Reference CPU kernel. Wraps RabitqPlusIndex::search_with_rerank. Deterministic by construction (integer popcount scan + stable exact L2² rerank with total-order tie break via position).
KernelCaps
Capability advertisement for a vector kernel. The caller’s dispatch policy compares these against the request to pick the best kernel for a given batch + determinism requirement.
ScanRequest
A batch of query vectors against a single index. The index is borrowed by reference so GPU kernels don’t need to own its lifetime — the cache holds the authoritative copy.

Traits§

VectorKernel
A vector kernel executes scan + exact rerank for one or more queries against a compressed RaBitQ index.

Type Aliases§

ScanResponse
Batched top-k results, one Vec<SearchResult> per query. Order matches the input queries.