interplane.Get Omega
Read in your language

openaccel-lab

aien-dev/openaccel-lab

Brought by drakestapleton

branch main Branches Tags History

openaccel-lab / docs / TOLERANCE.md

47 lines · 3321 bytes Raw Blame History Source

Tolerance contract

Every workload states, per output, how close an entrant has to come to the float64 reference. oal/check.py applies the contract; the entrant never sees it.

kindruleused for
exactbitwise equal to the reference rounded to the output dtypeinteger outputs, copies, elementwise ops whose float32 result is correctly rounded
intabs(got - ref) <= atol on integersquantisation, where round-half cases may differ by one step
boundabs(got - ref) <= c * gamma(n) * scale + atolreductions, dot products, matmuls, normalisations

gamma(n) = n*u / (1 - n*u) with u = 2^-24 (float32 unit roundoff) is the standard forward error bound for a length-n floating-point sum or dot product computed in any order (Higham, *Accuracy and Stability of Numerical Algorithms*, 2nd ed., Section 3.1). scale is the reference's own magnitude term, for example sum |a_i * b_i| for a dot product, so the bound does not depend on cancellation in the exact answer. c and atol are written in each workload.json with a one-line reason. A record's err_ratio is the largest abs(got - ref) / bound over all elements: 0 means bit-exact, 1 means at the bound, above 1 fails.

The bound allows any summation order on purpose. A tree reduction on a GPU, a serial loop on a CPU and a Kahan sum all pass; a dropped term, an off-by-one index or an exclusive scan in place of an inclusive one does not, and the controls in controls/ prove that on every backend.

Transcendentals in the Omega entrant

Seeded Omega has no exp word at omega-mv 369dbc96, so lib/omega/oal.om implements oal_expf in float64: x = n*ln2 + r with n = round(x / ln2), a two-part ln2 (Cody-Waite) and a degree-11 Taylor polynomial for exp(r), then scaling by 2^n through the exponent bits. The result is rounded to float32 by the caller. Every constant was checked with Wolfram:

That truncation error is 1.45e-7 of the float32 unit roundoff 2^-24 (WolframLanguageEvaluator: N[8.63527402609310923645372*^-15/2^-24, 6] -> 1.44876*^-7), so after the final rounding to float32 the Omega expf differs from a correctly rounded expf only on inputs that lie within that distance of a rounding boundary. Workloads that use exp (softmax, silu, attention) carry it in their bound term through c, not through a special case per entrant.