Skip to content

Build native kernels with -ffp-contract=off so Ubuntu 26.04 matches R bit for bit again - #202

Open
gitRasheed wants to merge 1 commit into
mainfrom
rasheed/no-fp-contract
Open

gitRasheed wants to merge 1 commit into
mainfrom
rasheed/no-fp-contract

Conversation

@gitRasheed

Copy link
Copy Markdown
Collaborator

Main has been red since GitHub moved ubuntu-latest to Ubuntu 26.04: about 28 bitwise tests fail by 1 to 4 ulp on every Python version, on #200 and on #201 alike.

The cause is fused multiply-add. The hosted runner's GCC 15.2 is Ubuntu's amd64v3 build (its cc1plus hash matches that package, not the stock one), whose default target is x86-64-v3 with FMA enabled. GCC's default -ffp-contract=fast then turns acc += a * b into one FMA, rounding once where R rounds twice. objdump counts 6, 52 and 14 FMA instructions in the seasonality, partial-moment and regression objects, and zero with contraction off.

This sets -ffp-contract=off on nnscore and _nnscore for GCC and Clang. Probes on the same container and wheels, contraction on vs off:

  • seasonality, n = 37: lag 2 is 1.1268546707527485 in R and ...487 contracted; all 7 lags exact with it off
  • degree-1 UPM, 162 targets: rows 21, 104 and 105 differ contracted; all 162 exact off
  • multivariate prediction: 7,996 differences at k = 300 contracted; 0 off

Across the whole R cache, 528 of 6,266 values differed contracted and all matched with it off, on both GCC 15.2 and GCC 13.3. With this change alone, the original bitwise tests pass again on Ubuntu 24.04, stock 26.04 and the amd64v3 variant, Python 3.11 to 3.14 (3,223 tests on 3.12, each). No test or workflow file changes.

It also keeps AppleClang from contracting on arm64, whose default is -ffp-contract=on.

#201 has separate failures from R 14.2 itself (#166 makes SSD, TSD and continuous FSD reject infinite values); those belong with the cache refresh.

This branch has not been deployed

No deployments
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