facebookresearch / faiss

A library for efficient similarity search and clustering of dense vectors.
https://faiss.ai
MIT License
31.61k stars 3.65k forks source link

compare difference between distances of (x-c1) and (x-c2) is weird #3268

Open simshi opened 9 months ago

simshi commented 9 months ago

Summary

in compareLists(): https://github.com/facebookresearch/faiss/blob/abff75ef078aa7b2258c5ea965f2353691c71b42/faiss/gpu/test/TestUtils.cpp#L259-L268

while ref index is not equal with test index, comparing refD with testD would like comparing apple and orange, the distances are || vectorX - C[it->second] || and || vectorX - C[result]||

suggest move this code block into if (it != indices.end()){ ... }, and change to refD = lookup(refDist, query, it->second, dim1, dim2)

Platform

OS: Ubuntu 22.04

Faiss version: master

Installed from: conda

Faiss compilation options:

Running on:

Interface:

Reproduction instructions

I remember it was found by running build/faiss/gpu/test/TestIVFPQ largebatch, but the env is lost, so not sure the exact config...

simshi commented 9 months ago

while EXPECT_LE(relErr, maxRelativeError) is failed, the stats printed below shows only tiny difference in result, about 0.1%, so I think this is an issue