Fix Faiss fp16 parity tests across architectures (#5695)

Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5695

Correct GPU tests to decode the exact packed fp16 values passed to `search_ex`; the generic software converter and legacy `roundToHalf` disagree on half-way ties. Keep labels exact while comparing CPU distances with the normal scaled `1e-5` BLAS/SIMD tolerance.

___

Differential Revision: D122785161

fbshipit-source-id: 057ded12bdc018add4bef39e514217b83b59c2cb
This commit is contained in:
Jaeyoon Jeong
2026-10-01 07:33:29 -07:00
committed by meta-codesync[bot]
parent 430a41ee4c
commit 38460ee969
2 changed files with 19 additions and 4 deletions
+9 -2
View File
@@ -8,6 +8,7 @@
#include <omp.h>
#include <algorithm>
#include <atomic>
#include <cmath>
#include <cstddef>
#include <limits>
#include <map>
@@ -1165,8 +1166,14 @@ TEST(IndexFlat, search_ex_float16_native_matches_float32) {
hi.data());
EXPECT_EQ(hi, fi)
<< "metric=" << metric << " d=" << d << " k=" << k;
EXPECT_EQ(hd, fd)
<< "metric=" << metric << " d=" << d << " k=" << k;
for (size_t i = 0; i < fd.size(); ++i) {
EXPECT_NEAR(
hd[i],
fd[i],
1e-5f * std::max(1.0f, std::fabs(fd[i])))
<< "metric=" << metric << " d=" << d << " k=" << k
<< " result=" << i;
}
}
}
}