Skip to main content

APPROX_REL_TOL

Constant APPROX_REL_TOL 

Source
pub const APPROX_REL_TOL: f64 = 1e-6;
Expand description

The relative tolerance a NumericsClaim::Approx program’s rewrite is discharged against.

★ WHY EXACTNESS IS THE WRONG QUESTION FOR SOME REWRITES. Fusing two stages removes a round trip: the inner result stays in the destination registers instead of being packed to a buffer and unpacked again. That is a REAL change to the arithmetic — it rounds LESS — so a fused kernel and its unfused source differ in the last bits BY CONSTRUCTION. Demanding == would forbid the optimization; waving it through unchecked would let a genuinely wrong rewrite hide behind “floating point”. So the program’s own declared claim decides which question is asked: Exact uses equivalent_under, Approx uses equivalent_within.

This bound is ~1e-6 relative — about eight fp32 ulps, and four orders of magnitude tighter than the bf16 ulp (~4e-3) a wrong answer would have to hide inside.