Skip to content

Remove SafeSinh cross-lane defense now that eve fixed it upstream - #173

Merged
foolnotion merged 2 commits into
mainfrom
fix/eve-sinh-crosslane-fixed-upstream
Aug 10, 2026
Merged

Remove SafeSinh cross-lane defense now that eve fixed it upstream#173
foolnotion merged 2 commits into
mainfrom
fix/eve-sinh-crosslane-fixed-upstream

Conversation

@foolnotion

Copy link
Copy Markdown
Member

Summary

#172 defended eve::sinh/eve::tanh call sites against a confirmed
third-party bug: a NaN in one SIMD lane of an eve::wide register
corrupted the computed result in a completely unrelated, non-NaN lane
of the same register (affecting sinh, tanh, expm1, coth, csch,
gd in eve's math module).

jfalcou/eve#2366 fixes the
shared root cause: expm1's own non-finite-lane handling was calling
the fast/approximate [raw] path for the entire register whenever any
lane was non-finite, degrading accuracy in every other lane too. Since
sinh, tanh, and coth call expm1 directly, and csch/gd call
sinh/tanh respectively, this one-line upstream fix covers all 6
affected functions.

Changes

  • Bumped the foolnotion/nur-pkg (eve package) pin to
    unstable-2026-08-07 (past eve#2366's merge).
  • Removed SafeSinh (functions.hpp) and reverted its 3 call sites
    (primal Sinh, JIT Sinh, Cosh's derivative rule) to call
    eve::sinh directly.
  • Left Tanh's derivative rule on FastTanhDefend Sinh/Tanh-derivative call sites against eve's cross-lane NaN bug #172 framed that switch
    as also fixing an unrelated inconsistency with primal Tanh (which
    already used FastTanh), not purely a defensive workaround, so kept
    it independent of the eve bug status.
  • Updated the stale SafeSinh-referencing comment on the regression
    test, kept the test itself as a permanent guard.

Verification

  • Standalone before/after repro (built at operon's actual
    -march=x86-64-v3 target) against both eve pins: all 6 functions
    (sinh, tanh, expm1, coth, csch, gd) show cross-lane
    corruption under the old pin, clean under the new one.
  • Full test suite (~[performance]) passes both with the defense in
    place (confirms the eve bump alone doesn't regress anything) and
    without it (confirms nothing else depended on SafeSinh
    incidentally) — 0 failures in both runs.

Test plan

  • Standalone cross-lane repro, old vs new eve pin
  • Full suite passes with defense removed

jfalcou/eve#2366 fixes the root cause PR #172 worked around (a wrong
fast-path in expm1's non-finite-lane handling, corrupting unrelated
finite lanes in the same SIMD register). Bumped the eve pin
(foolnotion/nur-pkg#049b418) and reverted sinh's three call sites to
eve::sinh directly; Tanh's derivative stays on FastTanh for consistency
with primal Tanh, independent of the eve bug.

Verified with a standalone before/after repro (all of sinh, tanh,
expm1, coth, csch, gd corrupted under the old eve pin, clean under the
new one) and operon's full test suite passing both with and without
the defense in place.
Windows CI uses vcpkg (not the nix flake, which was already bumped),
so it was still building against the pre-eve#2366 buggy eve and
failing the cross-lane corruption regression test this PR relies on.
@foolnotion
foolnotion merged commit 6d50ba0 into main Aug 10, 2026
3 checks passed
@foolnotion
foolnotion deleted the fix/eve-sinh-crosslane-fixed-upstream branch August 10, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant