Skip to content

Add GFX12 hardware oracle support and improve GPU testing - #4152

Open
nandorjanosi wants to merge 5 commits into
ItsNotRexed:mainfrom
nandorjanosi:test-388-development
Open

nandorjanosi wants to merge 5 commits into
ItsNotRexed:mainfrom
nandorjanosi:test-388-development

Conversation

@nandorjanosi

@nandorjanosi nandorjanosi commented Nov 22, 2026 •

Copy link
Copy Markdown

What and why

Adds GFX12 (RDNA 4) hardware oracle support and improves GPU testing.

Tested

  • AMD Radeon RX 9070 XT (gfx1201).
  • 120/120 translator programs matched hardware results.
  • Negative controls detected.
  • Semantic tests: 17 passed, 24 subtests passed.

Checklist

  • No game data, keys or decryption included.
  • No new translator rule introduced; this contribution focuses on hardware oracle support and testing.

@bobcatchris

Copy link
Copy Markdown
Contributor

Independent CPU verification of b1cb9b764947f99e83a25fc5d6c4259b03e61a17 against base aa2988cc555bad7ecd508b48a702adbb32fe7c95 (AI-assisted, no GPU run; synthetic fixtures only).

PR head:

  • python -I tests/semantic/test_loop_ballot_barrier.py: 17/17 OK
  • python -I tests/test_hw_oracle.py: 42 passed / 2 skipped
  • python -m pytest tests/test_image_fuzz_hw.py -q: 29 passed / 1 skipped
  • python -I -m compileall -q on the five changed tool files: exit 0

Untouched base with the same test files:

  • test_loop_ballot_barrier.py: 17/17 (unchanged, as expected)
  • test_hw_oracle.py: 1 failure — gfx12 kernel still uses the gfx10 s_load_dwordx2 mnemonic
  • test_image_fuzz_hw.py: 2 failures — no T# layout for gfx12 (gfx1201)

The negative controls land exactly on the new GFX12 oracle/T# paths, so the CPU-side change is well scoped. No game data or hardware was used.

@iurysf

iurysf commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Code read of b1cb9b7: the GFX12 kernel spelling is right, and two of the new paths are untested.

Windows 11, CPython 3.14.6, llvm-mc 23.1.6. py -3.14 -m unittest tests.test_hw_oracle: 42 passed, 2 skipped. py -3.14 -m unittest tests.semantic.test_loop_ballot_barrier with LLVM_MC: 17 passed. Eighteen image-fuzz tests that do not need a pytest fixture passed, including test_t_sharp_gfx12_exact_words. Patching hw_oracle.runner.open_oracle to an arch gfx1300 makes image_fuzz.main return 77 and print unsupported GPU architecture 'gfx1300'. No AMD clang is installed (LEONIDA_AMD_CLANG unset), so the hardware oracle did not run. pytest is not installed here; the nine fixture tests were not run as pytest.

Live mutant, kernel text: putting the GFX11 spelling back at tools/hw_oracle/tsharp.py:156 (v[2:3] and unorm for every family) still leaves those 18 tests green. test_kernel_text_per_family only walks gfx1150 and gfx1030 (tests/test_image_fuzz_hw.py:124). llvm-mc -mcpu=gfx1201 accepts image_load v[8:11], [v2, v3], s[8:15] dmask:0xf dim:SQ_RSRC_IMG_2D and rejects v[2:3] (operands are not valid for this GPU) and rejects unorm (invalid operand).

Live mutant, calls: skipping OpControlBarrier when call_stack is non-empty still passes all 17 semantic tests. test_barrier_inside_called_function only asserts memory == {} (tests/semantic/test_loop_ballot_barrier.py:1622). Dropping the OpReturnValue store is caught: the nested-call test raises KeyError: Unknown SSA id %first.

The GFX12 WORD4 pitch branch is not separable from the GFX11 formula inside the legal size range. The largest pitch is 16383 (width 16129, 1 byte per texel), so bit 14 is never set. s_load_dwordx2 and s_load_b64 encode as the same bytes on gfx1201 (80 20 00 f4 00 00 00 f8); s_load_b64 is rejected on gfx1030. DMASKS is the same 15 values, reordered. git diff --check reports trailing whitespace at tools/hw_oracle/tsharp.py:37 and tools/image_fuzz.py:521. The module comment at tsharp.py:30 still says GFX12 is not built here.

AI-assisted code read (Claude)

@sds-228 sds-228 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.

Code review of b1cb9b7: one issue. git diff --check reports trailing whitespace in tools/hw_oracle/tsharp.py and tools/image_fuzz.py; please strip it before merge. Targeted suites: 17, 44 and 25 tests OK (some skips).

AI-assisted (OpenCode).

@AC-Storm-YT

Copy link
Copy Markdown
Contributor

Tested b1cb9b76 on real hardware, both RDNA4 and RDNA2: Windows 11, AMD Windows driver 26.11.2, tools/hw_oracle (HIP launcher), AMD clang from rocm-sdk-core 10.0.0.

AMD Radeon RX 9070 XT (RDNA4, gfx1201, driver 32.0.32029.2010):

  • image_fuzz.py --oracle hw --programs 120 --seed 1: 120/120 match (60 wave32, 60 wave64), as in the description.
  • --programs 2400 --seed 2: 2400/2400 match (1200 wave32, 1200 wave64).
  • --programs 180 --seed 1 --negative-control: unperturbed model 0/180 mismatch. Every perturbation is caught (unorm_256 30, swap_rb 144, sint_unsigned 30, alpha_zero 16, dmask_in_place 132, no_sentinels 168, transpose 166 of 180), and so is every wrong T# FORMAT (30/30, 30/30, 30/30, 24/30, 30/30, 30/30).

Ryzen 7 9800X3D iGPU (RDNA2, gfx1036, driver 32.0.21045.29003), to check that the gfx10 path is unchanged: --programs 2400 --seed 2 gives 2400/2400 match.

Controls on the 9070 XT:

  • main aa2988cc's tools/: exit 77, no T# layout for gfx12 (gfx1201); this builder knows gfx10, gfx11.
  • FORMAT put back at the GFX11 position (code << 20 instead of code << 17 in image_words): 116 of 120 cases mismatch, so the hardware needs the new GFX12 position.
  • word6 bit 15 cleared: still 120/120, so these linear, one-mip loads don't show what that bit is for.

PR tests on Windows (Python 3.13): tests/test_hw_oracle.py 51 OK (1 skipped), pytest tests/test_image_fuzz_hw.py 30 passed, tests/semantic/test_loop_ballot_barrier.py 17 OK.

Synthetic textures only, no game files.

@memorypressure

Copy link
Copy Markdown

Verified on Linux: merges cleanly with current main and merge-trees cleanly against both #4087 and #3954. The new/changed suites pass (test_hw_oracle 44 OK / 2 skipped; test_image_fuzz_hw 29 passed / 1 skipped, so the GFX12 T# word tests ran; test_loop_ballot_barrier 17 OK) — but the DMASKS reorder in tools/image_fuzz.py breaks the pre-existing test_dmask_schedule_covers_each_format_and_keeps_full_mask_first, which asserts DMASKS[0] == 0xf; that test passes on main and fails on this head, so the reorder needs to keep the full mask first or carry the invariant's update with its rationale. Smaller items: a computed-then-unused mismatched list and trailing whitespace in negative_control, formatting artifacts in tsharp.py's gfx12 dict, and literal #### scaffolding lines in test_image_fuzz_hw.py. The loop_ballot_barrier parser refactor is unrelated to GFX12 and belongs in its own PR. The GFX12 descriptor-bit claims are self-consistent with the unit tests but no GFX12 hardware was available here. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

nullmarsh added a commit to nullmarsh/Leonida that referenced this pull request Nov 23, 2026
…lable" and exit 77

docs/testing.md says a tool that cannot use the hardware oracle prints
"hardware oracle unavailable: ..." and exits 77. On an RDNA4 card (RX 9060
XT, gfx1200) ten tools ended otherwise at main 561b65a: an uncaught
RuntimeError or ValueError, a "harness error" exit 2, or rows printed as
MISMATCH whose hardware value was the reason text. None of that is a model
failure on RDNA4: their kernels cannot run there, for a reason known before
anything is assembled.

- asm.modes_skip_reason: every kernel of the tool sets IEEE and DX10_CLAMP,
  which gfx1170+ fixes (f32_fuzz, f16_trans_sweep, pknorm_probe,
  fma_mix_probe, vinterp_hw_probe).
- asm.family_skip_reason: the kernel text is an older family's.
  buffer_swizzle_probe and smem_neg_probe use MUBUF/MTBUF forms, which the
  GFX12 assembler rejects and gfx1150 still takes. vcmp16_opsel_probe is raw
  GFX10 compare opcodes (0xC9 for v_cmp_lt_f16_e64 on gfx1036, 0x01 on
  gfx1150 and gfx1200), so on GFX11 and GFX12 it printed the oracle's
  sentinel as a result; it now also refuses a word the kernel never stored.
  sampler_lod_probe sets GFX10 mip fields and exited 2 elsewhere.
- texoff_probe reports a missing T# layout as image_fuzz does, instead of
  raising.

mad_denorm_probe already exits 77 on main (v_mad_f32 is GFX10.1 only), and
lds_fuzz, valu_fuzz and the GFX12 T# are left to ItsNotRexed#3978, ItsNotRexed#4519, ItsNotRexed#5576 and
ItsNotRexed#4152.

tests/test_hw_oracle_gfx12_unavailable.py runs each tool with a fake
oracle reporting gfx1200 (exit 77, the reason, no kernel run, oracle
closed), gfx1030 (every tool still reaches Oracle.run) and gfx1150. It
fails for all ten tools without the change. docs/testing.md lists what
runs on RDNA4 and what does not.

Tested on an RX 9060 XT (gfx1200, AMD 26.11.2, rocm-sdk-core 10.0.0 clang,
HIP launcher): the ten tools exit 77 with their reason; salu_diff,
crosslane_fuzz (50/50) and int_hw_probe (186/186) are unchanged. Not run on
GFX10 or GFX11 hardware. Synthetic programs only, no game files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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