wave_diff: one check, the two shapes it is called with #2901

Closed
github-bot wants to merge 1 commit from gh-pr/2901/head into gh-pr/2901/base
Owner

@⁠fiestorra on GitHub · 2026-12-01 16:49 UTC · original
fiestorra:fix-vgpr-dst-check → main · +8 −1 · 1 files · 1 commits · closed without merging

main is red on the CI workflow and this is why, for the two wave files: cpu_ref.Machine._check_vgpr_dst takes the destination alone, wave_diff.WaveRef overrode it as (op, dst) so an error message can name the instruction, and both inherited callers still pass it the destination alone.

So every path through them raised, and the tests that walk wave programs fell over one after another:

TypeError: WaveRef._check_vgpr_dst() missing 1 required positional argument: 'dst'
  tools\cpu_ref.py:373   in _write_vgpr
  (and the same from _validate_vector_operands, line 387)

The inherited callers are _write_vgpr(dst, lane, value) and _validate_vector_operands(dst, srcs, ...), neither of which carries the op name — their own callers in cpu_ref and cf_ref do not pass one. The override therefore has to take the shape both are called with.

What it does now: with two arguments it is this file's own call (the op named); with one it is the inherited one, which gets write for the op that its caller does not have. The check itself is unchanged — the same _reject_mods and the same single-VGPR rule — so a valid write takes exactly the path it took before.

Measured on main 7f8bb9037, python3 -m pytest over the five files ci.yml runs:

before   43 failed, 51 passed, 34 skipped
after     5 failed, 66 passed, 34 skipped

test_wave_diff.py              all pass
test_wave_trace.py             all pass
test_cpu_ref.py                39 passed, 33 subtests

The five that are left are not this: four in test_piecewise_parse.py (LoaderTest::test_support_installs_the_finder_only_where_the_tokenizer_is_slow) and one in test_x64_recomp.py (DecodeTests::test_opcode_90_nop_pause_and_rex_xchg). They are separate regressions on the same red main, named so that they are not taken for this fix working.

AI-assisted: yes — DeepSeek v4.1 (flash), which found main red and got it most of the way back.

Written with an AI assistant.

**@⁠fiestorra** on GitHub · 2026-12-01 16:49 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2901) `fiestorra:fix-vgpr-dst-check` → `main` · +8 −1 · 1 files · 1 commits · closed without merging **`main` is red on the `CI` workflow and this is why, for the two wave files: `cpu_ref.Machine._check_vgpr_dst` takes the destination alone, `wave_diff.WaveRef` overrode it as `(op, dst)` so an error message can name the instruction, and both inherited callers still pass it the destination alone.** **So every path through them raised, and the tests that walk wave programs fell over one after another:** ``` TypeError: WaveRef._check_vgpr_dst() missing 1 required positional argument: 'dst' tools\cpu_ref.py:373 in _write_vgpr (and the same from _validate_vector_operands, line 387) ``` **The inherited callers are `_write_vgpr(dst, lane, value)` and `_validate_vector_operands(dst, srcs, ...)`, neither of which carries the op name** — **their own callers in `cpu_ref` and `cf_ref` do not pass one.** **The override therefore has to take the shape both are called with.** **What it does now**: **with two arguments it is this file's own call (the op named); with one it is the inherited one, which gets `write` for the op that its caller does not have.** **The check itself is unchanged — the same `_reject_mods` and the same single-VGPR rule — so a valid write takes exactly the path it took before.** **Measured on `main` `7f8bb9037`, `python3 -m pytest` over the five files `ci.yml` runs:** ``` before 43 failed, 51 passed, 34 skipped after 5 failed, 66 passed, 34 skipped test_wave_diff.py all pass test_wave_trace.py all pass test_cpu_ref.py 39 passed, 33 subtests ``` **The five that are left are not this**: **four in `test_piecewise_parse.py` (`LoaderTest::test_support_installs_the_finder_only_where_the_tokenizer_is_slow`) and one in `test_x64_recomp.py` (`DecodeTests::test_opcode_90_nop_pause_and_rex_xchg`).** **They are separate regressions on the same red main, named so that they are not taken for this fix working.** **AI-assisted:** yes — DeepSeek v4.1 (flash), which found main red and got it most of the way back. Written with an AI assistant.
cpu_ref.Machine._check_vgpr_dst takes the destination alone; wave_diff.WaveRef
overrode it as (op, dst) so an error message can name the instruction. Both
inherited callers - _write_vgpr and _validate_vector_operands - still call it
with the destination alone, so every path through them raised:

  TypeError: WaveRef._check_vgpr_dst() missing 1 required positional argument: 'dst'
  tools\cpu_ref.py:373

which takes test_wave_diff.py and test_wave_trace.py down with it: 43 failures
across the five files ci.yml runs, on main as it stands (7f8bb9037).

The override now takes both: with two arguments it is the file's own call, and
with one it is the inherited one, which passes "write" for the op that its own
callers do not carry. The check itself is unchanged - the same _reject_mods and
the same single-VGPR rule - so a valid write takes the same path as before.

Measured on main 7f8bb9037:
  the five files ci.yml runs   43 failed -> 5
  tests/test_wave_diff.py      all pass
  tests/test_wave_trace.py     all pass
  tests/test_cpu_ref.py        39 passed, 33 subtests

The five that are left are other regressions, not this one: four in
test_piecewise_parse.py (a finder installed where the tokenizer is not slow)
and one in test_x64_recomp.py (opcode 90). Named here so they are not taken for
this fix working.

Written with an AI assistant.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 16:56:01 +00:00
github-bot closed this pull request 2026-12-01 16:56:01 +00:00
Author
Owner

@⁠fiestorra on GitHub · 2026-12-01 16:52 UTC · original

Superseded by 85ec1d33b on main, which fixed the same thing a better way: it renamed the override to _check_wave_vgpr_dst, so it no longer shadows cpu_ref.Machine._check_vgpr_dst and the two inherited callers keep the one-argument method they were written for. That is cleaner than the both-shapes signature in this branch, and it does not leave "write" standing in for an op that the caller does not have.

Measured on main 85ec1d33b, python3 -m pytest over the five files ci.yml runs:

43 failed, 51 passed, 34 skipped     (7f8bb9037)
 1 failed, 67 passed, 34 skipped     (85ec1d33b)

So this branch is redundant and I am closing it rather than asking anyone to read it.

The one that is left is not the same bug: tests/test_piecewise_parse.py::LoaderTest::test_support_installs_the_finder_only_where_the_tokenizer_is_slow. It is the only thing keeping that workflow red.

Written with an AI assistant.

**@⁠fiestorra** on GitHub · 2026-12-01 16:52 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2901#issuecomment-7318383012) Superseded by `85ec1d33b` on `main`, which fixed the same thing a better way: it renamed the override to `_check_wave_vgpr_dst`, so it no longer shadows `cpu_ref.Machine._check_vgpr_dst` and the two inherited callers keep the one-argument method they were written for. That is cleaner than the both-shapes signature in this branch, and it does not leave `"write"` standing in for an op that the caller does not have. Measured on `main` `85ec1d33b`, `python3 -m pytest` over the five files `ci.yml` runs: ``` 43 failed, 51 passed, 34 skipped (7f8bb9037) 1 failed, 67 passed, 34 skipped (85ec1d33b) ``` So this branch is redundant and I am closing it rather than asking anyone to read it. The one that is left is not the same bug: `tests/test_piecewise_parse.py::LoaderTest::test_support_installs_the_finder_only_where_the_tokenizer_is_slow`. It is the only thing keeping that workflow red. Written with an AI assistant.
Author
Owner

@⁠KelboLive on GitHub · 2026-12-01 16:58 UTC · original · reviewed

The diagnosis is right: cpu_ref.Machine._check_vgpr_dst has taken one argument since 2c484d64a, while 30e5b8b93 added a two-argument override in wave_diff.py, so every inherited _write_vgpr/_validate_vector_operands call raised. The shim is load-bearing and works — 40 failed → all green in the three wave files here, and the multi-dword guard is still caught (removing it fails three tests).

But main already fixed this, one minute before this PR was opened. #2895 (9b7674d64, merged in f1573499f at 16:48 UTC) renamed the wave-only hook to _check_wave_vgpr_dst and updated its three call sites, which avoids the signature juggling entirely. This branch is based on 7f8bb9037 (one merge before that) and now conflicts in tools/wave_diff.py — merge-tree exits 1, and a rebase would leave a duplicate override.

Recommend closing this one, or rebasing onto 85ec1d33b and dropping the now-duplicate override in favour of #2895's rename.

**@⁠KelboLive** on GitHub · 2026-12-01 16:58 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2901#pullrequestreview-6135986238) · **reviewed** The diagnosis is right: `cpu_ref.Machine._check_vgpr_dst` has taken one argument since `2c484d64a`, while `30e5b8b93` added a two-argument override in `wave_diff.py`, so every inherited `_write_vgpr`/`_validate_vector_operands` call raised. The shim is load-bearing and works — 40 failed → all green in the three wave files here, and the multi-dword guard is still caught (removing it fails three tests). **But `main` already fixed this, one minute before this PR was opened.** #2895 (`9b7674d64`, merged in `f1573499f` at 16:48 UTC) renamed the wave-only hook to `_check_wave_vgpr_dst` and updated its three call sites, which avoids the signature juggling entirely. This branch is based on `7f8bb9037` (one merge before that) and now **conflicts in `tools/wave_diff.py`** — `merge-tree` exits 1, and a rebase would leave a duplicate override. Recommend closing this one, or rebasing onto `85ec1d33b` and dropping the now-duplicate override in favour of #2895's rename.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/ubiquitarianism--leonida!2901
No description provided.