March 18, 2025 · 6 min read

Checking numerical equivalence without golden outputs

How we validate optimized kernels against references when floating-point reordering makes bit-exact comparison impossible.

Reordering a reduction changes floating-point results. Requiring bit-exact equality would reject almost every useful optimization, so validation needs tolerances that are principled rather than arbitrary.

Tolerances by dtype and operation

We derive tolerance bands from the dtype and the depth of the reduction, then test across randomized inputs, edge-case values, and multiple shapes. Outliers are reported, not averaged away.

Beyond a single kernel

Small per-kernel differences can compound. We also compare end-to-end model outputs on held-out inputs to catch drift that unit-level checks miss.

← All engineering notes