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

Merged
leonida/mandy
kirigayakazima merged 1 commit from fix/hw-oracle-asm-gfx12-wave into main 2026-11-28 10:58:40 +00:00

Pull request successfully merged and closed

kirigayakazima commented 2026-11-26 13:48:22 +00:00

Claimed in the coordination issue as: HW-ORACLE-ASM-GFX12-RAW-LOAD-AND-KERNEL-WAVE-METADATA (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7193821284)

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.
Claimed in the coordination issue as: HW-ORACLE-ASM-GFX12-RAW-LOAD-AND-KERNEL-WAVE-METADATA (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7193821284) ### 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.
EdenBendheim commented 2026-11-26 21:43:39 +00:00

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.

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.
tiguan26 approved these changes 2026-11-27 04:41:38 +00:00
tiguan26 left a comment

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).

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).
zmasi commented 2026-11-28 10:03:44 +00:00

#2326 | head 556f625a9422c36015cfde385df97ea33bbde623 (merged cleanly with main 33db04a70) | python -I tests/test_hw_oracle_asm_gfx12.py | red on main: FAILED (failures=9) (s_load_dwordx2 emitted on gfx1200/gfx1201 instead of s_load_b64, per-kernel .wavefront_size: 64 missing, and boolean/zero Kernel counts accepted) | green on PR+main: 3 tests OK (-k test_raw_kernel_uses_s_load_b64_on_gfx11_and_gfx12: 1 test OK) | Windows 11, Python 3.12.10 | AI-assisted: yes

Audited Kernel.__init__, raw_kernel_text, metadata, and module_text in tools/hw_oracle/asm.py, and verified both PR + main (33db04a70) and a combined main + #2328 + #2326 merge (0 conflicts; 3 OK + 3 OK). Also passed tests/test_ci_registration.py (18 OK), tests/test_text_write_line_endings.py (3 OK), tests/test_runner_calls_all_tests.py (3 OK), and scripts/check_no_game_data.py.

#2326 | head 556f625a9422c36015cfde385df97ea33bbde623 (merged cleanly with main 33db04a70) | `python -I tests/test_hw_oracle_asm_gfx12.py` | red on main: `FAILED (failures=9)` (`s_load_dwordx2` emitted on `gfx1200`/`gfx1201` instead of `s_load_b64`, per-kernel `.wavefront_size: 64` missing, and boolean/zero `Kernel` counts accepted) | green on PR+main: `3 tests OK` (`-k test_raw_kernel_uses_s_load_b64_on_gfx11_and_gfx12`: `1 test OK`) | Windows 11, Python 3.12.10 | AI-assisted: yes Audited `Kernel.__init__`, `raw_kernel_text`, `metadata`, and `module_text` in `tools/hw_oracle/asm.py`, and verified both `PR + main` (`33db04a70`) and a combined `main + #2328 + #2326` merge (`0` conflicts; `3 OK` + `3 OK`). Also passed `tests/test_ci_registration.py` (`18 OK`), `tests/test_text_write_line_endings.py` (`3 OK`), `tests/test_runner_calls_all_tests.py` (`3 OK`), and `scripts/check_no_game_data.py`.
DadaCap commented 2026-11-28 10:58:42 +00:00

Merged, thank you @kirigayakazima! This PR (hw_oracle/asm: fix GFX12 scalar load, per-kernel wave metadata, and validation) was checked by zmasi or sodove and then by our own local run of its tests with main merged in, and it passed cleanly, so it went in with its reviewed batch.

AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.

Merged, thank you @kirigayakazima! This PR (hw_oracle/asm: fix GFX12 scalar load, per-kernel wave metadata, and validation) was checked by zmasi or sodove and then by our own local run of its tests with main merged in, and it passed cleanly, so it went in with its reviewed batch. AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.
Sign in to join this conversation.
No description provided.