Repository navigation
test(analytics): skip the negative half-tie on JVMs whose exp is fdlibm - #2876
Open
andynilson wants to merge 1 commit into
Open
andynilson wants to merge 1 commit into
andynilson wants to merge 1 commit into
Conversation
RecoveryDriversTest pins the shared "nearest, half-ties away from zero" rule with inputs tuned so the HRV marginal lands on exactly -0.5. That tie only holds when exp is correctly rounded at the two exponents behind it. HotSpot on arm64 (Apple Silicon) returns fdlibm's values there, one ulp off at both in the same direction, so the marginal comes out -0.4999999999999929 and rounds to 0. The two tests fail there (seen on Apple Silicon) while passing on CI's x86-64 runner. The rounding rule is not at fault, and the Swift twin (Apple libm) reaches the exact tie, so the product code stays as it is. The exact negative-tie assertions now run behind a probe that is true only where Math.exp equals StrictMath.exp at both exponents. CI cannot take that branch: the same assertions pass there, which fdlibm's values could not produce. Everything the tie does not decide still runs first, and a skipped tie reads as skipped rather than passed.
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.
What this PR does
Two
RecoveryDriversTestcases fail on Apple Silicon and pass on CI's x86-64 runner, both withexpected:<-0.5> but was:<-0.4999999999999929>:driverPointRoundingUsesNearestWithHalfTiesAwayFromZeroissue51NegativeHalfTieUsesDefaultArg8WithoutChangingScoreOrDriverFieldsSeveral open PRs list them as failing the same way on unmodified
main.Cause. The tests (from #1441) tune HRV
29.99117725828923so the HRV marginal lands on exactly−0.5. That holds only when
expis correctly rounded at the two exponentslogisticScoreevaluates.On arm64 HotSpot,
Math.expreturns fdlibm's (StrictMath) values there, each one ulp off, in thesame direction:
exp-0.2995162348730591(HRV29.99117725828923)0.74117668940262830.7411766894026282-0.32000000000000006(neutral, HRV30.0)0.72614903707369080.7261490370736909The marginal comes out
-0.4999999999999929and rounds to 0 instead of −1. The rounding rule isright; the Swift twin (Apple libm) gets exactly −0.5, and
ChargeDriversTestspasses on the same machine.Change (test-only, Kotlin).
assumeThisJvmCanReachTheNegativeTie(). It skipsthem only where
exp(x) == StrictMath.exp(x)at both exponents.probe is false there and they stay strict.
non-ties still run before any skip.
Assumepattern as the existinganalytics/agreement/*Test.ktskips.Not changed.
RecoveryScorertoStrictMath.expwould make Kotlin disagree withSwift at points like this.
Alternatives considered.
under fdlibm, so constants alone can't fix it.
exp(0) = 1, full side in the middle ofthe band that yields exactly 49.5) would hold everywhere but changes both twins. It can replace
this if preferred.
Type of change
How it was tested
macOS 26 on Apple Silicon, Homebrew OpenJDK 17.0.21:
RecoveryDriversTesttestFullDebugUnitTest --no-build-cache --rerun-tasksChargeDriversTests(unchanged)-0.4999999999999929exprounded to double gives the "correctly rounded" column, and with those values the marginal is exactly −0.5Math.expequalsStrictMath.expat both exponents on this JVMdoc_comment_lint.pyOK;i18n_audit.py --ci upstream/mainOK; no Kotlin warnings in the changed file.Checklist
swift testinPackages/<name>) — n/a, no package touched (the Swift twin was run anyway: 19 passed)android/(./gradlew testFullDebugUnitTest; after a branch switch add--no-build-cache --rerun-tasks, or Gradle may fail classes you never touched)StrandDesigntokens — no hardcoded colors, fonts, or spacing (no UI change)docs/CONTRIBUTING.mdStrand.xcodeproj/) or any secrets/keystoresRelated issues
Refs #1441 (where these tests were added). Reported as pre-existing in #2795, #2822, #2824, #2827, #2828.