Skip to content

test: FuzzOps MatMul oracle as a stated error bound - #138

Merged
tannevaled merged 1 commit into
mainfrom
test/fuzzops-matmul-bound
Nov 30, 2026
Merged

tannevaled merged 1 commit into
mainfrom
test/fuzzops-matmul-bound

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

FuzzOps compared MatMul bit-for-bit with a naive float64 triple loop. The GEMM sums in its own order and fuses multiply-add, so the two differ by rounding only (nightly fuzz run 46298156668, amd64: At[3 1] = 2.6035494484318307e+23, oracle 2.603549448431831e+23, 1 ulp). MatMul is not wrong.

The test now asserts the stated inner-product bound, with the exact value summed in math/big:

|C_ij - exact_ij| <= gamma_k * sum_k |a_ik||b_kj| + k*2^-1074,   gamma_k = ku/(1-ku), u = 2^-53

The bound holds for any summation order and for FMA (go-blas docs/design.md Decision 4). A dot product with a non-finite operand keeps the oracle's value; one whose magnitude sum exceeds MaxFloat64 is not bounded (intermediate overflow is order-dependent). At vs Copy and every elementwise op stay bit-exact. The crash input 3f595a556cba79cb is committed as a regression seed. A temporary 1e-10 relative perturbation of the MatMul output tripped the new check, then was reverted.

SumAxis and CumSum keep the exact oracle: no failure has been seen there.

Test-only. Refs #137

🤖 Generated with Claude Code

The GEMM sums in its own order and fuses multiply-add, so it is not bit-equal
to the naive float64 loop the fuzz oracle used (1 ulp apart on amd64, run
46298156668: At[3 1] 2.6035494484318307e+23 vs 2.603549448431831e+23).
MatMul now owes |C_ij - exact_ij| <= gamma_k * sum|a_ik||b_kj| with exact_ij
summed in math/big; At vs Copy stay bit-equal, elementwise ops unchanged.
Commits the crash input as a regression seed.

Refs #137

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 972c879 into main Nov 30, 2026
13 checks passed
@tannevaled
tannevaled deleted the test/fuzzops-matmul-bound branch November 30, 2026 20:12
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