Tests: GPU coverage for v_cmp_class_f16/f64, v_fmamk/fmaak_f16, v_cvt_pknorm_*_f16 and v_mac_legacy_f32 #373

Open
github-bot wants to merge 1 commit from github-bot/gh-373 into main AGit
Owner

@⁠KoLolX3 on GitHub · 2026-11-24 04:01 UTC · original
KoLolX3:test/vfloat-gpu → main · +138 −10 · 4 files · 1 commits · open

Takes over draft #135 (carried over from the original repo by its author, KoLolX3). Adds a synthetic GPU fixture for floating-point class, f16 FMA and normalized conversions, and legacy multiply-add translations.

Rebased on main 3f81d46a, preserving newer contract documentation and the cs_w64x_cmp_sdst test registration. The fixture tests translated SPIR-V; its result does not establish native hardware behavior for the original AMD opcodes.

Tested on AMD Radeon RX 7900 XT (RADV NAVI31, Mesa 26.3.1, Linux): the fixture translated and passed spirv-val, and all eight expected words matched with subgroup size 32 in native and LEONIDA_W64_EMULATE=1 builds. python -I tests/test_run_gpu_tests.py passed 68 tests; the semantic suite passed 6,279 tests in 487 files. Compileall, make_game.py --help, check_no_game_data.py on changed files and git diff --check passed. Synthetic fixtures only, no game files.

AI-assisted: yes (Claude Code and OpenAI Codex).

**@⁠KoLolX3** on GitHub · 2026-11-24 04:01 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/373) `KoLolX3:test/vfloat-gpu` → `main` · +138 −10 · 4 files · 1 commits · open Takes over draft #135 (carried over from the original repo by its author, KoLolX3). Adds a synthetic GPU fixture for floating-point class, f16 FMA and normalized conversions, and legacy multiply-add translations. Rebased on `main` `3f81d46a`, preserving newer contract documentation and the `cs_w64x_cmp_sdst` test registration. The fixture tests translated SPIR-V; its result does not establish native hardware behavior for the original AMD opcodes. Tested on AMD Radeon RX 7900 XT (RADV NAVI31, Mesa 26.3.1, Linux): the fixture translated and passed `spirv-val`, and all eight expected words matched with subgroup size 32 in native and `LEONIDA_W64_EMULATE=1` builds. `python -I tests/test_run_gpu_tests.py` passed 68 tests; the semantic suite passed 6,279 tests in 487 files. Compileall, `make_game.py --help`, `check_no_game_data.py` on changed files and `git diff --check` passed. Synthetic fixtures only, no game files. AI-assisted: yes (Claude Code and OpenAI Codex).
docs/design.md marks these float VALU rows not GPU-verified: the
translations were CPU-checked (and, except v_mac_legacy_f32, the
instructions measured on hardware), but the translated SPIR-V never
ran on a GPU. cs_vfloat_ext.asm runs one lane through
v_cmp_class_f16 (sNaN, -denormal, -inf, a miss) and v_cmp_class_f64
(-0, a qNaN against the sNaN bit, the smallest +denormal, +inf), one
bit per case; v_fmamk_f16 and v_fmaak_f16 in both print orders,
including the one rounding of (1+2^-10)*3 to 0x4202, with the high
half kept; v_cvt_pknorm_i16_f16/u16_f16 at the even rounding of
0.5*32767, -inf, NaN and a clamped 2.0; and v_mac_legacy_f32 with the
legacy 0 * inf = +0 rule. The eight expected words are derived in its
header from the rows. Registered in check.py and run_gpu_tests.py next
to cs_lds_atomics_ext; the five rows note the GPU check.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:56:15 +00:00
Author
Owner

@⁠Sangonapou on GitHub · 2026-11-24 05:05 UTC · original

Tested d4e5972a on NVIDIA GeForce RTX 3080 Ti Laptop (Ampere, subgroup 32..32), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300): pass

Runtime built at this head with scripts\build_runtime.ps1 (MSVC 19.51, VS Build Tools 2026); llvm-mc 23.1.6 (conda-forge), SPIRV-Tools 2026.4, Vulkan SDK 1.4.363.0. No game files.

  • run_gpu_tests.py --filter cs_vfloat_ext --require-pass: PASS native and with LEONIDA_W64_EMULATE=1 (0xb 0xd 0xa5a54300 0xa5a54202 0x80014000 0xffff0000 0x40000000 0x40500000).
  • Full suite: 258 shaders, 258 translated, 258 pass spirv-val; native 198/249 passed, 49 skipped; emulated 230/249 passed, 17 skipped, i.e. main plus this fixture. The only failures, cs_imgload_tfe and cs_imgload_d16_tfe, fail identically on main ece4ba5b on this card (main: native 197/248, emulated 229/248), the same pair as #31 / #336.
**@⁠Sangonapou** on GitHub · 2026-11-24 05:05 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/373#issuecomment-7122619885) Tested d4e5972a on NVIDIA GeForce RTX 3080 Ti Laptop (Ampere, subgroup 32..32), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300): pass Runtime built at this head with `scripts\build_runtime.ps1` (MSVC 19.51, VS Build Tools 2026); `llvm-mc` 23.1.6 (conda-forge), SPIRV-Tools 2026.4, Vulkan SDK 1.4.363.0. No game files. - `run_gpu_tests.py --filter cs_vfloat_ext --require-pass`: PASS native and with `LEONIDA_W64_EMULATE=1` (`0xb 0xd 0xa5a54300 0xa5a54202 0x80014000 0xffff0000 0x40000000 0x40500000`). - Full suite: 258 shaders, 258 translated, 258 pass spirv-val; native 198/249 passed, 49 skipped; emulated 230/249 passed, 17 skipped, i.e. `main` plus this fixture. The only failures, `cs_imgload_tfe` and `cs_imgload_d16_tfe`, fail identically on `main` `ece4ba5b` on this card (main: native 197/248, emulated 229/248), the same pair as #31 / #336.
Author
Owner

@⁠ohshitwaddup on GitHub · 2026-11-24 17:30 UTC · original

Independent hardware verification of cs_vfloat_ext, plus five documentation defects I confirmed. The fixture itself is correct — all eight words are right. Everything below is about the docs/design.md row text.

The fixture verified on a second card

RX 6900 XT (RDNA2 / GFX1030, Navi 21, PCI 1002:73bf), RADV NAVI21, Mesa 26.2.4, Vulkan 1.4.354, Nobara Linux 44, kernel 7.2.10, subgroup 32..64, run at VKC_SUBGROUP_SIZE=32:

device: AMD Radeon RX 6900 XT (RADV NAVI21) (subgroup 32..64)
compute subgroup size: 32
1 groups x 64: 0 mismatches
out[0..7] = 11 13 2779071232 2779070978 2147565568 4294901760 1073741824 1078984704

Which is 0x0000000B 0x0000000D 0xA5A54300 0xA5A54202 0x80014000 0xFFFF0000 0x40000000 0x40500000 — 8/8 exact, matching the header and check.py. That is an RDNA2 card under RADV where your record has an RX 7900 XT under RADV, so the words now hold across two AMD generations and two drivers.

To be precise about what this proves: the fixture is -mcpu=gfx1013 assembly that build.py assembles and rdna2spirv.py translates, so the GPU executed the translator's SPIR-V, not the native opcodes. That is consistent with how design.md already uses "GPU-checked" elsewhere, and the v_mac_legacy_f32 clause already says so — the wording fixes below just need to make that explicit in all five rows.

Five defects in the row edits

1. All five rows say "native wave64", but the fixture is wave32. It is mattr: +wavefrontsize32,-wavefrontsize64 with group: 32,1,1, and both runners pin VKC_SUBGROUP_SIZE=32 (WAVE32_LANE_DUMPS). The run above confirms compute subgroup size: 32. Suggested: native (wave32) and with LEONIDA_W64_EMULATE=1.

2. v_cmpx_class_f16 / v_cmpx_class_f64 are claimed but never executed. grep -c cmpx_class cs_vfloat_ext.asm is 0; the only cmpx is v_cmpx_eq_u32_e32 0, v0, the EXEC cut to lane 0. L489 and L508 are titled for both forms, and the sibling cs_cmpx_class_f32.asm shows the pattern. Either add a v_cmpx_class_* case (the EXEC narrowing is the interesting part) or say plainly: v_cmpx_class_f16/f64 not GPU-checked.

3. Stale "Not GPU-verified" survives inside the edited rows. The added lines contain the literal string six times, so a row reads **Not GPU-verified.** GPU-checked by … — self-contradictory, and it means the PR does not achieve its own stated goal of flipping them. Two rows also have a broken sentence from the insert:

  • L479: …(a clamped 2.0; one lane, … LEONIDA_W64_EMULATE=1). and not run on the shader corpus. .`
  • L489: same shape.

The orphan and not run on the shader corpus. . should go — the row already says "Not run on the shader corpus." immediately before.

4. L317 overstates the rounding. v_fmaak_f16 uses K=0, so the addend contributes nothing and a separate multiply-then-add gives the identical 0x4202. It shows tie-to-even and operand order (a swap would give 0x4200), which is worth keeping — but "the one rounding of (1+2^-10)*3" claims fusion the probe cannot detect. Suggested: the tie-to-even result 0x4202 of (1+2^-10)*3.

Related, on ties generally: both probes (16383.5 and the 1.5-ulp case) round up under round-to-nearest-even and under round-half-away-from-zero, so a wrong rounding mode would still pass. A discriminating case needs a tie whose lower neighbour is even, e.g. exact 16382.5 → RNE 16382 vs half-up 16383. Optional, but it would make the tie claim falsifiable.

5. v_mac_legacy_f32 cannot be hardware-verified on this silicon, and the row should say so once. llvm-mc 22.1.8 rejects the mnemonic for gfx1030 and gfx1100, accepting it only for gfx1013 — so no RDNA2 desktop part and no RDNA3 part runs it. The presence of "the translated SPIR-V, not the opcode on silicon" is good; it just needs to replace the stale "Not GPU-verified" rather than sit beside it. Suggested:

GPU-checked by cs_vfloat_ext.asm (translated SPIR-V only: the legacy 0 * inf = +0 rule and D as the addend; one lane, …). Not hardware-measured: like the other mad opcodes it exists on gfx1010-1013 only, so no RDNA2 desktop part runs it.

Also, 0 * inf = +0 is checked only with addend 2.0, so the sign of the +0 (the only difference between +0 and -0 here) is unobservable in that probe — fine as a translator test, worth knowing if anyone later reads it as a hardware result.

What I did not check

Your CI: linux-gpu-tools, macos, macos-python and stdlib-tests-linux show failing and check cancelled. I did not confirm your claim that this matches main, so I am neither endorsing nor disputing it.

Summary

The eight expected words are arithmetically correct and I reproduced them on RDNA2 — including the tie-to-even 0x4202, the 0x80014000 pknorm saturation, and both legacy-mac words. The fixture is a sound translator test and I would like to see it merged. Fix items 1–3 (wrong wave size, non-existent v_cmpx_class coverage, stale "Not GPU-verified" + broken sentences) and 4–5 (overstated rounding, legacy-mac wording), and all five rows are honest.

AI-assisted: yes (Hermes Agent) — ran the fixture on an RX 6900 XT and verified each defect above with the commands named.

**@⁠ohshitwaddup** on GitHub · 2026-11-24 17:30 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/373#issuecomment-7139297736) Independent hardware verification of `cs_vfloat_ext`, plus five documentation defects I confirmed. **The fixture itself is correct — all eight words are right.** Everything below is about the `docs/design.md` row text. ## The fixture verified on a second card RX 6900 XT (RDNA2 / GFX1030, Navi 21, PCI 1002:73bf), RADV NAVI21, Mesa 26.2.4, Vulkan 1.4.354, Nobara Linux 44, kernel 7.2.10, subgroup 32..64, run at `VKC_SUBGROUP_SIZE=32`: ``` device: AMD Radeon RX 6900 XT (RADV NAVI21) (subgroup 32..64) compute subgroup size: 32 1 groups x 64: 0 mismatches out[0..7] = 11 13 2779071232 2779070978 2147565568 4294901760 1073741824 1078984704 ``` Which is `0x0000000B 0x0000000D 0xA5A54300 0xA5A54202 0x80014000 0xFFFF0000 0x40000000 0x40500000` — **8/8 exact**, matching the header and `check.py`. That is an RDNA2 card under RADV where your record has an RX 7900 XT under RADV, so the words now hold across two AMD generations and two drivers. To be precise about what this proves: the fixture is `-mcpu=gfx1013` assembly that `build.py` assembles and `rdna2spirv.py` translates, so the GPU executed the **translator's SPIR-V**, not the native opcodes. That is consistent with how `design.md` already uses "GPU-checked" elsewhere, and the `v_mac_legacy_f32` clause already says so — the wording fixes below just need to make that explicit in all five rows. ## Five defects in the row edits **1. All five rows say "native wave64", but the fixture is wave32.** It is `mattr: +wavefrontsize32,-wavefrontsize64` with `group: 32,1,1`, and both runners pin `VKC_SUBGROUP_SIZE=32` (`WAVE32_LANE_DUMPS`). The run above confirms `compute subgroup size: 32`. Suggested: `native (wave32) and with LEONIDA_W64_EMULATE=1`. **2. `v_cmpx_class_f16` / `v_cmpx_class_f64` are claimed but never executed.** `grep -c cmpx_class cs_vfloat_ext.asm` is **0**; the only `cmpx` is `v_cmpx_eq_u32_e32 0, v0`, the EXEC cut to lane 0. L489 and L508 are titled for both forms, and the sibling `cs_cmpx_class_f32.asm` shows the pattern. Either add a `v_cmpx_class_*` case (the EXEC narrowing is the interesting part) or say plainly: `v_cmpx_class_f16/f64 not GPU-checked`. **3. Stale "Not GPU-verified" survives inside the edited rows.** The added lines contain the literal string six times, so a row reads `**Not GPU-verified.** GPU-checked by …` — self-contradictory, and it means the PR does not achieve its own stated goal of flipping them. Two rows also have a broken sentence from the insert: - L479: `…(a clamped 2.0; one lane, … LEONIDA_W64_EMULATE=1`). and not run on the shader corpus. .` - L489: same shape. The orphan `and not run on the shader corpus. .` should go — the row already says "Not run on the shader corpus." immediately before. **4. L317 overstates the rounding.** `v_fmaak_f16` uses **K=0**, so the addend contributes nothing and a separate multiply-then-add gives the identical `0x4202`. It shows tie-to-even and operand order (a swap would give `0x4200`), which is worth keeping — but "the one rounding of `(1+2^-10)*3`" claims fusion the probe cannot detect. Suggested: `the tie-to-even result 0x4202 of (1+2^-10)*3`. Related, on ties generally: both probes (`16383.5` and the 1.5-ulp case) round **up** under round-to-nearest-even *and* under round-half-away-from-zero, so a wrong rounding mode would still pass. A discriminating case needs a tie whose lower neighbour is even, e.g. exact `16382.5` → RNE `16382` vs half-up `16383`. Optional, but it would make the tie claim falsifiable. **5. `v_mac_legacy_f32` cannot be hardware-verified on this silicon, and the row should say so once.** `llvm-mc 22.1.8` rejects the mnemonic for **gfx1030 and gfx1100**, accepting it only for gfx1013 — so no RDNA2 desktop part and no RDNA3 part runs it. The presence of "the translated SPIR-V, not the opcode on silicon" is good; it just needs to replace the stale "Not GPU-verified" rather than sit beside it. Suggested: > GPU-checked by `cs_vfloat_ext.asm` (translated SPIR-V only: the legacy `0 * inf = +0` rule and D as the addend; one lane, …). **Not hardware-measured**: like the other mad opcodes it exists on gfx1010-1013 only, so no RDNA2 desktop part runs it. Also, `0 * inf = +0` is checked only with addend `2.0`, so the sign of the `+0` (the only difference between `+0` and `-0` here) is unobservable in that probe — fine as a translator test, worth knowing if anyone later reads it as a hardware result. ## What I did not check Your CI: `linux-gpu-tools`, `macos`, `macos-python` and `stdlib-tests-linux` show failing and `check` cancelled. I did not confirm your claim that this matches `main`, so I am neither endorsing nor disputing it. ## Summary The eight expected words are arithmetically correct and I reproduced them on RDNA2 — including the tie-to-even `0x4202`, the `0x80014000` pknorm saturation, and both legacy-mac words. The fixture is a sound translator test and I would like to see it merged. Fix items 1–3 (wrong wave size, non-existent `v_cmpx_class` coverage, stale "Not GPU-verified" + broken sentences) and 4–5 (overstated rounding, legacy-mac wording), and all five rows are honest. AI-assisted: yes (Hermes Agent) — ran the fixture on an RX 6900 XT and verified each defect above with the commands named.
Author
Owner

@⁠CodingRule on GitHub · 2026-11-25 12:20 UTC · original

GPU test on an NVIDIA Ada card, for the record: this passes on an RTX 4090.

  • Tested: this branch's head 02af0326 merged onto main 0d80bc5d (clean merge), test programs built from that main with scripts\build_runtime.ps1.
  • Command: python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_vfloat_ext, once native and once with LEONIDA_W64_EMULATE=1.
  • Result: 1/1 translated and spirv-val clean, 1/1 passed in both modes, with the expected words/pixels from the fixture header. Nothing skipped.
  • Device: NVIDIA GeForce RTX 4090 (Ada / AD102), driver 591.86, Vulkan 1.4.325, subgroup 32..32, Windows 11 Pro build 26200. llvm-mc 21.1.8 (scripts\build_llvm_mc.ps1), SPIRV-Tools v2026.4, MSVC 14.44.35207.

Only the filtered fixture(s) were run for this PR, not the full suite or ctest; the full-suite baseline for this card on main is in #1777. Synthetic fixtures only, no game files. AI-assisted (Claude Code ran the tests and wrote this comment).

**@⁠CodingRule** on GitHub · 2026-11-25 12:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/373#issuecomment-7162241485) GPU test on an NVIDIA Ada card, for the record: this passes on an **RTX 4090**. - **Tested:** this branch's head `02af0326` merged onto `main` `0d80bc5d` (clean merge), test programs built from that `main` with `scripts\build_runtime.ps1`. - **Command:** `python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_vfloat_ext`, once native and once with `LEONIDA_W64_EMULATE=1`. - **Result:** 1/1 translated and `spirv-val` clean, 1/1 passed in both modes, with the expected words/pixels from the fixture header. Nothing skipped. - **Device:** NVIDIA GeForce RTX 4090 (Ada / AD102), driver 591.86, Vulkan 1.4.325, subgroup 32..32, Windows 11 Pro build 26200. llvm-mc 21.1.8 (`scripts\build_llvm_mc.ps1`), SPIRV-Tools v2026.4, MSVC 14.44.35207. Only the filtered fixture(s) were run for this PR, not the full suite or ctest; the full-suite baseline for this card on `main` is in #1777. Synthetic fixtures only, no game files. AI-assisted (Claude Code ran the tests and wrote this comment).
This pull request has changes conflicting with the target branch.
  • runtime/test/shaders/check.py
  • scripts/run_gpu_tests.py
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/373/head:github-bot/gh-373'
git switch 'github-bot/gh-373'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-373'
git switch 'github-bot/gh-373'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-373'
git switch 'github-bot/gh-373'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-373'
git switch 'main'
git merge --squash 'github-bot/gh-373'
git switch 'main'
git merge --ff-only 'github-bot/gh-373'
git switch 'main'
git merge 'github-bot/gh-373'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.