Bump tanh_fast Float32 tolerance and handle Julia 1.13 pow DomainError#45
Merged
ChrisRackauckas merged 2 commits intoMay 28, 2026
Merged
Conversation
`tanh_fast` is SLEEFPirates' relaxed-accuracy tanh variant (suffix `_fast`). On Apple aarch64 it peaks at ~3.93 ULP for Float32 near x = -6.21, just over the previous 3-ULP tolerance. The Float64 variant stays within 3 ULP, so only Float32 is loosened. This unblocks the `accuracy tanh_fast` test on SLEEFPirates.jl/Interface/1 (downstream of JuliaSIMD/VectorizationBase.jl#129). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Julia 1.13 changed `Base.:^(::Real, ::Real)` to throw a `DomainError` for negative bases with non-integer exponents (previously returned NaN). This broke `Accuracy (max error in ulp) for Float32/Float64` in `test/accuracy.jl` because the `pow` reference path uses `Base.:^` over a grid that included `x = -100:0.20:100`. Since the y grid (`0.1:0.20:100`) is entirely non-integer, the negative-base samples contributed no useful coverage: both `SLEEFPirates.pow` and the reference produced NaN, and `countulp` returns 0 when both inputs are NaN. Restricting the bases to `0:0.20:100` (matching the `pow_fast` grid just below) preserves all meaningful test points and removes the DomainError. Fix for SLEEFPirates.jl/Interface/pre (Julia 1.13 prerelease) downstream of JuliaSIMD/VectorizationBase.jl#129. Validated locally on Julia 1.11; Julia 1.13 validation deferred to CI. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 28, 2026
ChrisRackauckas
added a commit
that referenced
this pull request
May 28, 2026
Fix Julia 1.13 DomainError in log1p test grid (followup to #45)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two surgical fixes to the SLEEFPirates accuracy test harness (no production code changes) to unblock the downstream Interface CI on JuliaSIMD/VectorizationBase.jl#129.
Fix 1:
tanh_fastFloat32 tolerance bump (3 -> 4 ULP)CI log from
SLEEFPirates.jl/Interface/1on VB#129:tanh_fastis the relaxed-accuracy variant (suffix_fast), so a small tolerance bump is the appropriate fix here, not a polynomial rework. Float32 peaks at ~3.93 ULP near x = -6.21; Float64 stays at 2.47 ULP, so only Float32 is loosened (tol = T === Float32 ? 4 : 3).Fix 2: Restrict
powaccuracy test bases to x >= 0CI log from
SLEEFPirates.jl/Interface/pre(Julia 1.13 prerelease):Julia 1.13 changed
Base.:^(::Real, ::Real)to throwDomainErrorfor negative base + non-integer exponent (previously returnedNaN). Thepowaccuracy test used a gridx = -100:0.20:100, y = 0.1:0.20:100. Since theygrid is entirely non-integer, the negative-base samples never contributed useful coverage -- bothSLEEFPirates.powand the referenceBase.:^produced NaN, andcountulp(NaN, NaN) = 0. Restricting bases to0:0.20:100(matching thepow_fastgrid just below) preserves all meaningful test points.Test plan
Local validation on Julia 1.11.8 (Apple aarch64) against a local VectorizationBase build of branch
fix/fmadd-true-fma:Accuracy (max error in ulp) for Float32: 561 pass, 0 fail, 4 broken (was 560 pass, 1 fail, 4 broken before this PR)Accuracy (max error in ulp) for Float64: 388 pass, 0 fail, 5 brokentanh_fastFloat32 still peaks at 3.93 ULP (under new 4-ULP tol); Float64 peaks at 2.47 ULP (under unchanged 3-ULP tol)powFloat32 peaks at 0.71 ULP; Float64 peaks at 2.10 ULP after the grid restriction -- same effective coverage minus the no-information negative-base samplesOut of scope
evaluatejob failure on the Interface CI is a separate CI infrastructure issue, not addressed here.src/changes; both fixes live intest/accuracy.jl.