cf_ref: validate mask widths, integer/export/branch modifiers, EXEC=0 operands, and duplicate PCs (CF-REF-OPERAND-VALIDATION) #1780

Closed
ShotTechOp wants to merge 1 commit from upstream-pr/1780 into main
ShotTechOp commented 2026-11-25 11:58:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ShotTechOp on 2026-11-25T11:58:35Z.


Summary

Claimed in #1608 as CF-REF-OPERAND-VALIDATION: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7161734635

Hardens tools/cf_ref.py (WaveMachine) so malformed or unsupported control-flow, mask, integer, export, and branch operands raise cpu_ref.Unsupported / cpu_ref.ProgramError instead of silently truncating, wrapping, or skipping validation when EXEC == 0:

  1. Exact mask operand width checks (_read_mask, _write_mask):
    • Accept an optional width (32 or 64, defaulting to self.wave so subclasses like tools/wave_diff.py stay compatible).
    • Reject SGPR counts that do not match the operation width (n != 2 on 64-bit mask ops/compares such as s0 or s[0:3]; n != 1 on 32-bit mask ops/compares such as s[0:1]), and reject 32-bit *_lo/*_hi special mask registers on 64-bit ops (s_mov_b64, s_<op>_b64, s_*_saveexec_b64, wave64 v_cmp_*).
    • Preserve wave32 exec_hi read-as-0 / ignored-write and vcc_hi scalar behaviour covered by tests/test_cf_ref_edge_fixes.py.
  2. Validate operands even when EXEC == 0:
    • Validate vector destinations (_check_vgpr_dst) and integer sources (_check_int_src) before the active-lane loop in v_add_nc_u32, v_sub_nc_u32, v_subrev_nc_u32, v_mul_lo_u32, v_mbcnt_lo_u32_b32, v_mbcnt_hi_u32_b32, wave32 VOP2 v_cndmask_b32, and v_cmp_* / v_cmpx_*.
  3. Reject abs/neg and multi-dword operands on integer, mask, and export ops:
    • Reject abs/neg modifiers on mask operands, scalar destinations, integer sources, and exp mrt0 operands, plus multi-dword VGPRs on exp mrt0 and integer vector ops.
  4. Branch simm16 range/modifier checks and duplicate PC guard:
    • Reject abs/neg modifiers and out-of-range offsets outside [-32768, 65535] in _branch.
    • Raise ProgramError on duplicate instruction PCs in WaveMachine.__init__.

Independent of #1457 (tools/cpu_ref.py); zero PR dependencies and zero file overlap.

Testing

Environment: Windows 11 x64, Python 3.12.10, CPU-only (no GPU or game files; rebased on 0d80bc5).

  • python -I tests/test_cf_ref.py -> 31/31 OK (negative control on 0d80bc5 tools/cf_ref.py: 42 failures, 1 error across the 5 new regression tests)
  • python -I tests/test_cf_ref_edge_fixes.py -> 5/5 OK
  • python -I tests/test_wave_diff.py -> 12/12 OK
  • python -m compileall -q tools/cf_ref.py tests/test_cf_ref.py -> exit 0
  • python -I scripts/check_no_game_data.py tools/cf_ref.py tests/test_cf_ref.py -> exit 0
  • git diff --check -> clean

AI-assisted: yes (Antigravity). Synthetic inputs only; no game data.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5490882198 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1780). Originally posted by [ShotTechOp](https://github.com/ShotTechOp) on 2026-11-25T11:58:35Z. --- ## Summary Claimed in #1608 as `CF-REF-OPERAND-VALIDATION`: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7161734635 Hardens `tools/cf_ref.py` (`WaveMachine`) so malformed or unsupported control-flow, mask, integer, export, and branch operands raise `cpu_ref.Unsupported` / `cpu_ref.ProgramError` instead of silently truncating, wrapping, or skipping validation when `EXEC == 0`: 1. **Exact mask operand width checks (`_read_mask`, `_write_mask`)**: - Accept an optional `width` (`32` or `64`, defaulting to `self.wave` so subclasses like `tools/wave_diff.py` stay compatible). - Reject SGPR counts that do not match the operation width (`n != 2` on 64-bit mask ops/compares such as `s0` or `s[0:3]`; `n != 1` on 32-bit mask ops/compares such as `s[0:1]`), and reject 32-bit `*_lo`/`*_hi` special mask registers on 64-bit ops (`s_mov_b64`, `s_<op>_b64`, `s_*_saveexec_b64`, wave64 `v_cmp_*`). - Preserve wave32 `exec_hi` read-as-0 / ignored-write and `vcc_hi` scalar behaviour covered by `tests/test_cf_ref_edge_fixes.py`. 2. **Validate operands even when `EXEC == 0`**: - Validate vector destinations (`_check_vgpr_dst`) and integer sources (`_check_int_src`) before the active-lane loop in `v_add_nc_u32`, `v_sub_nc_u32`, `v_subrev_nc_u32`, `v_mul_lo_u32`, `v_mbcnt_lo_u32_b32`, `v_mbcnt_hi_u32_b32`, wave32 VOP2 `v_cndmask_b32`, and `v_cmp_*` / `v_cmpx_*`. 3. **Reject `abs`/`neg` and multi-dword operands on integer, mask, and export ops**: - Reject `abs`/`neg` modifiers on mask operands, scalar destinations, integer sources, and `exp mrt0` operands, plus multi-dword VGPRs on `exp mrt0` and integer vector ops. 4. **Branch `simm16` range/modifier checks and duplicate PC guard**: - Reject `abs`/`neg` modifiers and out-of-range offsets outside `[-32768, 65535]` in `_branch`. - Raise `ProgramError` on duplicate instruction PCs in `WaveMachine.__init__`. Independent of `#1457` (`tools/cpu_ref.py`); zero PR dependencies and zero file overlap. ## Testing Environment: Windows 11 x64, Python 3.12.10, CPU-only (no GPU or game files; rebased on `0d80bc5`). - `python -I tests/test_cf_ref.py` -> 31/31 OK (negative control on `0d80bc5` `tools/cf_ref.py`: 42 failures, 1 error across the 5 new regression tests) - `python -I tests/test_cf_ref_edge_fixes.py` -> 5/5 OK - `python -I tests/test_wave_diff.py` -> 12/12 OK - `python -m compileall -q tools/cf_ref.py tests/test_cf_ref.py` -> exit 0 - `python -I scripts/check_no_game_data.py tools/cf_ref.py tests/test_cf_ref.py` -> exit 0 - `git diff --check` -> clean AI-assisted: yes (Antigravity). Synthetic inputs only; no game data.
lixonik commented 2026-11-25 12:13:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-25T12:13:42Z.

Review: COMMENTED


Independent native Windows A/B at 3df0d83e against 0d80bc5d. With the new cf_ref test file run against the base implementation I saw 42 failed assertions and one error. At this head all 31 cf_ref tests, five cf_ref edge tests and 12 wave_diff tests passed. The last suite checks an existing consumer of the reference machine.

AI-assisted. Synthetic instructions and CPU only.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6057394848 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1780#pullrequestreview-6057394848). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-25T12:13:42Z. **Review:** COMMENTED --- Independent native Windows A/B at `3df0d83e` against `0d80bc5d`. With the new cf_ref test file run against the base implementation I saw 42 failed assertions and one error. At this head all 31 cf_ref tests, five cf_ref edge tests and 12 wave_diff tests passed. The last suite checks an existing consumer of the reference machine. AI-assisted. Synthetic instructions and CPU only.
GeorgiyDemo commented 2026-11-25 12:20:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by GeorgiyDemo on 2026-11-25T12:20:07Z.


Tested 3df0d83ea on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against main 0d80bc5df (Python CPU reference; no GPU):

  • pytest 9.2.0 on tests/test_cf_ref.py: 31 passed, 106 subtests passed at this head.
  • The same file on main: 43 failed, 30 passed, 64 subtests — the mask-width, EXEC=0 operand, integer/export and branch-modifier validation is not there.
  • Not run: anything on hardware — cf_ref is the CPU reference model.

AI-assisted; synthetic fixtures only, no game data.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7162234100 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1780#issuecomment-7162234100). Originally posted by [GeorgiyDemo](https://github.com/GeorgiyDemo) on 2026-11-25T12:20:07Z. --- Tested `3df0d83ea` on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against `main` `0d80bc5df` (Python CPU reference; no GPU): - pytest 9.2.0 on `tests/test_cf_ref.py`: **31 passed, 106 subtests passed** at this head. - The same file on `main`: **43 failed**, 30 passed, 64 subtests — the mask-width, EXEC=0 operand, integer/export and branch-modifier validation is not there. - Not run: anything on hardware — `cf_ref` is the CPU reference model. AI-assisted; synthetic fixtures only, no game data.
zmasi commented 2026-11-28 11:53:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T11:53:20Z.


#1780 | head 3df0d83ea5 (0 git conflicts with main 24549bdb1, semantic base-class method collision) | python -I tests/test_cf_ref.py | red on main: FAILED (failures=42, errors=1) | standalone PR head: 31 tests OK, PR+main: FAILED (errors=11) | Windows 11, Python 3.12.10 | AI-assisted: yes

Heads-up before merging: although this branch merges cleanly with main (24549bdb1) with 0 git conflicts and passes 31/31 tests on its standalone head, commit 2c484d64a on main added Machine._check_vgpr_dst(self, dst) in tools/cpu_ref.py:365 (called by Machine._write_vgpr at tools/cpu_ref.py:373). In tools/cf_ref.py, WaveMachine._check_vgpr_dst(self, op, dst) now inadvertently overrides that base method with a 2-argument signature, causing TypeError: WaveMachine._check_vgpr_dst() missing 1 required positional argument: 'dst' across 11 tests when merged with main.

Verified locally that renaming the WaveMachine helper (for example _check_cf_vgpr_dst(self, op, dst), or matching (self, dst)) makes all 31 tests in tests/test_cf_ref.py pass (OK) on PR + main; the mask-width, EXEC == 0 operand, abs/neg modifier, simm16 branch range, and duplicate-PC checks themselves are clean.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238848867 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1780#issuecomment-7238848867). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T11:53:20Z. --- #1780 | head 3df0d83ea50966a136b3794e6037220e666869d7 (0 git conflicts with main 24549bdb1, semantic base-class method collision) | `python -I tests/test_cf_ref.py` | red on main: `FAILED (failures=42, errors=1)` | standalone PR head: `31 tests OK`, **PR+main: `FAILED (errors=11)`** | Windows 11, Python 3.12.10 | AI-assisted: yes Heads-up before merging: although this branch merges cleanly with `main` (`24549bdb1`) with `0` git conflicts and passes `31/31` tests on its standalone head, commit `2c484d64a` on `main` added `Machine._check_vgpr_dst(self, dst)` in `tools/cpu_ref.py:365` (called by `Machine._write_vgpr` at `tools/cpu_ref.py:373`). In `tools/cf_ref.py`, `WaveMachine._check_vgpr_dst(self, op, dst)` now inadvertently overrides that base method with a 2-argument signature, causing `TypeError: WaveMachine._check_vgpr_dst() missing 1 required positional argument: 'dst'` across 11 tests when merged with `main`. Verified locally that renaming the `WaveMachine` helper (for example `_check_cf_vgpr_dst(self, op, dst)`, or matching `(self, dst)`) makes all `31` tests in `tests/test_cf_ref.py` pass (`OK`) on `PR + main`; the mask-width, `EXEC == 0` operand, `abs`/`neg` modifier, `simm16` branch range, and duplicate-PC checks themselves are clean.
TheGeogeo commented 2026-11-28 23:38:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-28T23:38:25Z.


Tested 3df0d83ea merged (no commit) with main aa918e5d9: Python 3.12.4, Windows 11 10.0.26300, CPU only. check_no_game_data.py is clean.

Blocker: it breaks once merged with current main. On its own head, tests/test_cf_ref.py passes (31 tests). Merged with main, it gives 11 errors: TypeError: WaveMachine._check_vgpr_dst() missing 1 required positional argument: 'dst'.

Cause: since this branch, main's base class tools/cpu_ref.py (cpu_ref.Machine) defines _check_vgpr_dst(self, dst) and calls it with one argument (cpu_ref.py:373, :387). This PR's WaveMachine._check_vgpr_dst(self, op, dst) overrides it with another signature. Git merges cleanly, so nothing flags it. A rebase that renames the helper or reuses cpu_ref's should fix it. #1809 has the same clash in wave_diff.py.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7247565348 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1780#issuecomment-7247565348). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-28T23:38:25Z. --- Tested `3df0d83ea` merged (no commit) with `main` `aa918e5d9`: Python 3.12.4, Windows 11 10.0.26300, CPU only. `check_no_game_data.py` is clean. **Blocker: it breaks once merged with current `main`.** On its own head, `tests/test_cf_ref.py` passes (31 tests). Merged with `main`, it gives 11 errors: `TypeError: WaveMachine._check_vgpr_dst() missing 1 required positional argument: 'dst'`. Cause: since this branch, `main`'s base class `tools/cpu_ref.py` (`cpu_ref.Machine`) defines `_check_vgpr_dst(self, dst)` and calls it with one argument (`cpu_ref.py:373`, `:387`). This PR's `WaveMachine._check_vgpr_dst(self, op, dst)` overrides it with another signature. Git merges cleanly, so nothing flags it. A rebase that renames the helper or reuses `cpu_ref`'s should fix it. #1809 has the same clash in `wave_diff.py`. AI-assisted (Claude Code).
OreoFR commented 2026-11-29 02:56:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T02:56:16Z.


Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main c8bf0e7b6, PR head 3df0d83ea : red 42 failures + 1 error / green 11 errors

python3.12 -I tests/test_cf_ref.py (31 tests):

  • Merge: textually clean (git merge-tree).
  • Red (main + only this PR's test file): 42 failures + 1 error (subtests included) in 5 tests: test_branch_rejects_out_of_range_simm16_and_modifiers, test_duplicate_instruction_pc_raises_program_error, test_exec_zero_still_validates_vector_and_compare_operands, test_mask_and_vcmp_operand_width_mismatches_raise, test_rejects_abs_neg_on_cf_ref_integer_mask_and_export_operands.
  • Green (main + git merge --no-ff): 20 OK, 11 errors, all TypeError: WaveMachine._check_vgpr_dst() missing 1 required positional argument: 'dst'.
    • (READ IN CODE) Semantic conflict with main 2c484d64a: cpu_ref.Machine now has _check_vgpr_dst(self, dst), called from _write_vgpr; this PR defines _check_vgpr_dst(self, op, dst) in the subclass, which overrides the base method with another signature. On the PR head alone everything passes. Renaming the PR's method (e.g. _check_vgpr_dst_op) should fix it (ASSUMED).
  • (MEASURED n=3) the 11 green errors reproduce 3/3.
  • Neighbour tests regress on the merge (main → green): test_wave_diff 12 OK → 1 failure + 10 errors; test_cf_gpu_run 17 OK → 8 errors; test_cf_ref_edge_fixes 5 OK → 3 errors; semantic/test_loop_ballot_barrier 15 OK → 2 errors; test_cf_diff (pytest) 42 passed → 31 failed. semantic/test_saveexec_variants 9 OK both. (test_tool_startup fails on main too: psin_dialogue → ModuleNotFoundError: psin_data, unrelated.)
  • Diff: the validation logic (mask widths, abs/neg, simm16, duplicate PCs) is sensible; _check_int_src is called once before the lane loop and again per lane (redundant, harmless). No game data.

Verdict: FAILS (needs a rebase and the method rename).

AI-assisted: Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7249738747 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1780#issuecomment-7249738747). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T02:56:16Z. --- Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main c8bf0e7b6, PR head 3df0d83ea : red 42 failures + 1 error / green 11 errors `python3.12 -I tests/test_cf_ref.py` (31 tests): - Merge: textually clean (`git merge-tree`). - **Red** (main + only this PR's test file): 42 failures + 1 error (subtests included) in 5 tests: `test_branch_rejects_out_of_range_simm16_and_modifiers`, `test_duplicate_instruction_pc_raises_program_error`, `test_exec_zero_still_validates_vector_and_compare_operands`, `test_mask_and_vcmp_operand_width_mismatches_raise`, `test_rejects_abs_neg_on_cf_ref_integer_mask_and_export_operands`. - **Green** (main + `git merge --no-ff`): 20 OK, **11 errors**, all `TypeError: WaveMachine._check_vgpr_dst() missing 1 required positional argument: 'dst'`. - (READ IN CODE) Semantic conflict with main 2c484d64a: `cpu_ref.Machine` now has `_check_vgpr_dst(self, dst)`, called from `_write_vgpr`; this PR defines `_check_vgpr_dst(self, op, dst)` in the subclass, which overrides the base method with another signature. On the PR head alone everything passes. Renaming the PR's method (e.g. `_check_vgpr_dst_op`) should fix it (ASSUMED). - (MEASURED n=3) the 11 green errors reproduce 3/3. - Neighbour tests regress on the merge (main → green): `test_wave_diff` 12 OK → 1 failure + 10 errors; `test_cf_gpu_run` 17 OK → 8 errors; `test_cf_ref_edge_fixes` 5 OK → 3 errors; `semantic/test_loop_ballot_barrier` 15 OK → 2 errors; `test_cf_diff` (pytest) 42 passed → 31 failed. `semantic/test_saveexec_variants` 9 OK both. (`test_tool_startup` fails on main too: `psin_dialogue` → `ModuleNotFoundError: psin_data`, unrelated.) - Diff: the validation logic (mask widths, abs/neg, simm16, duplicate PCs) is sensible; `_check_int_src` is called once before the lane loop and again per lane (redundant, harmless). No game data. **Verdict: FAILS** (needs a rebase and the method rename). AI-assisted: Claude Code
OreoFR commented 2026-11-29 10:24:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T10:24:01Z.


@ShotTechOp proposed fix for the _check_vgpr_dst clash with main reported above. Since 2c484d64a, main's cpu_ref.Machine has _check_vgpr_dst(self, dst) and calls it with one argument from _write_vgpr and _validate_vector_operands, so this PR's WaveMachine._check_vgpr_dst(self, op, dst) overrides it with an incompatible signature. Renaming the PR's helper keeps its abs/neg and single-VGPR checks at its three call sites and leaves the base method to cpu_ref:

diff --git a/tools/cf_ref.py b/tools/cf_ref.py
index 2db9ff4f6..c87ded839 100644
--- a/tools/cf_ref.py
+++ b/tools/cf_ref.py
@@ -93,7 +93,7 @@ class WaveMachine(cpu_ref.Machine):
         if arg.get("abs") or arg.get("neg"):
             raise Unsupported(op, self.pc, "abs/neg modifiers are not modelled")
 
-    def _check_vgpr_dst(self, op, dst):
+    def _check_cf_vgpr_dst(self, op, dst):
         self._check_no_mods(op, dst)
         if dst.get("k") != "vgpr" or dst.get("n", 1) != 1:
             raise Unsupported(op, self.pc, "vector destination must be a single VGPR")
@@ -260,7 +260,7 @@ class WaveMachine(cpu_ref.Machine):
             return self._branch(base, a)
         if base in ("v_add_nc_u32", "v_sub_nc_u32", "v_subrev_nc_u32", "v_mul_lo_u32"):
             self._expect(ins, 3)
-            self._check_vgpr_dst(op, a[0])
+            self._check_cf_vgpr_dst(op, a[0])
             self._check_int_src(op, a[1], 0)
             self._check_int_src(op, a[2], 0)
             for lane in self._active_lanes():
@@ -271,7 +271,7 @@ class WaveMachine(cpu_ref.Machine):
             return None
         if base in ("v_mbcnt_lo_u32_b32", "v_mbcnt_hi_u32_b32"):
             self._expect(ins, 3)
-            self._check_vgpr_dst(op, a[0])
+            self._check_cf_vgpr_dst(op, a[0])
             self._check_int_src(op, a[1], 0)
             self._check_int_src(op, a[2], 0)
             for lane in self._active_lanes():
@@ -360,7 +360,7 @@ class WaveMachine(cpu_ref.Machine):
             return None
         if base == "v_cndmask_b32" and self.wave == 32 and len(a) == 3:
             # VOP2 form: the implicit condition is VCC_LO in wave32 (cpu_ref models a wave64 VCC).
-            self._check_vgpr_dst(op, a[0])
+            self._check_cf_vgpr_dst(op, a[0])
             self._check_int_src(op, a[1], 0)
             self._check_int_src(op, a[2], 0)
             for lane in self._active_lanes():

Checked on Windows 11, Python 3.12, CPU only, on main 54b2a81e9 + this PR (3df0d83ea, merged locally, not pushed):

  • without the fix: tests/test_cf_ref.py FAILED (errors=11), tests/test_wave_diff.py FAILED (failures=1, errors=10)
  • with the fix: test_cf_ref.py 31 OK, test_wave_diff.py 12 OK, test_cf_gpu_run.py 17 OK, test_cf_ref_edge_fixes.py 5 OK, test_cpu_ref.py 39 OK, test_wave_trace.py 10 OK, test_cf_diff.py (pytest) 42 passed, semantic/test_loop_ballot_barrier.py 15 OK, semantic/test_saveexec_variants.py 9 OK
  • full run_semantic_tests.py tests/semantic: 529 files, 6525 tests, the same 2 failing files as plain main (test_interp_computed_ij_fallback, test_valu_cvt_f16_int16_mods)
  • main + this PR + #1809 with both renames: test_cf_ref.py, test_wave_diff.py, test_cf_gpu_run.py, test_cf_ref_edge_fixes.py, test_cpu_ref.py and test_wave_trace.py pass too.

— OreoFR's agent (AI-assisted)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7254408779 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1780#issuecomment-7254408779). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T10:24:01Z. --- @ShotTechOp proposed fix for the `_check_vgpr_dst` clash with `main` reported above. Since `2c484d64a`, `main`'s `cpu_ref.Machine` has `_check_vgpr_dst(self, dst)` and calls it with one argument from `_write_vgpr` and `_validate_vector_operands`, so this PR's `WaveMachine._check_vgpr_dst(self, op, dst)` overrides it with an incompatible signature. Renaming the PR's helper keeps its abs/neg and single-VGPR checks at its three call sites and leaves the base method to `cpu_ref`: ```diff diff --git a/tools/cf_ref.py b/tools/cf_ref.py index 2db9ff4f6..c87ded839 100644 --- a/tools/cf_ref.py +++ b/tools/cf_ref.py @@ -93,7 +93,7 @@ class WaveMachine(cpu_ref.Machine): if arg.get("abs") or arg.get("neg"): raise Unsupported(op, self.pc, "abs/neg modifiers are not modelled") - def _check_vgpr_dst(self, op, dst): + def _check_cf_vgpr_dst(self, op, dst): self._check_no_mods(op, dst) if dst.get("k") != "vgpr" or dst.get("n", 1) != 1: raise Unsupported(op, self.pc, "vector destination must be a single VGPR") @@ -260,7 +260,7 @@ class WaveMachine(cpu_ref.Machine): return self._branch(base, a) if base in ("v_add_nc_u32", "v_sub_nc_u32", "v_subrev_nc_u32", "v_mul_lo_u32"): self._expect(ins, 3) - self._check_vgpr_dst(op, a[0]) + self._check_cf_vgpr_dst(op, a[0]) self._check_int_src(op, a[1], 0) self._check_int_src(op, a[2], 0) for lane in self._active_lanes(): @@ -271,7 +271,7 @@ class WaveMachine(cpu_ref.Machine): return None if base in ("v_mbcnt_lo_u32_b32", "v_mbcnt_hi_u32_b32"): self._expect(ins, 3) - self._check_vgpr_dst(op, a[0]) + self._check_cf_vgpr_dst(op, a[0]) self._check_int_src(op, a[1], 0) self._check_int_src(op, a[2], 0) for lane in self._active_lanes(): @@ -360,7 +360,7 @@ class WaveMachine(cpu_ref.Machine): return None if base == "v_cndmask_b32" and self.wave == 32 and len(a) == 3: # VOP2 form: the implicit condition is VCC_LO in wave32 (cpu_ref models a wave64 VCC). - self._check_vgpr_dst(op, a[0]) + self._check_cf_vgpr_dst(op, a[0]) self._check_int_src(op, a[1], 0) self._check_int_src(op, a[2], 0) for lane in self._active_lanes(): ``` Checked on Windows 11, Python 3.12, CPU only, on `main` `54b2a81e9` + this PR (`3df0d83ea`, merged locally, not pushed): - without the fix: `tests/test_cf_ref.py` FAILED (errors=11), `tests/test_wave_diff.py` FAILED (failures=1, errors=10) - with the fix: `test_cf_ref.py` 31 OK, `test_wave_diff.py` 12 OK, `test_cf_gpu_run.py` 17 OK, `test_cf_ref_edge_fixes.py` 5 OK, `test_cpu_ref.py` 39 OK, `test_wave_trace.py` 10 OK, `test_cf_diff.py` (pytest) 42 passed, `semantic/test_loop_ballot_barrier.py` 15 OK, `semantic/test_saveexec_variants.py` 9 OK - full `run_semantic_tests.py tests/semantic`: 529 files, 6525 tests, the same 2 failing files as plain `main` (`test_interp_computed_ij_fallback`, `test_valu_cvt_f16_int16_mods`) - `main` + this PR + #1809 with both renames: `test_cf_ref.py`, `test_wave_diff.py`, `test_cf_gpu_run.py`, `test_cf_ref_edge_fixes.py`, `test_cpu_ref.py` and `test_wave_trace.py` pass too. — OreoFR's agent (AI-assisted)
TheGeogeo commented 2026-11-29 18:48:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T18:48:31Z.


Re-checked 3df0d83ea (head unchanged) merged (no commit) with main 7c330c76d: Python 3.12.4, Windows 11 10.0.26300, CPU only.

  • The blocker from my earlier comment still stands. Merged with current main, tests/test_cf_ref.py gives 11 errors out of 31 tests: TypeError: WaveMachine._check_vgpr_dst() missing 1 required positional argument: 'dst'.
  • This needs a rebase onto current main and an update of the _check_vgpr_dst callers.
  • git merge-tree against #2566's head 7b5cb2941: no conflict.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7260774920 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1780#issuecomment-7260774920). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T18:48:31Z. --- Re-checked 3df0d83ea (head unchanged) merged (no commit) with main 7c330c76d: Python 3.12.4, Windows 11 10.0.26300, CPU only. - **The blocker from my earlier comment still stands.** Merged with current main, `tests/test_cf_ref.py` gives 11 errors out of 31 tests: `TypeError: WaveMachine._check_vgpr_dst() missing 1 required positional argument: 'dst'`. - This needs a rebase onto current main and an update of the `_check_vgpr_dst` callers. - `git merge-tree` against #2566's head `7b5cb2941`: no conflict. AI-assisted (Claude Code).
aslan2142 commented 2026-12-01 11:42:52 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:42:52Z.

Review: CHANGES_REQUESTED


Reviewed the diff against main: the extra operand/modifier validation in tools/cf_ref.py is useful, but tools/cf_ref.py:114 defines _check_vgpr_dst(self, op, dst) (2 arguments), which clashes with cpu_ref.Machine._check_vgpr_dst(self, dst) (1 argument) now on main, and CI is failing. Please resolve the method-name/signature clash against current main and re-run CI.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130536556 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1780#pullrequestreview-6130536556). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:42:52Z. **Review:** CHANGES_REQUESTED --- Reviewed the diff against `main`: the extra operand/modifier validation in `tools/cf_ref.py` is useful, but `tools/cf_ref.py:114` defines `_check_vgpr_dst(self, op, dst)` (2 arguments), which clashes with `cpu_ref.Machine._check_vgpr_dst(self, dst)` (1 argument) now on `main`, and CI is failing. Please resolve the method-name/signature clash against current `main` and re-run CI. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 16:37:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:37:53Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7317926842 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1780#issuecomment-7317926842). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:37:53Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1780
No description provided.