You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improvements to check.expect_almost_eq and FP8 support (#20198)
1. The fuzzy comparison used in `check.expect_almost_eq` is changed from
a single absolute `tolerance` to a two-parameter (`atol`, `rtol`)
NumPy-compatible fuzzy comparison: `abs(lhs - rhs) <= atol + rtol *
abs(rhs)`. The new `rtol` parameter defaults to 0 to preserve existing
behavior. The custom parser/printer are dropped, reverting to
default-generated.
2. Fixed comparisons of `NaN`'s, which were silently *passing*
comparison to anything else! The problem was that the implementation in
modules/check/module.cc was using the negated condition: `if (abs(lhs -
rhs) > tolerance) return false;`. Since all expressions involving `NaN`
evaluate to `false`, that ensured that as long as `lhs` or `rhs` was
`NaN`, we wouldn't return `false`. Generally, `NaN` semantics break
symmetry under negation, so a good rule to take away from this is to
avoid negating boolean expressions that involve floating-point values.
3. Dropped the test
`tests/e2e/regression/disable_demote_f64_to_f32.mlir`. It isn't needed
anyway as we by now have a number of tests relying on the flag in
question - it is necessary in any test exercising f64.
* The reason to drop this test now is that it was actually relying on
the buggy handling of NaN (above point 2.). It was producing NaN's and
was only passing its own checks thanks to that bug.
* Note that that is the same test that #20177 fixed undefined behavior
in.
5. Added support for bf16 and all the fp8 types both in
`check.expect_almost_eq` and in general (`string_util.c`) printing.
6. Printing more helpful diagnostics on failures of fuzzy comparisions,
giving details about the first array position that fails the
comparision, otherwise on large arrays it is hard or impossible to tell
the issue from the debug output.
* Example: `Expected near equality of these values. Contents does not
match to tolerance parameters atol=0.01, rtol=0. The first failure
occurs at index 0 as the lhs value 1 differs from the rhs value 0.98.`
---------
Signed-off-by: Benoit Jacob <jacob.benoit.1@gmail.com>
0 commit comments