Skip to content

Tools: hardware oracle for crosslane_fuzz — 24,000 cross-lane programs on real AMD hardware, wave32 and native wave64, 0 mismatches - #1202

Merged
ItsNotRexed merged 5 commits into
ItsNotRexed:mainfrom
AlxcBTW:hw-oracle-crosslane
Nov 22, 2026
Merged

ItsNotRexed merged 5 commits into
ItsNotRexed:mainfrom
AlxcBTW:hw-oracle-crosslane

Conversation

@AlxcBTW

@AlxcBTW AlxcBTW commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Builds on the hardware oracle from #1160, which has landed.

What and why

tools/crosslane_fuzz.py (FUZZ-7) can now run its generated cross-lane programs natively on an AMD GPU and compare the hardware against the model. Until now that model of wave and cross-lane behaviour had only been checked against the translator, never against hardware.

  • Usage: --oracle hw compares the hardware against the model; --oracle translator,hw runs both comparisons.
  • What runs natively: wave32 and native wave64, with the program's real workgroup size (partial waves, groups of several waves) and its EXEC setup. Every thread stores its 14 words, as on the GPU path.
  • tools/hw_oracle additions: raw kernels, a workgroup size per kernel, and wave64 code objects (-mwavefrontsize64, .amdhsa_wavefront_size32 0, wavefront size in the HSA metadata).
  • Wave-size probe: at startup a v_mbcnt probe checks that wave64 really runs 64-wide, so a runtime that ignored the metadata fails loudly.
  • Hazard guard: each instruction is followed by s_nop 7, because the model has no hazards; --no-hw-guard turns it off.
  • Failures: --keep / --minimize write the kernel that actually ran.
  • Optional, as in Tools: hardware oracle for salu_diff — run the fuzz programs natively on an AMD GPU; first finding fixes the s_bfe reference #1160: without the tools the run exits 77.

Results: Radeon 880M (gfx1150, RDNA3.5), driver 26.11.2

24,000 programs, 0 mismatches. 2000 programs per wave size in each run:

seed, options wave32 match / hypothesis ops confirmed wave64 match / hypothesis ops confirmed
11 2000 / 552 2000 / 592
12, --dpp 2000 / 494 2000 / 606
13, --dpp --ops 40 2000 / 773 2000 / 914
14, --ops 12 2000 / 247 2000 / 269
15, --dpp --no-hw-guard 2000 / 512 2000 / 593
16, --no-maskdata --dpp --ops 60 2000 / 989 2000 / 1111
  • No hidden failures: there were 0 mismatches and 0 assembler rejections. A failed hypothesis op on hardware now counts as a mismatch, and none occurred.
  • Two open hypotheses now hold on hardware, in wave32 and wave64: 7,652 programs contained one of them.
  • Controls: deliberately wrong models produce hardware mismatches in both wave sizes: popcount +1, a perturbed v_readlane, and --permlane-fetch-inactive. So the wrapper does not hide differences.
  • Without the s_nop guard: results are identical, so the generator hits no hazard on this GPU.

Translator against the model (translator,hw, 200 programs, seed 7): the hardware matches the model in every program.

GFX11 differences checked: none of the generated ops needed a skip.

  • row_share, row_xmask, dpp8, fi, bound_ctrl and v_permlane16/x16 are spelled the same on gfx1030 and gfx1150.
  • v_cmpx is generated only as _e32, which writes EXEC only.
  • s_ff1 is an alias of s_ctz on gfx11.

The limit is the same as in #1160: gfx1150 is RDNA3.5, not RDNA2. Agreement here is strong evidence for the model, not proof for gfx1013.

Tested

  • py -I tests/test_crosslane_fuzz.py, tests/test_hw_oracle.py, tests/test_salu_diff.py: green. Without hardware the hardware test is skipped. With hardware it also asserts rejected == 0 and hyp_only == 0.
  • The --oracle hw runs above, on a Radeon 880M with AMD clang 23.0.0git.
  • The kernels also assemble for gfx1030 and gfx1013. They have not run on RDNA2.

An independent review checked that the hardware wrapper matches the model: initial registers, EXEC for partial waves and groups of several waves, lane ids, store layout and branch labels. It reran the controls and confirmed by hand that wave64 really runs 64-wide. Its findings are fixed:

  • hypothesis ops could mask mismatches;
  • the wave-size probe;
  • the test checks for rejections and hyp_only;
  • --keep writes the kernel that ran;
  • the sources for the hypotheses.

AI-assisted (Claude Code).

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No translator change; the model is confirmed on hardware.)

🤖 Generated with Claude Code

AlxcBTW and others added 5 commits November 22, 2026 08:43
…st bit 31

tools/hw_oracle wraps the generated scalar programs in GFX10/GFX11 kernels,
assembles them with AMD clang and runs them through the HIP runtime of the
AMD Windows driver (hw_oracle.c, loaded with LoadLibrary, no SDK). salu_diff
compares the hardware's three SGPRs + SCC with the reference, alone or
together with the translator. A missing tool prints "unavailable" and exits 77.

First finding: s_bfe_i32 with offset + width > 32 stops the field at bit 31
on gfx1150 (width = min(width, 32 - offset)); the reference followed the
pseudocode literally. The translator already did the hardware thing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rness errors)

- LEONIDA_HIP_DLL is now passed to the launcher and loaded
- an all-rejected chunk is a RuntimeError (harness error), not skips
- -1 and 0xffffffff count as one literal; clang is no longer found by
  globbing */.venv under the cwd (env, PATH, HIP_PATH, ROCM_PATH, repo .venv)
- s_bfe past bit 31: say "analogous to LLVM's v_bfe fold", rule rests on the
  gfx1150 measurement; contract row in docs/design.md; Linux/ROCm note

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Runs each FUZZ-7 program natively on the AMD GPU in wave32 and native
wave64, with its real group size and EXEC setup, every thread storing its
14 words, and compares them with the model. hw_oracle gains raw kernels
(own stores), per-kernel workgroup size and wave64 code objects; the
launcher takes name:threads:words tokens.

24,000 programs on gfx1150: 0 mismatches; the permlane FI=0 and DPP8
inactive-source hypotheses hold on the hardware too. Translator mismatches
all trace to masks read as data (ItsNotRexed#293) and permlane (ItsNotRexed#580).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eep writes the kernel that ran

- run_hw: a failing hypothesis op counts as a mismatch (exit 1) and in hyp_only;
  --minimize marks the hypothesis ops that remain
- Oracle startup probe: a wave64 kernel must see lane 32 as 32, a wave32 kernel
  as lane 0 of the second wave
- test_on_hardware also asserts rejected == 0, no mismatches, no hyp_only
- --keep / --minimize write hw_lines() for hardware failures
- docs: where the permlane FI=0 (ItsNotRexed#374, ItsNotRexed#580) and DPP8 (ItsNotRexed#238) hypotheses come from,
  and the re-run table (24,000 programs, hyp_only 0)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AlxcBTW AlxcBTW changed the title Tools: hardware oracle for crosslane_fuzz — 24,000 cross-lane programs on real AMD hardware, wave32 and native wave64, 0 mismatches (Depends on #1160) Tools: hardware oracle for crosslane_fuzz — 24,000 cross-lane programs on real AMD hardware, wave32 and native wave64, 0 mismatches Nov 22, 2026
@Dom-in

Dom-in commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 5636ae8 on an AMD Radeon RX 9070 (RDNA4, gfx1201), AMD 26.11.2, Windows 11 Pro 26300, rocm-sdk-core==10.0.0 clang, launcher built with MSVC cl /O1. It's a second architecture next to the 880M.

As in #1160 (comment there), gfx1201 still stops with a traceback: asm.family() raises ValueError: unsupported GPU architecture 'gfx1201', and tests/test_hw_oracle.py errors in setUpClass (OnHardware) on any RDNA4 machine with the tools installed.

With a local, uncommitted 2-line change (family() accepts gfx12xx and uses the gfx11 spellings), everything runs. The wave-size probe passes, and native wave64 really is 64-wide on RDNA4.

8,000 programs, 0 mismatches, 0 rejected. The table uses --oracle hw --wave both --programs 2000, so 1000 per wave size:

seed, options wave32 match / hyp confirmed wave64 match / hyp confirmed
11 1000 / 265 1000 / 283
12, --dpp 1000 / 252 1000 / 324
13, --dpp --ops 40 1000 / 381 1000 / 440
15, --dpp --no-hw-guard 1000 / 256 1000 / 295

So the permlane16/x16 FI=0 and DPP hypotheses hold on gfx1201 as well: hyp_only 0 everywhere, with 1,995 permlane and 926 DPP hypothesis programs confirmed. That includes the run without the s_nop 7 guard.

With the mapping, tests/test_hw_oracle.py, tests/test_crosslane_fuzz.py and tests/test_salu_diff.py are all OK.

I'll claim the gfx12 support as a follow-up in #1006 and open it after this PR lands, since both touch tools/hw_oracle/asm.py. If you'd rather fold it in here, say so and I'll drop it. It's family() plus a GFX12_REMOVED entry for the SOPK compares that GFX12 dropped (s_cmpk_*, which salu_diff hits).

AI-assisted (Claude Code).

@YaBulochka

Copy link
Copy Markdown
Contributor

Tested 5636ae83 on RX 7600 (gfx1102), RADV Mesa 27.0.0-git (mesa-git), Linux: translator path pass, hardware oracle not runnable here.

Numbers (this commit, 8 threads):

  • scripts/run_gpu_tests.py --llvm-mc /usr/bin/llvm-mc --build runtime/build: 110/110 pass, 3.5 s. Baseline is green before anything else.
  • tests/test_crosslane_fuzz.py: 24 passed, 1 skipped (+4 subtests).
  • crosslane_fuzz.py --oracle translator, 200 programs, seed 7, wave32 + wave64: the summary is identical to origin/main on the same seed. --no-maskdata: 0 mismatches, 26 hyp_only in wave32 and 30 in wave64. --dpp --no-maskdata: 36 + 36 mismatches, i.e. the pre-existing DPP8 fi=0 gap, unchanged by this PR. So no regression on RADV from the crosslane_fuzz.py changes.
  • --oracle hw: hardware oracle unavailable: the launcher targets the Windows AMD driver (amdhip64_7.dll), exit 77. None of the 24,000 programs can be reproduced on Linux/mesa, and --oracle translator,hw drops the translator half too.

Port attempt, local only, not part of this PR: with a ~40-line POSIX launcher the device is detected as AMD Radeon RX 7600 arch=gfx1102 and the _probe kernel runs, so the wave32/wave64 probe gets that far. dlopen("libamdhip64.so.7") needs RTLD_GLOBAL (without it HIP reports no device), and on ROCm 7.10 the HIP calls only stay stable when the binary also links -lamdhip64. Every launch of the raw crosslane kernels (hw_lines + Kernel(..., raw=True)) then SIGSEGVs inside libamdhip64.so.7 (kernel 7.3.3, ROCm 7.10) before any program result, deterministically per module, while a plain hipModuleLoadData / hipModuleLaunchKernel program on the non-raw probe code object works. Not conclusive about your code, but Linux/RDNA2 coverage needs a real POSIX launcher and some work on the raw kernel path.

Method: build as in the FUZZ-7 section, run the stock GPU suite for a green baseline, run crosslane_fuzz with the translator oracle and diff its summary against origin/main on the same seed; hardware attempts through both a dlopen and a directly linked launcher.

No hardware risk from the diff itself (docs, tests and tools/, no rdna2spirv.py), so I would not block the merge on this. Just don't read it as RDNA2/mesa evidence: the oracle is Windows-only by design and the 24,000-program result is gfx1150 on the Windows driver.

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.

4 participants