Skip to content

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

Open
KoLolX3 wants to merge 1 commit into
ProjectLeonida:mainfrom
KoLolX3:test/vfloat-gpu
Open

KoLolX3 wants to merge 1 commit into
ProjectLeonida:mainfrom
KoLolX3:test/vfloat-gpu

Conversation

@KoLolX3

@KoLolX3 KoLolX3 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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).

@Sangonapou

Copy link
Copy Markdown
Contributor

Tested d4e5972 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.

@ohshitwaddup

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 25, 2026
…_pknorm_*_f16 and v_mac_legacy_f32

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.
@CodingRule

Copy link
Copy Markdown
Contributor

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).

@github-actions github-actions Bot added needs rebase Conflicts with the base branch: rebase it on main and removed needs rebase Conflicts with the base branch: rebase it on main labels Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants