fix: bits_float quiets signalling NaNs on every Python version (3.14 keeps them) #238

Merged
lcg007xd-c merged 1 commit from upstream-pr/238 into main 2026-11-25 21:08:01 +00:00
lcg007xd-c commented 2026-11-25 20:46:16 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by lcg007xd-c on 2026-11-25T20:46:16Z.


Change

The reference interpreter relies on CPython quieting a signalling f32 NaN when struct.unpack("<f") widens it to a double (_first_nan in emu/rdna2_exec_ops.py: "déjà rendu silencieux par la conversion en double"). CPython 3.14 no longer does: it keeps the signalling bit through struct. Measured with the same one-liner (struct.unpack("<f", struct.pack("<I", 0x7F800001)), then struct.pack("<f", …)):

3.12.13 → 0x7fc00001
3.13.13 → 0x7fc00001
3.14.10 → 0x7f800001

So on Python 3.14, main (4f2cf5c) fails 4 FMA tests: the FMA returns the signalling NaN instead of the quiet one.

FAILED tests/test_rdna2_exec_fma.py::test_interpreter_rounds_once_in_every_encoding[NaN signalant en a, rendu silencieux]
FAILED tests/test_rdna2_exec_fma.py::test_interpreter_rounds_once_in_every_encoding[NaN en b avant NaN en c]
FAILED tests/test_rdna2_exec_fma.py::test_interpreter_rounds_once_in_every_encoding[NaN signalant en c]
FAILED tests/test_rdna2_exec_fma.py::test_interpreter_matches_the_exact_rounding_on_a_seeded_sweep
  7F800001 × 3F800000 + 00000000 : (2139095041, …) au lieu de (2143289345, …)

Now bits_float sets bit 22 itself when the pattern is a NaN, so every Python version follows the rule that the 3.12 CI already checks against the GPU. Infinities, quiet NaNs and ordinary values are unchanged. Nothing changes on 3.12 or 3.13.

Linked issue: none.

Verification

Linux (Arch), no C++ runtime, no GPU (the runtime and GPU tests skip):

Python 3.14.10: python -m pytest → 2 failed, 1019 passed, 315 skipped
Python 3.12.13: python -m pytest → 2 failed, 1019 passed, 315 skipped
python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools → All checks passed!

The 2 remaining failures are tests/test_jour_j.py (manifest name case on Linux, fixed separately in #237), the same on both versions.

Not run: the Windows CI job and the GPU/WARP parity tests (no HLSL change).

Oracle and test data

  • New test_signalling_nan_operands_come_back_quiet_on_every_python (tests/test_rdna2_exec_fma.py): signalling NaNs of both signs and the largest payload come back with bit 22 set; a quiet NaN, ±infinity and 1.0 are unchanged.
  • Failure case: on Python 3.14 without the change, tests/test_rdna2_exec_fma.py has 7 failures (the 4 above and 3 of the new cases). On 3.12 the new test also passes without the change, because 3.12 already quiets.
  • Test data is built in the tests.

Checklist

  • The PR covers a single reviewable behaviour.
  • A test fails without this change and passes with it. (On Python 3.14.)
  • The commands and results of each check are given above.
  • An unimplemented function returns an error (E_NOTIMPL), never a fake success.
  • README: the same change in all 9 languages (test_readme_sync.py checks it). (No README change; still 1300+.)
  • No game, console or SDK file, no key, no dump, no download link.
  • Findings drawn from a title: none.
  • Code taken from another project: none.

Made with AI assistance (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:LooperSalty/AnyXboxX:issue:6613421266 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/238). Originally posted by [lcg007xd-c](https://github.com/lcg007xd-c) on 2026-11-25T20:46:16Z. --- ## Change The reference interpreter relies on CPython quieting a signalling f32 NaN when `struct.unpack("<f")` widens it to a double (`_first_nan` in `emu/rdna2_exec_ops.py`: "déjà rendu silencieux par la conversion en double"). **CPython 3.14 no longer does**: it keeps the signalling bit through `struct`. Measured with the same one-liner (`struct.unpack("<f", struct.pack("<I", 0x7F800001))`, then `struct.pack("<f", …)`): ``` 3.12.13 → 0x7fc00001 3.13.13 → 0x7fc00001 3.14.10 → 0x7f800001 ``` So on Python 3.14, `main` (`4f2cf5c`) fails 4 FMA tests: the FMA returns the signalling NaN instead of the quiet one. ``` FAILED tests/test_rdna2_exec_fma.py::test_interpreter_rounds_once_in_every_encoding[NaN signalant en a, rendu silencieux] FAILED tests/test_rdna2_exec_fma.py::test_interpreter_rounds_once_in_every_encoding[NaN en b avant NaN en c] FAILED tests/test_rdna2_exec_fma.py::test_interpreter_rounds_once_in_every_encoding[NaN signalant en c] FAILED tests/test_rdna2_exec_fma.py::test_interpreter_matches_the_exact_rounding_on_a_seeded_sweep 7F800001 × 3F800000 + 00000000 : (2139095041, …) au lieu de (2143289345, …) ``` Now `bits_float` sets bit 22 itself when the pattern is a NaN, so every Python version follows the rule that the 3.12 CI already checks against the GPU. Infinities, quiet NaNs and ordinary values are unchanged. Nothing changes on 3.12 or 3.13. Linked issue: none. ## Verification Linux (Arch), no C++ runtime, no GPU (the runtime and GPU tests skip): ``` Python 3.14.10: python -m pytest → 2 failed, 1019 passed, 315 skipped Python 3.12.13: python -m pytest → 2 failed, 1019 passed, 315 skipped python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools → All checks passed! ``` The 2 remaining failures are `tests/test_jour_j.py` (manifest name case on Linux, fixed separately in #237), the same on both versions. Not run: the Windows CI job and the GPU/WARP parity tests (no HLSL change). ## Oracle and test data - New `test_signalling_nan_operands_come_back_quiet_on_every_python` (`tests/test_rdna2_exec_fma.py`): signalling NaNs of both signs and the largest payload come back with bit 22 set; a quiet NaN, ±infinity and 1.0 are unchanged. - Failure case: on Python 3.14 without the change, `tests/test_rdna2_exec_fma.py` has 7 failures (the 4 above and 3 of the new cases). On 3.12 the new test also passes without the change, because 3.12 already quiets. - Test data is built in the tests. ## Checklist - [x] The PR covers a single reviewable behaviour. - [x] A test fails without this change and passes with it. (On Python 3.14.) - [x] The commands and results of each check are given above. - [x] An unimplemented function returns an error (`E_NOTIMPL`), never a fake success. - [x] README: the same change in all 9 languages (`test_readme_sync.py` checks it). (No README change; still `1300+`.) - [x] No game, console or SDK file, no key, no dump, no download link. - [x] Findings drawn from a title: none. - [x] Code taken from another project: none. Made with AI assistance (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
LooperSalty/AnyXboxX!238
No description provided.