Files
clawhdf5 committer agentandClaude Sonnet 5 377c8b6f17
CI / test (pull_request) Canceled after 0s
fix(accel): restore f32::EPSILON near-zero-denom guard in cosine_similarity
The SIMD migration weakened the near-zero-norm guard in all four
clawhdf5-accel cosine_similarity backends (scalar/avx2/avx512/neon)
from `denom < f32::EPSILON` to `denom == 0.0`. Vectors with a tiny
but nonzero norm (denom in (0, 1.19e-7)) fell through to dot/denom
and scored as identical instead of maximally dissimilar, diverging
from the pre-SIMD scalar loop's documented fallback behavior.

Restores the epsilon threshold in all four backends so
`1.0 - cosine_similarity(...)` in hnsw.rs::compute_distance
reproduces the old fallback exactly. Adds regression tests in
clawhdf5-accel and clawhdf5-ann locking in the near-zero-norm case.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
2026-08-17 13:28:43 +00:00
..
2026-08-16 20:44:28 +00:00

clawhdf5-ann

crates.io docs.rs

HNSW approximate nearest neighbor index stored as HDF5.

Features

  • Build and query HNSW indexes persisted in HDF5 format
  • Pure Rust, no C dependencies
  • Efficient similarity search for high-dimensional vectors

Usage

use clawhdf5_ann::HnswIndex;

let index = HnswIndex::from_hdf5("vectors.h5").unwrap();
let neighbors = index.search(&query, 10);

License

MIT