[PR #1724] tests: cs_fma_fused takes its f16 operands at run time, like its f32 ones (TEST-FMA-FUSED-F16-RUNTIME) #1736

Open
opened 2026-11-26 21:18:47 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: test-fma-fused-f16-runtime


📝 Commits (3)

  • e2634e4 tests: cs_fma_fused takes its f16 operands at run time, like its f32 ones (TEST-FMA-FUSED-F16-RUNTIME)
  • ebb0b0b docs: cs_fma_fused reads 0x7352 in its f16 word on KosmicKrisp at run time
  • 51439f9 ci: cs_fma_fused is no longer an expected failure of the macOS job

📊 Changes

5 files changed (+112 additions, -7 deletions)

View changed files

📝 .github/workflows/runtime.yml (+1 -3)
📝 docs/testing.md (+2 -1)
📝 runtime/test/shaders/cs_fma_fused.asm (+9 -3)
📝 tests/semantic/README.md (+4 -0)
➕ tests/semantic/test_fma_fused_fixture.py (+96 -0)

📄 Description

Claimed in the coordination issue as: TEST-FMA-FUSED-F16-RUNTIME (claim)

Depends on: #860

It does not build on #860; the two conflict. Both edit neighbouring Known problems rows of docs/testing.md, so whichever merges second needs a rebase that keeps both rows.

What and why

cs_fma_fused fails on a Mac with MoltenVK 1.4.2 in word 7, the v_fma_f16: docs/testing.md has a Known problems row for it and the macOS job lists it in EXPECTED_FAILURES. On an Apple M5 the word reads 0x0000, want 0x7351.

The translation is not what is wrong. The fixture reads the operands of its f32 multiply-adds from s4..s7 "so a driver cannot fold the multiply-adds at compile time", but the three operands of the f16 one were literals, so that whole multiply-add was a compile-time constant, and MoltenVK 1.4.2 gets that constant wrong. Measured on the M5 with the fixture otherwise unchanged:

f16 operands taken at run time word 7
none (as on main) 0x0000
the first, the second or the third alone 0x7351
any two 0x7351
all three 0x7351
  • runtime/test/shaders/cs_fma_fused.asm: the f16 triple is the s4 word XOR a literal each (0x3f800800 ^ 0x3f8064e1 = 0x6ce1, and so on), so it is the same triple at run time, and the header says why.
  • tests/semantic/test_fma_fused_fixture.py: the translated fixture gives the eight words of its header in the interpreter, and every register one of its multiply-adds reads comes from s4..s7, so a literal operand cannot come back unnoticed.
  • docs/testing.md: the Known problems row now says what is left, an f16 multiply-add whose three operands are all constants, and that the fixture no longer has one. tests/semantic/README.md lists the new test.

The translator, check.py and run_gpu_tests.py are not changed: the expected words are the same.

.github/workflows/runtime.yml still lists cs_fma_fused in the macOS job's EXPECTED_FAILURES. I left it: that runner's Metal device is not an M5, and an expected failure that passes only gets a notice there. If this pull request's macOS run shows that notice, the entry can go.

Tested

Apple M5, MoltenVK 1.4.2, llvm-mc 23.1.6, SPIRV-Tools v2026.4. Before is main 626d1281a, after is this branch on 3de22a190 (the fixture, the translator and the two runners are the same at both), with the test programs built from 626d1281a.

Before After
run_gpu_tests.py --filter cs_fma_fused, 5 runs 5 fail: word 7 (f16): got 0x00000000, want 0x00007351 5 pass: 8/8 fused exact (GLSL Fma)
the same with LEONIDA_FMA=exact, 5 runs 5 pass 5 pass
the same with LEONIDA_W64_EMULATE=1 fail, the same word pass
build.py <out> cs_fma_fused, then check.py word 7 (f16): got 0x00000000, want 0x00007351 ok
run_gpu_tests.py, all tests 193/263 passed, 68 skipped; failed cs_fma_fused, cs_imgatomic_ext 193/263 passed, 68 skipped; failed cs_imgatomic_ext, ps_imgatomic
  • In the full run the only verdicts that differ are cs_fma_fused (fail to pass) and ps_imgatomic (pass to fail). The second is the intermittent #543, not this change: its module is byte-identical in both runs, and run alone six times it passes five and fails one in each tree. cs_imgatomic_ext is red on main and claimed by someone else (GPU-IMG-ATOMIC-EXT-VOLUME-TAG).
  • The translation step reports 273 shaders: 272 translated, 272 pass spirv-val in both, and 1 of the 275 modules in the work folder changes: cs_fma_fused.
  • That LEONIDA_FMA=exact passed before is the same effect, not a fix: it changes only how the f32 multiply-adds around the f16 one are translated; the f16 one does not use Fma in either mode (Gen.fma_f16_odd).
  • tests/semantic/test_fma_fused_fixture.py: 3 tests pass; against main's fixture the run-time check fails (['v15', 'v16', 'v17'] != []). With one operand word changed by one bit the eight-word check fails, so it does compare.
  • python3 -I scripts/run_semantic_tests.py tests/semantic: 487 files, 6,279 tests, 0 failed before; 488 files, 6,282 tests, 0 failed after.
  • pytest files: 2 failed, 1908 passed, 18 skipped, before and after alike (the two are tests/test_translate.py on cs_dpp_cmp.asm, #1375's subject; cs_fma_fused.asm assembles and validates there as before).
  • Standard-library loop: 498 files, 4 failed, as on main; none is touched here (#1412, #1561 and #1657 are open for them).
  • tests/test_docs_*.py pass; python3 -I scripts/check_no_game_data.py is clean on the new test and the fixture.

Not tested: any GPU other than the M5, and the macOS runner's device. On a driver that evaluated the constant correctly the only change is that the f16 word is computed at run time.

GPUs tested: Apple M5 (8-core GPU), MoltenVK 1.4.2, macOS 27.2.1 (26B131)

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.

🤖 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/1724 **Author:** [@hugo0024](https://github.com/hugo0024) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `test-fma-fused-f16-runtime` --- ### 📝 Commits (3) - [`e2634e4`](https://github.com/ubiquitarianism/leonida/commit/e2634e4a1d3a24671ec93b6852e871cd78707215) tests: cs_fma_fused takes its f16 operands at run time, like its f32 ones (TEST-FMA-FUSED-F16-RUNTIME) - [`ebb0b0b`](https://github.com/ubiquitarianism/leonida/commit/ebb0b0b00b64165a06c5faa9b817d571f531a107) docs: cs_fma_fused reads 0x7352 in its f16 word on KosmicKrisp at run time - [`51439f9`](https://github.com/ubiquitarianism/leonida/commit/51439f9db5976db22a2ed8dd50a13089a81b2a16) ci: cs_fma_fused is no longer an expected failure of the macOS job ### 📊 Changes **5 files changed** (+112 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/runtime.yml` (+1 -3) 📝 `docs/testing.md` (+2 -1) 📝 `runtime/test/shaders/cs_fma_fused.asm` (+9 -3) 📝 `tests/semantic/README.md` (+4 -0) ➕ `tests/semantic/test_fma_fused_fixture.py` (+96 -0) </details> ### 📄 Description Claimed in the coordination issue as: TEST-FMA-FUSED-F16-RUNTIME ([claim](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7158527074)) Depends on: #860 It does not build on #860; the two conflict. Both edit neighbouring Known problems rows of `docs/testing.md`, so whichever merges second needs a rebase that keeps both rows. ### What and why `cs_fma_fused` fails on a Mac with MoltenVK 1.4.2 in word 7, the `v_fma_f16`: `docs/testing.md` has a Known problems row for it and the macOS job lists it in `EXPECTED_FAILURES`. On an Apple M5 the word reads `0x0000`, want `0x7351`. The translation is not what is wrong. The fixture reads the operands of its f32 multiply-adds from `s4..s7` "so a driver cannot fold the multiply-adds at compile time", but the three operands of the f16 one were literals, so that whole multiply-add was a compile-time constant, and MoltenVK 1.4.2 gets that constant wrong. Measured on the M5 with the fixture otherwise unchanged: | f16 operands taken at run time | word 7 | |---|---| | none (as on `main`) | `0x0000` | | the first, the second or the third alone | `0x7351` | | any two | `0x7351` | | all three | `0x7351` | - `runtime/test/shaders/cs_fma_fused.asm`: the f16 triple is the `s4` word XOR a literal each (`0x3f800800 ^ 0x3f8064e1 = 0x6ce1`, and so on), so it is the same triple at run time, and the header says why. - `tests/semantic/test_fma_fused_fixture.py`: the translated fixture gives the eight words of its header in the interpreter, and every register one of its multiply-adds reads comes from `s4..s7`, so a literal operand cannot come back unnoticed. - `docs/testing.md`: the Known problems row now says what is left, an f16 multiply-add whose three operands are all constants, and that the fixture no longer has one. `tests/semantic/README.md` lists the new test. The translator, `check.py` and `run_gpu_tests.py` are not changed: the expected words are the same. `.github/workflows/runtime.yml` still lists `cs_fma_fused` in the macOS job's `EXPECTED_FAILURES`. I left it: that runner's Metal device is not an M5, and an expected failure that passes only gets a notice there. If this pull request's macOS run shows that notice, the entry can go. ### Tested Apple M5, MoltenVK 1.4.2, llvm-mc 23.1.6, SPIRV-Tools v2026.4. Before is `main` `626d1281a`, after is this branch on `3de22a190` (the fixture, the translator and the two runners are the same at both), with the test programs built from `626d1281a`. | | Before | After | |---|---|---| | `run_gpu_tests.py --filter cs_fma_fused`, 5 runs | 5 fail: `word 7 (f16): got 0x00000000, want 0x00007351` | 5 pass: `8/8 fused exact (GLSL Fma)` | | the same with `LEONIDA_FMA=exact`, 5 runs | 5 pass | 5 pass | | the same with `LEONIDA_W64_EMULATE=1` | fail, the same word | pass | | `build.py <out> cs_fma_fused`, then `check.py` | `word 7 (f16): got 0x00000000, want 0x00007351` | `ok` | | `run_gpu_tests.py`, all tests | 193/263 passed, 68 skipped; failed `cs_fma_fused`, `cs_imgatomic_ext` | 193/263 passed, 68 skipped; failed `cs_imgatomic_ext`, `ps_imgatomic` | - In the full run the only verdicts that differ are `cs_fma_fused` (fail to pass) and `ps_imgatomic` (pass to fail). The second is the intermittent #543, not this change: its module is byte-identical in both runs, and run alone six times it passes five and fails one in each tree. `cs_imgatomic_ext` is red on `main` and claimed by someone else (GPU-IMG-ATOMIC-EXT-VOLUME-TAG). - The translation step reports `273 shaders: 272 translated, 272 pass spirv-val` in both, and 1 of the 275 modules in the work folder changes: `cs_fma_fused`. - That `LEONIDA_FMA=exact` passed before is the same effect, not a fix: it changes only how the f32 multiply-adds around the f16 one are translated; the f16 one does not use `Fma` in either mode (`Gen.fma_f16_odd`). - `tests/semantic/test_fma_fused_fixture.py`: 3 tests pass; against `main`'s fixture the run-time check fails (`['v15', 'v16', 'v17'] != []`). With one operand word changed by one bit the eight-word check fails, so it does compare. - `python3 -I scripts/run_semantic_tests.py tests/semantic`: 487 files, 6,279 tests, 0 failed before; 488 files, 6,282 tests, 0 failed after. - pytest files: 2 failed, 1908 passed, 18 skipped, before and after alike (the two are `tests/test_translate.py` on `cs_dpp_cmp.asm`, #1375's subject; `cs_fma_fused.asm` assembles and validates there as before). - Standard-library loop: 498 files, 4 failed, as on `main`; none is touched here (#1412, #1561 and #1657 are open for them). - `tests/test_docs_*.py` pass; `python3 -I scripts/check_no_game_data.py` is clean on the new test and the fixture. Not tested: any GPU other than the M5, and the macOS runner's device. On a driver that evaluated the constant correctly the only change is that the f16 word is computed at run time. GPUs tested: Apple M5 (8-core GPU), MoltenVK 1.4.2, macOS 27.2.1 (26B131) 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. 🤖 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#1736
No description provided.