I've been working on a problem in quantitative finance where we need reproducible results for audit trails. Simple stuff like sin(0.5) returns different bits on ARM vs x86, or CPU vs GPU.
Traced it down to libm implementations using different polynomial approximations, FMA instructions, and compiler optimizations. Even the same binary can produce different results depending on CPU microarchitecture.
Ended up building a REST API that forces determinism by using fixed Remez polynomial coefficients, disabling FMA, and enforcing strict evaluation order. Every response includes a SHA256 hash of the output bytes.
Just shipped an update with 19 validated unary functions (trig, hyperbolic, exp, log, roots) plus support for compound expressions. Tested across M1 Mac, x86 Linux, and H100 GPU. Same inputs produce identical hashes on all three.
Curious if others have hit this problem. How do you handle determinism in distributed systems where floating point consistency matters? Is there interest in a tool like this or are people just accepting the drift?
The java.lang.StrictMath javadoc[4] describes which algorithms and C libraries are used to achieve reproducibility across implementations/architectues.
luxiedge•3h ago
Traced it down to libm implementations using different polynomial approximations, FMA instructions, and compiler optimizations. Even the same binary can produce different results depending on CPU microarchitecture.
Ended up building a REST API that forces determinism by using fixed Remez polynomial coefficients, disabling FMA, and enforcing strict evaluation order. Every response includes a SHA256 hash of the output bytes.
Just shipped an update with 19 validated unary functions (trig, hyperbolic, exp, log, roots) plus support for compound expressions. Tested across M1 Mac, x86 Linux, and H100 GPU. Same inputs produce identical hashes on all three.
Curious if others have hit this problem. How do you handle determinism in distributed systems where floating point consistency matters? Is there interest in a tool like this or are people just accepting the drift?
Demo binary: https://github.com/RegularJoe-CEO/LuxiDemo/releases/tag/v2.0...