Commit 6590d25a3 for llama.cpp
commit 6590d25a32de615556e578f6a7848564efc32cb3
Author: Pascal <admin@serveurperso.com>
Date: Mon Nov 9 09:31:13 2026 +0100
tests: bound the test_rope tolerance by the f32 angle resolution (#31874)
The rotation angle of a position p is rounded in f32 to about
p*FLT_EPSILON radians, and the CPU reference and the GPU kernels reach
it through different rounding sequences (cumulative product versus
pow). With positions up to 8192 this puts the NMSE floor between
backends near 8e-8, so the default 1e-7 threshold fails at random on
Metal. Derive the tolerance from n_ctx instead: it stays at 1e-7 for
n_ctx=512 and becomes 9.5e-7 for the YaRN cases at n_ctx=8192.
diff --git a/tests/test-backend-ops.cpp b/tests/test-backend-ops.cpp
index a17f6b43e..bea65c746 100644
--- a/tests/test-backend-ops.cpp
+++ b/tests/test-backend-ops.cpp
@@ -6670,6 +6670,13 @@ struct test_rope : public test_case {
}
}
+ double max_nmse_err() override {
+ // the f32 rotation angle of a position below n_ctx carries a rounding error of up to n_ctx*FLT_EPSILON radians
+ // backends compute the angle with different rounding sequences, so their agreement is bounded by that error
+ const double eps_theta = n_ctx * FLT_EPSILON;
+ return std::max(test_case::max_nmse_err(), eps_theta * eps_theta);
+ }
+
double max_maa_err() override {
return 1e-3;
}