RFC: adopt explicit FMA as the numerical contract (feedback wanted)#96
RFC: adopt explicit FMA as the numerical contract (feedback wanted)#96mario4tier wants to merge 1 commit into
Conversation
One-time output shift bounded by 1e-12*max(1,|old|) (integer outputs bit-identical) in exchange for ~25% faster recursive indicators on all post-2013 x86 / all ARM64, and bit-identical results across platforms afterwards. Decision paths (candlestick penetration tests, SAR reversal) are never fused. For community feedback; no implementation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
I will leave that here in case someone care, but my mind is already set to modernize the code unless someone "insist" that TA-Lib should remain 100% bitwise-matching like the last 25 years... To be clear, we are talking here of very small output differences (likely insignificant to most), in exchange with faster/modern code. BTW, this debate is not specific to TA-Lib, there are similar recuring discussion in the Rust community about what "default" means and if it should adapt to more modern processor. Forever matching floating point output is... complicated. |
|
I'm in favor! Let's move into the future! |
|
@mrjbq7 Great timing! I was coming back here to see how I should bubble this up to the largest python community. Thanks for concurring. Will probably move to FMA in late 2027. I want to do first a bunch of fixes and algo-level optimization while we still can do bit-perfect comparison against the 0.6.4 reference. |
The tradeoff, up front: switching TA-Lib's value-path arithmetic to explicit fused multiply-add costs a one-time change in real-valued outputs bounded by a tested variation margin — every element stays numerically equal to today within
|new − old| ≤ 1e-12 × max(1, |old|), and all integer/pattern outputs stay bit-identical (decision paths are never fused — candlestick penetration tests and SAR reversals are structurally excluded). In exchange: ~25% faster recursive indicators (measured: 427µs → 311µs per 200k-bar DEMA-class recursion) on every x86 CPU since 2013 and all ARM64, and — for the first time — bit-identical TA-Lib results across x86-64, ARM64, and every platform, becausefmais one IEEE-754 correctly-rounded operation. The margin applies once at the transition; afterwards our regression gates return to bitwise comparison against the new frozen reference.Full proposal:
docs/fma-proposal.mdin this PR — hardware/ecosystem trend, exact fusion policy (value-path only), the mechanical validation plan over the existing ≈118k-comparison differential fuzz matrix, artifact strategy (x86-64-v3 primary + baseline fallback), and timing (after the current lockstep optimization pass completes under the existing bit-exact contract).Feedback wanted on four questions (see the end of the doc): (1) is the 1e-12 margin acceptable for your stored expected values / golden files? (2) x86-64-v3-primary artifacts: too early? (3) should a
TA_NO_FMAbuild opt-out exist, and for how long? (4) does anything in your pipeline need pre-FMA bit-compatibility indefinitely?This is a discussion PR — no implementation; it adds only the proposal document.
🤖 Generated with Claude Code