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
{{ message }}
Repository navigation
Do subnormal results have to be preserved when the reference formula overflows in float32? #967
Ran into this ambiguity while making RustNN run SmolLM2-135M with decent chat quality on Apple Watch:
the spec’s sigmoid reference 1 / (exp(-x) + 1) returns 0 in float32 below x = -88.72 because exp(-x) overflows, while the correctly rounded result is a representable subnormal down to about -103.
on My M4 MacBook (macOS 27.2), Chrome Canary 158 returns exactly the overflowing value; the WPT tolerance for sigmoid is 34 ULP, which the overflowing result misses by five orders of magnitude at -90 but meets at -100 (27 units of 2^-149). it seems to me that the same question applies to every operator whose reference formula has an intermediate that overflows or underflows while the result is still representable: softmax tails, reduceLogSumExp (whose existing WPT cases also fail in that Canary with Infinity and -13.8 instead of 100 and -100), and the normalization statistics in float16. this feel wrong to me, but I am admittedly a bit out of my depth 😅
Two readings fit the text (literal formula, so flushing and intermediate overflow conform or mathematical function with the tolerance on the correctly rounded result).
the reference formulas define the value and implementations may compute them literally, so flush-to-zero and intermediate overflow are conforming
the formulas define the mathematical function and the tolerance applies to the correctly rounded result, so an implementation must avoid intermediate overflow.
The WPT files assume option 2 for reduceLogSumExp but I couldn't find a similar opinion/gate for sigmoid. Could the specification state which reading applies, and whether subnormal results are covered by the tolerance or may be flushed? A draft WPT test for the sigmoid case is at web-platform-tests/wpt#63968; its expected values change by one line if its determined option 1 is best, just lmk :D
Activity
fix(coreml): materialize typed precision boundaries (#279)