lattice-simd 0.15.0

SIMD vector math for Lattice: dot product, cosine, L2 and L1 distance, normalization, and INT8/INT4/binary quantized vectors
Documentation
  • Coverage
  • 100%
    98 out of 98 items documented1 out of 6 items with examples
  • Size
  • Source code size: 348.7 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.5 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 4s Average build duration of successful builds.
  • all releases: 5s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • ohdearquant/lattice
    46 6 158
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ohdearquant

lattice-simd

SIMD vector math for Lattice: dot product, cosine similarity, Euclidean and Manhattan distance, L2 normalization, and approximate operations over INT8, INT4 and binary quantized vectors, including tiered storage with prepared queries.

Kernels cover AVX-512, AVX2+FMA, NEON and WASM SIMD128, with a scalar fallback for every operation. On x86_64 and aarch64 the kernel is chosen at runtime from the detected CPU features (SimdConfig); on wasm32 it is chosen at compile time from target_feature = "simd128".

The crate has no internal dependencies. lattice-embed re-exports it as lattice_embed::simd, so code written against either path uses the same items.

use lattice_simd::{cosine_similarity, dot_product, normalize};

let mut a = vec![1.0_f32, 2.0, 3.0];
let b = vec![3.0_f32, 2.0, 1.0];
let dot = dot_product(&a, &b);
let cos = cosine_similarity(&a, &b);
normalize(&mut a);
assert!(dot > 0.0 && cos > 0.0);

The SIMD surface is marked unstable. See docs/simd.md for the kernel family, dispatch, numerical behaviour and the quantized-vector formats.

Crate reference

The sections below are generated by scripts/crate-readme.py from the source tree and are refreshed after pushes to main. Text between the generated markers is overwritten; edit the source or the script instead.

Facts

Source layout

The tracked files under src/; each Rust file shows the first sentence of its //! module documentation.

  • binary.rs: Binary sign quantization and Hamming-distance operations.
  • binary/
    • tests.rs
  • cosine.rs: SIMD cosine-similarity kernels and batch variants.
  • distance.rs: SIMD Euclidean and squared-Euclidean distance kernels.
  • dot_product.rs: SIMD float dot-product kernels, including a one-query/four-candidate path.
  • error.rs: Errors returned by prepared quantized-tier operations.
  • int4.rs: INT4 packed-vector quantization and approximate dot products.
  • int4/
    • tests.rs
  • lib.rs: SIMD vector operations for embedding similarity and compressed-vector search.
  • manhattan.rs: SIMD Manhattan (L1) distance kernels.
  • normalize.rs: SIMD in-place L2 normalization kernels.
  • quantized.rs: INT8 vector quantization and approximate similarity kernels.
  • quantized/
    • simd_parity_tests.rs
  • tests.rs: Tests for SIMD operations.
  • tier.rs: Quantization tiers, prepared queries, and unified distance dispatch.
  • tier/
    • tests.rs

Targets declared by the manifest, including the ones Cargo discovers by directory:

  • lib (1): lattice_simd

Statistics

Rust lines by kind (code, comment, blank; doc comments count as comment), test functions (#[test] and #[<runtime>::test] attributes), items declared pub (not pub(crate); reachability through private modules is not resolved) and occurrences of the unsafe keyword outside comments and strings.

Area Files Code Comment Blank Tests pub items unsafe
src/ 16 6524 1049 1105 131 105 106
total 16 6524 1049 1105 131 105 106

Other tracked files (the README excluded):

Extension Files Size
.md 1 26.4 KiB
.toml 1 600 B

In-crate documentation

Features

The manifest declares no features.

Workspace dependencies

  • Depends on: no other crate in this workspace
  • Used by: lattice-embed

Architecture decisions

No ADR under docs/adr/ names lattice-simd or crates/simd/.

Benchmarks

No CI benchmark data for this crate: bench-update.yml records only lattice-embed simd, lattice-inference elementwise_cpu_bench.