Expand description
SIMD vector operations for embedding similarity and compressed-vector search.
Dispatch uses the best supported target kernel with scalar fallbacks; WASM SIMD128 is selected at compile time. The public SIMD surface is unstable.
See docs/simd.md for the kernel family, dispatch, and quantization design.
Structs§
- Binary
Vector - Unstable: binary quantization format and struct layout are under active design.
- Int4
Params - Unstable: INT4 quantization internals; scale/bias scheme may change.
- Int4
Vector - Unstable: INT4 quantization format is under active design; struct layout may change.
- Prepared
Query With Meta - A prepared query with caller-provided normalization metadata.
- Quantization
Params - Unstable: INT8 quantization parameters; scale/bias scheme may change.
- Quantized
Vector - Unstable: INT8 quantized vector; struct layout and invariants may change.
- Simd
Config - Unstable: SIMD dispatch internals; fields may be added as new ISAs are supported.
Enums§
- Normalization
Hint - Caller assertion that a vector is L2-unit-normalized (norm ≈ 1).
- Prepared
Query - Unstable: pre-quantized query for repeated same-tier distance computation.
- Quantization
Tier - Unstable: tier design is under active iteration; tier boundaries may change.
- Quantized
Data - Unstable: unified quantized data container; variants may change with tier redesign.
Functions§
- approximate_
cosine_ distance - Unstable: quantizes an
f32query and computes tiered cosine distance. - approximate_
cosine_ distance_ prepared - Unstable: computes prepared cosine distance in
[0, 2]for matching tiers. - approximate_
cosine_ distance_ prepared_ with_ meta - Computes prepared cosine distance; hints are accepted but do not select a separate code path.
- approximate_
dot_ product - Unstable: approximate tiered dot-product dispatch.
- approximate_
dot_ product_ prepared - Unstable: computes a prepared dot product for matching non-binary tiers.
- approximate_
int4_ batch_ prepared - Computes distances from one prepared INT4 query without re-quantizing it.
- approximate_
int4_ batch_ prepared_ into - Writes prepared INT4 distances into a reusable buffer, clearing it on error.
- approximate_
int8_ batch_ prepared - Computes distances from one prepared INT8 query without re-quantizing it.
- approximate_
int8_ batch_ prepared_ into - Writes prepared INT8 distances into a reusable buffer, clearing it on error.
- batch_
approximate_ cosine_ distance_ prepared - Computes distances from one prepared query to all stored vectors.
- batch_
approximate_ cosine_ distance_ prepared_ into - Writes prepared-query distances into a reusable buffer, clearing it on error.
- batch_
cosine_ one_ vs_ many - Unstable: one-query/many-candidate cosine similarity.
- batch_
cosine_ similarity - Unstable: batched cosine dispatch; callers supply normalization knowledge.
- batch_
dot_ product - Unstable: batched dot-product dispatch with a same-query fast path.
- cosine_
similarity - Computes cosine similarity, returning
0.0for a mismatch, empty input, or zero norm. - cosine_
similarity_ fused - Unstable: fused single-pass cosine similarity.
- cosine_
similarity_ i8 - Unstable: SIMD INT8 cosine similarity; norm storage approach may change.
- cosine_
similarity_ pre_ normalized - Cosine similarity against a query whose norm the caller already knows.
- dot_
product - Computes the float dot product, returning
0.0for a dimensional mismatch. - dot_
product_ batch4 - Compute dot product of one query against 4 candidates simultaneously.
- dot_
product_ i8 - Unstable: computes an approximate float dot product, returning
0.0for a mismatch. - dot_
product_ i8_ raw - Unstable: computes an unscaled raw INT8 dot product, returning
0.0for a mismatch. - euclidean_
distance - Computes Euclidean (L2) distance, returning
f32::MAXfor a dimensional mismatch. - is_
unit_ norm - Returns
truewhen the squared norm ofvis within 1e-4 of 1.0. - manhattan_
distance - Computes Manhattan (L1) distance, the sum of absolute per-element differences.
- normalize
- Unstable: SIMD dispatch layer; use
lattice_embed::utils::normalizefor the stable wrapper. - prepare_
query - Prepare a query vector for repeated distance computation against a homogeneous tier.
- prepare_
query_ with_ norm - Prepare a query annotated with the given normalization hint.
- query_
norm - The query-side norm for
cosine_similarity_pre_normalized. - resolved_
dot_ product_ batch4_ kernel - Resolve the best available batch-4 f32 dot-product kernel once and return it.
- resolved_
dot_ product_ kernel - Resolve the best available f32 dot-product kernel once and return it.
- resolved_
i8_ dot_ kernel - Return the cached INT8 dot-product kernel for tight loops.
- simd_
config - Unstable: SIMD dispatch internal; shape may change as new backends are added.
- squared_
euclidean_ distance - Computes squared Euclidean distance without a square root.
- try_
approximate_ cosine_ distance_ prepared - Alias for
approximate_cosine_distance_preparedretained for compatibility. - try_
approximate_ dot_ product_ prepared - Alias for
approximate_dot_product_preparedretained for compatibility.
Type Aliases§
- DotBatch4
Kernel - SIMD kernel type for batch-4 f32 dot product.
- DotKernel
- SIMD kernel function pointer type for f32 dot product.
- I8Dot
Kernel - INT8 dot-product kernel function pointer type.