8000 xls/dslx/stdlib/tests: Fix silent no-op and masked-bug issues in C++ float tests. by copybara-service[bot] · Pull Request #5469 · google/xls · GitHub
[go: up one dir, main page]

Skip to content

xls/dslx/stdlib/tests: Fix silent no-op and masked-bug issues in C++ float tests. - #5469

Draft
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_1023920433
Draft

copybara-service[bot] wants to merge 1 commit into
mainfrom
test_1023920433

Conversation

@copybara-service
@copybara-service copybara-service Bot commented Nov 19, 2026 •
Copy link
Copy Markdown

xls/dslx/stdlib/tests: Fix silent no-op and masked-bug issues in C++ float tests.

Several existing C++ floating-point tests and testbench helpers silently masked
correctness bugs or failed to exercise edge-case inputs: TestbenchBuilder's
default GenerateRandomValue<T> template was an empty no-op for unsupported
types (causing bfloat16_mul_test_cc to test (0.0, 0.0) 1M times), the FMA
tests filtered out all exp == 0 inputs (masking signed-zero bugs), and
CompareResultsWith1PercentMargin omitted std::abs (passing any overestimate,
including the ~55% error on bexp == 1 inputs in float32::fast_rsqrt).

  • Replace the silent no-op GenerateRandomValue fallback in
    xls/tests/testbench_builder_utils.h with LOG(FATAL), add a uint16_t
    specialization, and add unit tests in testbench_builder_utils_test.cc.
  • Use uint16_t tuple inputs (bijective enumeration for exhaustive runs,
    TestbenchBuilder's default random generator otherwise), sign-preserving
    subnormal flushing, canonical +qNaN verification, printers, and correct
    (ComputeExpected, ComputeActual) argument order in bfloat16_mul_test.cc.
  • Cover ±0.0, subnormals, infinities, and NaNs via a 12^3 special-value
    pass plus TestbenchBuilder's default uniform random bit patterns in
    float32_fma_test.cc and float64_fma_test.cc, flush subnormal inputs in
    ComputeExpected, compare exact bits (and canonical +qNaN in float64)
    after FlushSubnormal, and fix PrintFloat hex formatting widths.
  • Use sign-preserving xls::FlushSubnormal, bit-exact non-NaN and canonical
    +qNaN comparison, and correct (ComputeExpected, ComputeActual) order in
    float64_mul_test.cc.
  • Compute relative error in double with std::abs and explicit NaN/inf
    handling in CompareResultsWith1PercentMargin (float32_test_utils.h) and
    bump float32_fast_rsqrt_test.cc default num_samples to 1024 * 1024.
  • Switch float32_downcast_test.cc to Arbitrary<uint64_t>() with bit-exact
    non-NaN comparison and enable enable_llvm_coverage = True on
    float32_downcast_jit_wrapper.
  • Fix signed 32-bit loop-counter overflow in float32_test.cc's --exhaustive
    mode, and move file-local test helpers into anonymous namespaces.

COPYBARA_INTEGRATE_REVIEW=#5468 from xlsynth:cdleary/2026-11-18-reject-incomparable-equality 96637a4
FUTURE_COPYBARA_INTEGRATE_REVIEW=#5468 from xlsynth:cdleary/2026-11-18-reject-incomparable-equality 96637a4

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0