Skip to content

GPU fixture for v_mqsad_u32_u8 through the translated path (TEST-644) - #4669

Open
rafaelpssz wants to merge 2 commits into
ItsNotRexed:mainfrom
rafaelpssz:test/mqsad-gpu
Open

rafaelpssz wants to merge 2 commits into
ItsNotRexed:mainfrom
rafaelpssz:test/mqsad-gpu

Conversation

@rafaelpssz

@rafaelpssz rafaelpssz commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

TEST-644, the v_mqsad_u32_u8 part (claim). The ds_wrxchg2 part is already run by cs_w32_new_ops.asm on main, and the open #3208 and #2003 add fixtures for it, so it is left to them.

What

The v_mqsad_u32_u8 row of docs/design.md was hardware-verified on RDNA2 (native, through hw_oracle), but the translated path had never run on a GPU (Not GPU-verified). This adds the fixture:

  • runtime/test/shaders/cs_w32_mqsad_u32.asm runs v_mqsad_u32_u8 twice. S0 = 0x88776655_44332211. S1 = 0x40005000, whose bytes 0 and 2 are zero, so the masked SAD has to skip them.
    • A, in place (D = S2): S2 = {0xFFFFFFF0, 1, 2, 3}, so accumulator 0 wraps at 32 bits.
    • B, D over S0 (v[2:5] over v[2:3]): this only gives the expected words if every source is read before the first write, as the row says.
  • The expected words are derived step by step in the .asm header from the ISA pseudocode, and checked by the same formula in Python: 0x22 0x33 0x34 0x3F 0x132 0x232 0x332 0x43C.
  • It is registered in runtime/test/shaders/check.py and scripts/run_gpu_tests.py next to cs_w32_new_ops, as a wave32 fixture.
  • The row in docs/design.md is now GPU-checked.

Tested (RTX 3060, Ampere, driver 616.64, Windows 11)

  • run_gpu_tests.py --filter cs_w32_mqsad_u32: translated, passes spirv-val, PASS (34 51 52 63 306 562 818 1084). It also passes with LEONIDA_W64_EMULATE=1.
  • tests/test_run_gpu_tests.py, test_run_gpu_tests_paths.py (20), test_shader_checks.py (83), test_ctest_registration.py, test_docs_design_rows.py and test_docs_links.py pass, and git diff --check is clean.

Since then it has also passed on an AMD RX 6700 XT (RDNA2), an RTX 5070 Ti and an Apple M2 (MoltenVK); the row says so (6db3a228).

Thanks

  • @Kam471 for the RTX 5070 Ti run (Blackwell): the same eight words.
  • @justr4mzi for the AMD RX 6700 XT run (RDNA2, under validation), which makes it hardware-exact as well.
  • @bobcatchris for the Apple M2 / MoltenVK run, with a negative control on the base.
  • @rgvxsthi for the AMD RX 9070 run (RDNA4, LLPC).

By @rafaelpssz, with Claude Code (AI-assisted).

cs_w32_mqsad_u32 runs v_mqsad_u32_u8 twice on S0 = 0x88776655_44332211 and
S1 = 0x40005000 (two zero bytes the masked SAD skips): in place with D = S2
(one accumulator wraps at 32 bits), and with D over S0, which only gives the
expected words if every source is read before the first write. Expected
words derived from the ISA pseudocode in the .asm. Exact on an RTX 3060
(616.64), native and with LEONIDA_W64_EMULATE=1; the design.md row is now
GPU-checked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built and ran at 698ece2a9 on Windows 11, RTX 5070 Ti.

  • code_hooks_test -> 14 checks, 0 failures.
  • GPU: run_gpu_tests.py --filter mqsad -> 1/1 passed, cs_w32_mqsad_u32 -> 34 51 52 63 306 562 818 1084, translator 1/1 + spirv-val.
  • git diff --check clean.

The fixture exercises v_mqsad_u32_u8 through the translated path with the expected words, and the new archetype hook has its own unit test. Stacking note: the branch carries db51b7d3f (Mods manifests) and 9e6444fad (the archetype hook / --archetype-lookup), both owner-authored, under the fixture change; merging this PR lands both features. Six open PRs share the Mods base, and #4672 shares the archetype base — they merge cleanly with each other but the base is unreviewed by this PR.

@justr4mzi

Copy link
Copy Markdown
Contributor

Tested at 698ece2a on Windows 11 with AMD Radeon RX 6700 XT (RDNA2, gfx1031), LLVM_MC, SPIRV-Tools, and LEONIDA_VK_VALIDATION=1.

Summary

  • Diff over current main (0db7fed5) is now cleanly isolated to the 4 TEST-644 files (docs/design.md, runtime/test/shaders/check.py, runtime/test/shaders/cs_w32_mqsad_u32.asm, scripts/run_gpu_tests.py — the earlier base commits are already in main).
  • Build (vk_compute_test..vk_sampler_test + code_hooks_test, [12/12]): exit 0.
  • python -I scripts/run_gpu_tests.py --build build --filter mqsad --require-pass (LEONIDA_VK_VALIDATION=1): 1 shaders: 1 translated, 1 pass spirv-val, 1/1 passed (cs_w32_mqsad_u32 34 51 52 63 306 562 818 1084) with 0 validation errors.
  • python -I scripts/run_gpu_tests.py --build build --filter cs_w32 --require-pass (LEONIDA_VK_VALIDATION=1): 14 shaders: 14 translated, 14 pass spirv-val, 14/14 passed (0 validation errors).
  • ctest -R "^code_hooks$": 1/1 std (0.04 sec) & LEONIDA_VK_VALIDATION=1 (0.01 sec), code_hooks_test.exe (14 checks, 0 failures).
  • Python & hygiene checks: tests/test_shader_checks.py (79/79 OK, 1.511s), tests/test_run_gpu_tests.py (41/41 OK, 0.585s), tests/test_docs_*.py (30/30 OK, 22.391s), tests/test_ctest_registration.py (4/4 OK, 0.054s), scripts/check_no_game_data.py (exit 0), git diff --check (exit 0).

AI-assisted (Gemini, Antigravity).

@bobcatchris

Copy link
Copy Markdown
Contributor

Apple M2 / MoltenVK validation of head 698ece2a9efa516d9d8d950539a9566d45ad4f62 (hardware reports Apple M2 / Mac14,3, not M1), macOS 26.4, MoltenVK 1.4.2, subgroup range 4..32, llvm-mc 23.1.6. Clean full build on AppleClang 17.

  • python -I scripts/run_gpu_tests.py --filter cs_w32_mqsad_u32 --build runtime/build/linux (built as runtime/build/vulkan here): 1 shader translated, 1 pass spirv-val; 1/1 passed — words 34 51 52 63 306 562 818 1084, exactly the values derived in the fixture header, 0 mismatches.
  • Full suite on the PR head: 221 shaders translated, 221 pass spirv-val; 153/218 passed, 58 skipped, 7 failed (the known MoltenVK expected set).
  • Negative control on the PR's base 3eb4410b8de7a6d28cb81557e7bca6de864fda56 with the identical commands: 220 shaders, 152/217 passed, 58 skipped, 7 failed. The only difference is this PR's new fixture, which passes; no common test changed status in either direction.

No code changes, no game data; synthetic shader and counts only.

AI-assisted.

…ltenVK too

@justr4mzi (RX 6700 XT, gfx1031), @Kam471 (RTX 5070 Ti) and @bobcatchris
(Apple M2 / MoltenVK) ran cs_w32_mqsad_u32 with the same eight words.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rafaelpssz

Copy link
Copy Markdown
Contributor Author

Thanks @justr4mzi and @bobcatchris. The RDNA2 run makes this hardware-exact and not only translator-exact, and the M2 run comes with a negative control. The row now lists both (6db3a228), and you're in Thanks.

@rgvxsthi

Copy link
Copy Markdown

Tested 698ece2a merged onto main 0db7fed5 (3 commits behind; merges cleanly) on AMD Radeon RX 9070 (RDNA4), AMD 26.11.2 (LLPC), Windows 11 Pro 10.0.26300, MSVC 14.44.35207, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0, Ninja RelWithDebInfo, llvm-mc 23.1.6 (conda-forge): pass.

  • python -I scripts/run_gpu_tests.py --build runtime/build --filter mqsad: PASS cs_w32_mqsad_u32 34 51 52 63 306 562 818 1084, 1/1.
  • Whole GPU suite on the same build: 222 shaders, 222 translated, 222 pass spirv-val; 203/218 passed, 15 skipped, 0 failed (the skips are the ones the d3d12 tests run).

So the translated v_mqsad_u32_u8 path now has an AMD RDNA4 GPU run next to the RDNA2 hw_oracle result. No game files. AI-assisted (Claude Code).

@rafaelpssz

Copy link
Copy Markdown
Contributor Author

Thanks @rgvxsthi, RDNA4 makes three AMD generations with the same eight words. You're in Thanks.

@memorypressure

memorypressure commented Nov 23, 2026 •

Copy link
Copy Markdown

Verified on Linux: the single design.md row passes both docs-compliance tests at the head (paths and the --wave64-emulate flag all tracked/real). Note it belongs with the TEST-644 stack: the cited fixture cs_w32_mqsad_u32.asm exists only there — on plain main the row still reads "Not GPU-verified" and a standalone cherry-pick conflicts and would break test_docs_repo_paths. The added hardware results (RX 6700 XT, RTX 5070 Ti, MoltenVK on M2) cannot be reproduced from this CPU-only host and rest on the reporters' runs. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

Correction (2026-11-23): stale-ref error: the cs_w32_mqsad_u32.asm fixture is not on main but arrives via this PR's lineage when merged (the merge-tree is clean) — so no ordering blocker, but merging lands the lineage with it. The hardware-claims note stands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants