hw_oracle/asm: fix GFX12 scalar load, per-kernel wave metadata, and validation #2326

Open
github-bot wants to merge 1 commit from github-bot/gh-2326 into main AGit
Owner

@⁠kirigayakazima on GitHub · 2026-11-26 13:48 UTC · original
kirigayakazima:fix/hw-oracle-asm-gfx12-wave → main · +77 −5 · 2 files · 1 commits · open

Claimed in the coordination issue as: HW-ORACLE-ASM-GFX12-RAW-LOAD-AND-KERNEL-WAVE-METADATA (#1608)

What and why

  • Fix raw_kernel_text() in tools/hw_oracle/asm.py to emit s_load_b64 on GFX12 (as on GFX11) rather than GFX10's s_load_dwordx2, and reuse is_gfx1170_or_later(arch).
  • Update metadata() and module_text() in tools/hw_oracle/asm.py so mixed-wave batches emit per-kernel .wavefront_size matching each kernel's .amdhsa_wavefront_size32 instead of repeating the batch default wave size.
  • Validate wave (32 or 64), threads (>= 1), words (>= 1), and reject bool values for integer Kernel arguments in Kernel.__init__().
  • Add standard-library unit tests in tests/test_hw_oracle_asm_gfx12.py.

Tested

  • python -I tests/test_hw_oracle_asm_gfx12.py -v: 3 passed, 0 failed (detached upstream/main baseline with only the new test file fails with 9 subtest/test failures).
  • python -I tests/test_hw_oracle.py -v: 59 tests (OK, 3 skipped without AMD clang / libdrm gcc on host).
  • python -I tests/test_hw_oracle_asm_strip.py -v: 1 passed, 0 failed.
  • python -I tests/test_ci_registration.py: 16 passed.
  • python -I tests/test_text_write_line_endings.py: 3 passed.
  • python -I scripts/check_no_game_data.py, python -I -m compileall -q tools/hw_oracle/asm.py tests/test_hw_oracle_asm_gfx12.py, and git diff --cached --check: passed.

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • 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.
**@⁠kirigayakazima** on GitHub · 2026-11-26 13:48 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2326) `kirigayakazima:fix/hw-oracle-asm-gfx12-wave` → `main` · +77 −5 · 2 files · 1 commits · open Claimed in the coordination issue as: HW-ORACLE-ASM-GFX12-RAW-LOAD-AND-KERNEL-WAVE-METADATA (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ### What and why - Fix `raw_kernel_text()` in `tools/hw_oracle/asm.py` to emit `s_load_b64` on GFX12 (as on GFX11) rather than GFX10's `s_load_dwordx2`, and reuse `is_gfx1170_or_later(arch)`. - Update `metadata()` and `module_text()` in `tools/hw_oracle/asm.py` so mixed-wave batches emit per-kernel `.wavefront_size` matching each kernel's `.amdhsa_wavefront_size32` instead of repeating the batch default wave size. - Validate `wave` (`32` or `64`), `threads` (`>= 1`), `words` (`>= 1`), and reject `bool` values for integer `Kernel` arguments in `Kernel.__init__()`. - Add standard-library unit tests in `tests/test_hw_oracle_asm_gfx12.py`. ### Tested - `python -I tests/test_hw_oracle_asm_gfx12.py -v`: 3 passed, 0 failed (detached `upstream/main` baseline with only the new test file fails with 9 subtest/test failures). - `python -I tests/test_hw_oracle.py -v`: 59 tests (`OK`, 3 skipped without AMD clang / libdrm gcc on host). - `python -I tests/test_hw_oracle_asm_strip.py -v`: 1 passed, 0 failed. - `python -I tests/test_ci_registration.py`: 16 passed. - `python -I tests/test_text_write_line_endings.py`: 3 passed. - `python -I scripts/check_no_game_data.py`, `python -I -m compileall -q tools/hw_oracle/asm.py tests/test_hw_oracle_asm_gfx12.py`, and `git diff --cached --check`: passed. GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 13:50:21 +00:00
Author
Owner

@⁠EdenBendheim on GitHub · 2026-11-26 21:43 UTC · original

Locally verified 556f625a9 against main at fac8b4bb9 on macOS 27.3 arm64 (Python 3.14.3, LLVM 21.1.8). Claim confirmed in #1608; patch applies cleanly; no conflicting overlap with #1332.

  • tests/test_hw_oracle_asm_gfx12.py: 3 tests / 9 failures (incl. subtests) on plain main; 3/3 passed with the patch.
  • tests/test_hw_oracle*.py: 68 passed, 4 skipped via unittest; 70 passed, 11 skipped, 18 subtests via pytest.
  • LLVM 21.1.8 assembled the generated mixed wave64/wave32 module for both gfx1200 and gfx1201.
  • check_no_game_data.py, compileall, test_text_write_line_endings.py (3/3), and test_ci_registration.py (16/16) all passed.

Non-blocking test note: tests/test_hw_oracle_asm_gfx12.py:29 checks that both metadata values appear in the output, so swapping them between k0 and k1 would still pass (the implementation itself emits them in kernel order).

Synthetic inputs only; no game data. GPUs tested: none (CPU/assembler verification only). AI-assisted verification.

**@⁠EdenBendheim** on GitHub · 2026-11-26 21:43 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2326#issuecomment-7204001949) Locally verified `556f625a9` against `main` at `fac8b4bb9` on macOS 27.3 arm64 (Python 3.14.3, LLVM 21.1.8). Claim confirmed in #1608; patch applies cleanly; no conflicting overlap with #1332. - `tests/test_hw_oracle_asm_gfx12.py`: 3 tests / 9 failures (incl. subtests) on plain `main`; 3/3 passed with the patch. - `tests/test_hw_oracle*.py`: 68 passed, 4 skipped via `unittest`; 70 passed, 11 skipped, 18 subtests via `pytest`. - LLVM 21.1.8 assembled the generated mixed wave64/wave32 module for both `gfx1200` and `gfx1201`. - `check_no_game_data.py`, `compileall`, `test_text_write_line_endings.py` (3/3), and `test_ci_registration.py` (16/16) all passed. Non-blocking test note: `tests/test_hw_oracle_asm_gfx12.py:29` checks that both metadata values appear in the output, so swapping them between `k0` and `k1` would still pass (the implementation itself emits them in kernel order). Synthetic inputs only; no game data. GPUs tested: none (CPU/assembler verification only). AI-assisted verification.
Author
Owner

@⁠tiguan26 on GitHub · 2026-11-27 04:41 UTC · original · approved these changes

Approving 556f625a9.

The GFX12 fix is real: raw_kernel_text picked s_load_dwordx2 for every family but gfx11, so gfx12 kernels got the GFX10 mnemonic; now only gfx10 uses it. Per-kernel wavefront sizes go into the metadata instead of one module-wide value, and Kernel validates its fields.

Merged onto main d1dff7949 in one batch with 15 other tool PRs of this series (no conflicts), on Linux with Python 3.13. tests/test_hw_oracle_asm_gfx12.py: 3 passed, 12 subtests (new). AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠tiguan26** on GitHub · 2026-11-27 04:41 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2326#pullrequestreview-6083571099) · **approved these changes** Approving 556f625a9. The GFX12 fix is real: `raw_kernel_text` picked `s_load_dwordx2` for every family but gfx11, so gfx12 kernels got the GFX10 mnemonic; now only gfx10 uses it. Per-kernel wavefront sizes go into the metadata instead of one module-wide value, and `Kernel` validates its fields. Merged onto `main` `d1dff7949` in one batch with 15 other tool PRs of this series (no conflicts), on Linux with Python 3.13. `tests/test_hw_oracle_asm_gfx12.py`: 3 passed, 12 subtests (new). AI-assisted (Claude Code, Claude Opus 5.5).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2326/head:github-bot/gh-2326'
git switch 'github-bot/gh-2326'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2326'
git switch 'github-bot/gh-2326'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2326'
git switch 'github-bot/gh-2326'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2326'
git switch 'main'
git merge --squash 'github-bot/gh-2326'
git switch 'main'
git merge --ff-only 'github-bot/gh-2326'
git switch 'main'
git merge 'github-bot/gh-2326'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.