Skip to content

test(semantic): add translator tests for VALU Cross-Lane Permutation & Data Exchange Suite - #6033

Open
slopgobblercobbler wants to merge 25 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-valu-cross-lane-bundle
Open

slopgobblercobbler wants to merge 25 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-valu-cross-lane-bundle

Conversation

@slopgobblercobbler

Copy link
Copy Markdown
Contributor

What

Adds comprehensive reference oracles, symbolic AST, deterministic interpreter, multi-lane Wave64 divergence tests, and translator integration tests for Bundle 54: VALU Cross-Lane Permutation & Data Exchange Suite in tests/semantic/test_valu_cross_lane_bundle.py.

Covers all 5 RDNA2 cross-lane data exchange and lane permutation opcodes:

  • v_readfirstlane_b32
  • v_readlane_b32
  • v_writelane_b32
  • v_permlane16_b32
  • v_permlanex16_b32

Every test across all suites exercises support.translate_lines(...) and executes via spirv_mini_interp:

  1. Reference mathematical oracle and architectural models matching RDNA2 hardware semantics
  2. Symbolic AST opcode definitions, typed operand validation, and deterministic cross-lane simulation
  3. Multi-lane Wave64 divergence, active lane masking, modulo lane indexing (mod 64 / mod 32), and row routing
  4. Register aliasing, operand preservation, and nibble selector decoding
  5. Translator validation exercising tools/rdna2spirv.py via support.translate_lines(...), asserting SPIR-V operations (OpGroupNonUniformShuffle, OpBitFieldUExtract, OpBitwiseXor, OpSelect, etc.) and mutation detection

Tested

  • Tested with Python 3.10+ (python -I)
  • python -m compileall -q tests (Clean, 0 errors)
  • python -I tests/semantic/test_valu_cross_lane_bundle.py (All 24 test classes passed, OK)
  • python -I tests/test_semantic_translator_use.py (All 3 tests passed, OK)
  • Standard library Python only (unittest, struct, dataclasses, enum, typing)
  • Strictly zero game data, binaries, or proprietary keys

@Dom-in

Dom-in commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Reviewed 8d2112b25. The translator tests in this file don't check what the translated shader computes, so they pass with a broken translation.

Reproduce (Windows 11, Python 3.13.14, no GPU, no game files):

  1. In tools/rdna2spirv.py, in the v_readlane_b32 branch, change the lane mask from self.cu(63 if self.wave64 else 31) to self.cu(0), so every v_readlane_b32 reads lane 0.
  2. python -I tests/semantic/test_valu_cross_lane_bundle.py → Ran 43 tests ... OK.
  3. With the same change, pytest tests/semantic/test_wave64_cross_half.py tests/semantic/test_wave32_lane_select.py tests/semantic/test_lane_masks_edge_cases.py tests/semantic/test_loop_ballot_barrier.py tests/semantic/test_fspx_wave_size.py tests/semantic/test_wave32_pixel_subgroup64.py → 9 failed (for example test_wave64_cross_half.py::NegativeControls::test_readlane_lane_select_mod_32).

Why:

  • The model_* functions are defined in the test file itself, so the oracle tests check the file against itself.
  • The test_translator_* tests assert opcode names in the SPIR-V text (OpCapability Shader is in every module).
  • They call si.run_workgroup(...), but the programs store nothing and the result is never read, so the run only shows the module executes without crashing.

That's also why the "mutation detection" in the description doesn't hold: a change to what the translation computes isn't detected.

Suggestion: make each program write its result and compare it per lane with the model, the way tests/semantic/test_alu_bitwise_swap.py does (run_ps_lines(..., export_regs=...) then assertEqual(words, ...)). Then the step-1 change makes the file fail.

AI-assisted (Claude Code).

@DavidM1911

Copy link
Copy Markdown

Tested 8d2112b: python -m unittest discover -s tests/semantic -p test_valu_cross_lane_bundle.py — 43/43 OK, Windows 11, Python 3.14. AI-assisted. No game files.

@lunarminus

Copy link
Copy Markdown

Tested 8d2112b2 merged onto main d0835dd9 on an AMD Radeon 760M (RDNA3 iGPU, gfx1103, subgroup 32..64), RADV Mesa 26.3.1, CachyOS Linux: pass (but see the mutation result: the new translator tests don't catch a broken v_readlane_b32)

  • Tree tested: the branch is based on 561b65a8, which already contains d0835dd9, so the merge was a fast-forward to 8d2112b2. The tested tree is 561b65a8 plus the one new file, tests/semantic/test_valu_cross_lane_bundle.py. Nothing under runtime/ changes, so I used an existing up-to-date 561b65a8 build.
  • Syntax check: python -m compileall -q tests is clean.
  • New file: 43/43 OK three ways: python -I tests/semantic/test_valu_cross_lane_bundle.py, python -m unittest discover -s tests/semantic -p test_valu_cross_lane_bundle.py, and pytest.
  • tests/test_semantic_translator_use.py: 3/3 OK.
  • The six lane test files from Dom-in's review (test_wave64_cross_half, test_wave32_lane_select, test_lane_masks_edge_cases, test_loop_ballot_barrier, test_fspx_wave_size, test_wave32_pixel_subgroup64), run with pytest: 42 passed, 44 subtests passed.
  • Dom-in's mutation, reproduced: I changed the v_readlane_b32 lane mask in tools/rdna2spirv.py (line 7542 on this tree) from self.cu(63 if self.wave64 else 31) to self.cu(0), in a scratch copy of tools/ and tests/.
    • The six files go to 9 failed, 38 passed (e.g. test_wave64_cross_half.py::NegativeControls::test_readlane_lane_select_mod_32).
    • The new file still passes 43/43.
    • So its test_translator_* tests don't detect a wrong lane select, which matches Dom-in's review.
    • Side note: LEONIDA_TOOLS_DIR has no effect under pytest, because tests/conftest.py imports rdna2spirv from the repository's tools/ first. That's why the mutation was run from a copied tree.
  • scripts/run_gpu_tests.py, both modes: 216/232 passed, 16 skipped, with and without LEONIDA_W64_EMULATE=1. A fresh run of 561b65a8 without the PR gives the same totals, and comparing PASS/FAIL/SKIP per test shows no differences in either mode.
    • Against d0835dd9 without the PR (196/210 passed, 14 skipped): all 210 common tests have the same result.
    • The 22 extra lines (20 PASS, 2 SKIP) are fixtures main added between d0835dd9 and 561b65a8, not from this PR.
    • The PR adds no GPU fixture, so the GPU run only shows that the tree doesn't regress. It says nothing about the new tests.
  • No command specific to AMD or 32-wide GPUs was requested in the PR or its comments, so nothing beyond the above was run.

AI-assisted (Claude Code).

@ErayOzdayioglu

Copy link
Copy Markdown

Re-checked the current head e423a08 against @Dom-in's review of 8d2112b (Windows 11 26200, Python 3.12.10, llvm-mc 23.1.6, CPU only, no game files): pass, and the review point is fixed.

  • python -I tests/semantic/test_valu_cross_lane_bundle.py: 24 tests OK. The previous head had 43; this one has fewer tests, but they read results back.
  • Dom-in's mutation, v_readlane_b32 masking the lane select with 0 so that it always reads lane 0: the file now fails (5 failures in TestReadLane, including test_indexing, test_modulo_64 and test_mutation_guard). On 8d2112b it passed.
  • A second mutation, v_permlanex16_b32 without the row swap (OpBitwiseXor ... 16 changed to ... 0): fails too (4 failures in TestPermLaneX16, including test_cross_half_row_swap).

So the translator tests now compare the translated result per lane, at least for these two ops. I didn't mutate v_readfirstlane_b32, v_writelane_b32 or v_permlane16_b32.

AI-assisted: yes

@Spggety

Spggety commented Nov 23, 2026

Copy link
Copy Markdown

Tested e423a08e on AMD Radeon RX 6600 XT (Navi 23, gfx1032, RDNA2, discrete), AMD proprietary driver 24.10.1 (32.0.12019.1028, Vulkan 1.3.292), subgroup 32..64, Windows 11 (build 22631). Toolchain: MSVC 14.44, Vulkan SDK 1.4.363.1, llvm-mc from rocm-sdk-core 10.0.0, Python 3.11.9. Pass.

  • python -I -m unittest discover -s tests/semantic -p test_valu_cross_lane_bundle.py (with LLVM_MC set, so the translator half runs): 24 tests, OK.

This PR is tests only and adds no GPU fixture, so there is nothing more for the GPU to run.

Synthetic inputs only, no game files. AI-assisted (Claude Code).

@InCaseOf

Copy link
Copy Markdown

Tested e423a08 on RX 5700 XT (RDNA1, gfx1010, RADV NAVI10), Mesa 26.3.1, Linux 6.18: pass

  • scripts/run_gpu_tests.py: 204/232 passed, 28 skipped, 0 failed.
  • w64_graphics.py over all fixtures: 29/29 ok.
  • tests/semantic/test_valu_cross_lane_bundle.py: Ran 24 tests in 0.711s OK
  • python -m unittest discover -s tests/semantic (this base predates run_semantic_tests.py): 6174 tests OK (1 skipped, 1 expected failure).

LLVM llvm-mc 23.1.5, SPIRV-Tools v2026.4, Python 3.14; test programs built from main e36d4c4 unless rebuilt for the PR as noted. main e36d4c4 on the same GPU: run_gpu_tests.py 212/240, 28 skipped, 0 failed; w64_graphics.py 29/29; semantic suite 2 files failing (test_image_atomics_guard, test_image_store_d16). No game files.

AI-assisted (Claude Code).

@jpjonte

jpjonte commented Nov 23, 2026

Copy link
Copy Markdown

Tested e423a08 merged onto main 1924c8f on AMD RX 9070 XT (RDNA4, gfx1201, wave32 and wave64), RADV Mesa 26.3.1, Arch Linux (kernel 7.3.5), Python 3.14: pass.

  • The PR's own tests: tests/semantic/test_valu_cross_lane_bundle.py: 24 tests, OK.
  • Semantic suite: no change from main 1924c8f. The 48 failures there are the stale test_image_atomics_guard / test_image_store_d16 tests that tests: fix image atomics guard and image_store d16 tests after #4473 and #6805 #7608 fixes, and this PR adds none.
  • compileall: OK. scripts/run_gpu_tests.py: 245/245 translated, all spirv-val-valid, 222/239 passed, 16 skipped. runtime/test/shaders/check.py: 207 of 210 pass, 3 skipped. Same per-test results as main, apart from ms_wave_info_s3, a mesh-shader fixture that fails intermittently on main on this GPU as well, unrelated to this PR.

No game files. AI-assisted (Claude Code).

@karearl

karearl commented Nov 23, 2026

Copy link
Copy Markdown

Hardware: AMD Radeon Graphics gfx1036 (Raphael iGPU, Windows driver 32.0.11024 / 24.10.24, wave64, maxPushConstantsSize 128, run with LEONIDA_PC_TAIL_UBO=1) and RTX 5080 (NVIDIA 621.24, wave32, native and LEONIDA_W64_EMULATE=1), Windows 11 IoT Enterprise LTSC 2024, MSVC 2022, llvm-mc 21.1.8, SPIRV-Tools v2026.4.

Baseline on main 3e1e6ea11 on this machine: run_gpu_tests.py fails ms_clip (AMD) and ms_wave_info_s3 (both GPUs); run_semantic_tests.py fails test_image_atomics_guard and test_image_store_d16. PRs on an older base also fail test_float_nan_fract, which #7302 fixed on main. "Same as main" below means exactly these.

AI-assisted (Claude Code).

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.

9 participants