near_vector distance cutoff is not applied for subnormal cutoff values (< f32 min normal)
How to reproduce this bug?
Weaviate 1.39.4; see reproduce.py: flat index, L2-squared, three vectors
[1e-20,0,0,0], [3e-20,0,0,0], [1e-19,0,0,0], query [0,0,0,0] with
decreasing cutoffs.
What is the expected behavior?
Cutoff membership must be consistent with the distances the engine itself
reports: {results} == {p : distance(p) <= cutoff}. The failure boundary exactly
at the f32 minimum normal suggests the cutoff is flushed/lost in an f32
conversion on the request path (while the distance computation path handles
subnormals correctly).
What is the actual behavior?
nearVector(distance=X) filters nothing when X < ~1.18e-38 (the float32 minimum
normal): every point is returned regardless of its distance, even though the engine
reports the correct subnormal distances for the same query. Cutoffs at or above
the f32 minimum normal work correctly.
stored squared distances: 1e-40, 9e-40, 1e-38 (all reported exactly)
cutoff 4e-40 -> returns all 3 points (expected only pid 0)
cutoff 5e-40 -> returns all 3 (expected [0])
cutoff 2e-39 -> returns all 3 (expected [0, 1])
cutoff 1e-38 -> returns all 3 (expected [0, 1, 2]) OKSupporting information
- Weaviate server: 1.39.4
- weaviate-client: 4.23.1
- Python: 3.12.14
- OS: Windows-11-10.0.26200-SP0
- Vector index: flat
- Distance metric: l2-squared
Server Version
1.39.4
Weaviate Setup
Single Node
Nodes count
1
Code of Conduct
- I have read and agree to the Weaviate's Contributor Guide and Code of Conduct
Source: weaviate/weaviate