Skip to content

feat(hw-oracle): assemble and run the template on gfx12 - #25979

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
Helldiverr:feat/hw-oracle-gfx12
Nov 23, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
Helldiverr:feat/hw-oracle-gfx12

Conversation

@Helldiverr

@Helldiverr Helldiverr commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What

The stock tools/hw-oracle template does not assemble for RDNA4. The gfx12 kernel descriptor has no IEEE mode or DX10 clamp field, so comgr rejects .amdhsa_ieee_mode and .amdhsa_dx10_clamp (directive unsupported on gfx12+). The template's s_waitcnt lgkmcnt(0) / s_waitcnt vmcnt(0) still assemble for gfx12, but as SOPP opcode 9 (bf89fc07), not as the gfx12 counter waits (s_wait_kmcnt 0 = bfc70000, s_wait_loadcnt 0 = bfc00000).

  • template.s takes the two waits and the two mode directives from placeholders. hw_oracle.assemble fills them for the assembly target: the gfx12 counter waits and no IEEE/DX10 clamp directives on gfx12*, and the same lines as before everywhere else.
  • ieee and dx10_clamp are None on gfx12 (--ieee none --dx10-clamp none) and stay required 0/1 integers on older targets. A mismatch is a ValueError (a usage error in the CLI) before anything is assembled. The other modes are unchanged, and every mode is still required.
  • --json reports record null for the two modes. compare_results.py accepts null for those two modes only and only in gfx12* reports, requires integers for them on every other target, and treats null and an integer as different settings.
  • HW_ORACLE.md gets an "RDNA4 (gfx12) differences" section. It notes that probe_catalog.py still passes integers for both modes, so the catalog does not run on gfx12; that is left for a follow-up.

This follows up the gfx1201 measurement in #25964 (#25964 (comment)), which needed a patched copy of the template.

Tested

Windows 11 Pro build 26300, AMD Radeon AI PRO R9700 (gfx1201), AMD driver 32.0.31044.16, amdhip64_7.dll, amd_comgr_3.dll, Python 3.15.

  • python3 tools/hw-oracle/test_hw_oracle.py: 84 tests OK, 5 skipped (Linux HSA runner, POSIX compiler fixtures, no clang). The comgr test now also assembles the gfx1201 template in wave32 and wave64. New tests cover template rendering on gfx1013/gfx1036/gfx1100/gfx1151 and gfx1200/gfx1201/gfx12-generic, the target and mode mismatch errors, None rejected for the other modes, and the CLI's none forwarding, JSON output and invalid values.
  • python3 tools/hw-oracle/test_compare_results.py: 20 tests OK, including gfx12 reports with null modes, null against an integer, null in other modes, null on gfx1030/gfx1100/gfx1151 and integers on gfx1200/gfx1201/gfx12-generic.
  • python3 tools/hw-oracle/test_probe_catalog.py: OK.
  • Native runs with the stock CLI (no patched copy) on the R9700: v_add_nc_u32, v_lshl_add_u32 and v_max_num_f32 rows in wave32 and wave64, fine and coarse memory, with the expected results. For example, 0xffffffff << 1 + 0x7fc00000 gives 7fbffffe, and v_max_num_f32(qNaN, 1.0) gives 3f800000. Integer --ieee on gfx1201 fails with ieee must be None on gfx1201, .... Two --json runs compare as 0 differing words with compare_results.py.
  • No regression for older targets: through comgr, main and this branch produce byte-identical code objects for gfx1013, gfx1030, gfx1100 and gfx1151 in wave32 and wave64, with non-default modes (ieee=1 dx10_clamp=0 denorm32=2 round32=1 round16=2 fp16_overflow=1). No RDNA2 or RDNA3 GPU was available here to run them, so those targets are checked by assembly only.
  • python3 tools/check_conventions.py --base origin/main and python3 tools/pr_overlap.py --branch feat/hw-oracle-gfx12 (no overlap) passed.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

The gfx12 kernel descriptor has no IEEE mode or DX10 clamp field and
the template's s_waitcnt waits are not the gfx12 counter waits, so the
stock template failed to assemble on RDNA4. The template now takes the
waits and both mode directives from the assembly target, ieee and
dx10_clamp are None on gfx12 and required integers elsewhere, and
compare_results.py accepts null for those two modes.

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

Reviewed — looks good

Nothing blocks this change; the optional point below is to extend the probe catalog in a follow-up if gfx12 catalog runs are needed.

What I ran

Reviewed head 2640fbc65a8037534427fc5311736312eeb4d466 from the prepared diff and read the changed files listed below. No commands or tests were run; repo_read.py was unavailable as a command in this review interface.

Results

Check Result Note
Change and targeted call paths passed Reviewed all six changed files
Automated tests not run Author-reported results were not independently verified
Runtime behavior not run No GPU or assembler run

Findings

Blocking

None.

Non-blocking

  • The PR documents that probe_catalog.py does not run on gfx12 because its stored modes are integers. Supporting gfx12 catalog runs could be considered separately; this limitation is explicitly called out in docs/dev/HW_ORACLE.md.

Not verified

  • Automated test results, assembler output and GPU behavior were not independently verified.
  • All six changed files listed as reviewed in manifest.json were read. No changed files were excluded by files.json; that file was not present in the review bundle.

To get this to a good state

Nothing is required. The probe catalog limitation is optional follow-up work.

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

I ran the exact head on Windows with Python 3.15.2: test_hw_oracle.py passed 84 tests with 6 skips (no AMD comgr/clang here), test_compare_results.py passed 19, test_probe_catalog.py passed 40, and tools/check_conventions.py --base origin/main passed. I did not run a native AMD kernel. The GFX12 template split and older-target rendering look consistent, but there is one report-validation issue below.

AI-assisted: yes.

modes = report["floating_point_modes"]
if not isinstance(modes, dict) or modes.keys() != MODES.keys() or any(
not integer(modes[name], 0, limit - 1) for name, limit in MODES.items()):
not integer(modes[name], 0, limit - 1) and not (name in GFX12_REMOVED_MODES and modes[name] is None)

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.

[P2] Tie nullable modes to the GFX12 assembly target

This currently accepts null for ieee and dx10_clamp in every report, not only GFX12 reports. I reproduced it by changing both modes to null in two otherwise valid gfx1030 fixtures: the CLI exits 0 and prints 0 differing words, although hw_oracle.py correctly refuses to generate that combination. Since this function is the report validator and the documented invariant is None only on gfx12* (integers on older targets), please cross-check assembly_target against the two mode values and add both invalid-direction cases. Otherwise a hand-edited or externally produced impossible older-target report is accepted as oracle evidence.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 2bc007a. read_report now checks the two modes against assembly_target after the existing type checks. On gfx12* both must be null (ieee must be null on gfx1201, whose kernel descriptor has no ieee field). On every other target both must be integers (ieee must be an integer from 0 to 1 on gfx1030). Both errors match what hw_oracle.assemble raises.

New test_removed_kernel_modes_are_null_only_on_gfx12 covers both directions:

  • null for each mode on gfx1030, gfx1100 and gfx1151;
  • 0 and 1 for each mode, with the other mode null, on gfx1200, gfx1201 and gfx12-generic.

test_removed_kernel_modes_differ_from_explicit_modes now compares a valid gfx1201 report (both modes null) with the gfx1030 fixture. The old version left one integer mode on gfx1201, which is now rejected as invalid input.

HW_ORACLE.md describes the check.

Results:

  • test_compare_results.py: 20 OK. With only the compare_results.py change reverted, 18 subtests fail.
  • test_hw_oracle.py: 84 OK, 5 skipped.
  • test_probe_catalog.py: 40 OK.
  • check_conventions.py --base origin/main: passed.

AI-assisted: yes

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

Re-reviewed exact head 2bc007a9e04641ca7fab5c1ae420241e6c5bc339. The follow-up ties both nullable modes to gfx12* targets in the report validator and covers invalid values in both directions. My original gfx1030 reproducer now exits 2 with ieee must be an integer from 0 to 1 on gfx1030.

On Windows with Python 3.15.2, test_hw_oracle.py passed 84 tests with 6 expected skips on this non-AMD machine, test_compare_results.py passed 20, test_probe_catalog.py passed 40, and tools/check_conventions.py --base origin/main passed. Hosted checks on this head are green. I did not run a native AMD kernel; the author's R9700 run covers that separately.

AI-assisted: yes.

@github-actions github-actions Bot added the docs label Nov 23, 2026

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

Reviewed — no blocking findings

The inspected implementation is internally consistent; I did not run the reported checks, so a formal approval is not justified.

What I ran

Read the prepared diff and all six changed files at head 2bc007a9e04641ca7fab5c1ae420241e6c5bc339 using repo_read.py. No commands or tests were run. The manifest lists six files under reviewed; all six were read. No files were excluded.

Results

Check Result Note
Changed code review passed Six changed files read
Tests and runtime checks not run Results in the description are author reported

Negative control

Not run; no tests were run during this review.

Findings

Blocking

None.

Non-blocking

None.

Sources

Not verified

The test suites, comgr assembly, and native GPU runs described by the author were not run or independently confirmed.

To get this to a good state

Nothing is required.

@oneandonlydean
oneandonlydean merged commit 86ec2a6 into boykopovar:main Nov 23, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants