[PR #1692] tests: GPU-free repro of the FMA denormal-product divergence (TEST-FMA-DENORM-PRODUCT) #1707

Open
opened 2026-11-26 20:22:10 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1692
Author: @GTAVIB4GTAVI
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: test/fma-nvidia-repro


📝 Commits (1)

  • 12f1778 tests: GPU-free repro of the FMA denormal-product divergence (TEST-FMA-DENORM-PRODUCT)

📊 Changes

2 files changed (+261 additions, -0 deletions)

View changed files

➕ tests/semantic/fixtures/ps_fma_denorm_product.asm (+17 -0)
➕ tests/semantic/test_fma_denorm_product.py (+244 -0)

📄 Description

Claimed as: TEST-FMA-DENORM-PRODUCT (standalone claim issue #1594: #14 is at GitHub's 2,500-comment cap and rejects new comments)

What and why

whoalin1 reported on #14 (7150696174 (a), 7152027316 (c)) that on an RTX 4070 SUPER v_fmamk_f32 with an exact product of -2^-127 and addend 0x00ffffff returns the addend instead of RDNA2's 0x00bfffff: the driver flushes the denormal intermediate product. Nothing in the tree pinned that mix (cs_fma_fused probes rounding on normal products). This adds a repro that needs no GPU.

  • tests/semantic/fixtures/ps_fma_denorm_product.asm: hand-written, v_fmamk_f32, v_fmaak_f32, v_fma_f32, v_fmac_f32 on push-constant operands.
  • tests/semantic/test_fma_denorm_product.py, 12 tests, per --fma mode:
    • what is emitted: glsl one GLSL.std.450 Fma per op; khr one OpFmaKHR per op with FMAKHR and SPV_KHR_fma; exact no OpFmaKHR, every OpFMul/OpFAdd/OpFSub NoContraction, and its 4 GLSL Fma feed only OpSelect;
    • the mrt0 words under three models of the driver's fused op: fused (the hardware word in every mode); product-flushing (glsl and khr give the addend, the reported NVIDIA word; exact keeps the hardware word, also with every f32 denormal result flushed); NaN for every finite operand triple (exact unchanged).
    • the expected words are checked against exact rationals, not against the interpreter.

Test only: no translator change, no docs change. Whether NVIDIA's OpFmaKHR keeps the product has not been measured by anyone; the file only pins that khr leaves it to that one op. The sNaN item of 7152027316 is #1554's and is not part of this.

Tested

Windows 10 22H2, Python 3.12, SPIRV-Tools from Vulkan SDK 1.4.363.0.

  • python -m unittest discover -s tests/semantic -p test_fma_denorm_product.py: 12 tests OK, on main 3f81d46ac (after rebase) and on c7e82e26e.
  • python -I scripts/run_semantic_tests.py tests/semantic -j 8, same base c7e82e26e: without the commit 487 files / 6,279 tests / 0 files failed; with it 488 / 6,291 / 0 files failed. Not re-run after the rebase onto 3f81d46ac.
  • python -I scripts/check_no_game_data.py on both files: clean.

GPUs tested: n/a (CPU interpreter only; the divergence itself was not measured on this box's RTX 2080 Ti)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: test only)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1692 **Author:** [@GTAVIB4GTAVI](https://github.com/GTAVIB4GTAVI) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `test/fma-nvidia-repro` --- ### 📝 Commits (1) - [`12f1778`](https://github.com/ubiquitarianism/leonida/commit/12f177867863936c83dc49ac81f211ddb720e47d) tests: GPU-free repro of the FMA denormal-product divergence (TEST-FMA-DENORM-PRODUCT) ### 📊 Changes **2 files changed** (+261 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `tests/semantic/fixtures/ps_fma_denorm_product.asm` (+17 -0) ➕ `tests/semantic/test_fma_denorm_product.py` (+244 -0) </details> ### 📄 Description Claimed as: TEST-FMA-DENORM-PRODUCT (standalone claim issue #1594: #14 is at GitHub's 2,500-comment cap and rejects new comments) ### What and why whoalin1 reported on #14 (7150696174 (a), 7152027316 (c)) that on an RTX 4070 SUPER `v_fmamk_f32` with an exact product of `-2^-127` and addend `0x00ffffff` returns the addend instead of RDNA2's `0x00bfffff`: the driver flushes the denormal intermediate product. Nothing in the tree pinned that mix (`cs_fma_fused` probes rounding on normal products). This adds a repro that needs no GPU. - `tests/semantic/fixtures/ps_fma_denorm_product.asm`: hand-written, `v_fmamk_f32`, `v_fmaak_f32`, `v_fma_f32`, `v_fmac_f32` on push-constant operands. - `tests/semantic/test_fma_denorm_product.py`, 12 tests, per `--fma` mode: - what is emitted: `glsl` one GLSL.std.450 `Fma` per op; `khr` one `OpFmaKHR` per op with `FMAKHR` and `SPV_KHR_fma`; `exact` no `OpFmaKHR`, every `OpFMul`/`OpFAdd`/`OpFSub` `NoContraction`, and its 4 GLSL `Fma` feed only `OpSelect`; - the mrt0 words under three models of the driver's fused op: fused (the hardware word in every mode); product-flushing (`glsl` and `khr` give the addend, the reported NVIDIA word; `exact` keeps the hardware word, also with every f32 denormal result flushed); NaN for every finite operand triple (`exact` unchanged). - the expected words are checked against exact rationals, not against the interpreter. Test only: no translator change, no docs change. Whether NVIDIA's `OpFmaKHR` keeps the product has not been measured by anyone; the file only pins that `khr` leaves it to that one op. The sNaN item of 7152027316 is #1554's and is not part of this. ### Tested Windows 10 22H2, Python 3.12, SPIRV-Tools from Vulkan SDK 1.4.363.0. - `python -m unittest discover -s tests/semantic -p test_fma_denorm_product.py`: 12 tests OK, on `main` 3f81d46ac (after rebase) and on c7e82e26e. - `python -I scripts/run_semantic_tests.py tests/semantic -j 8`, same base c7e82e26e: without the commit 487 files / 6,279 tests / 0 files failed; with it 488 / 6,291 / 0 files failed. Not re-run after the rebase onto 3f81d46ac. - `python -I scripts/check_no_game_data.py` on both files: clean. GPUs tested: n/a (CPU interpreter only; the divergence itself was not measured on this box's RTX 2080 Ti) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: test only) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1707
No description provided.