fix: the Python model refuses v_cndmask_b32's unreadable mask whatever EXEC holds #525

Merged
Luke-Ervin merged 1 commit from upstream-pr/525 into main 2026-11-27 19:38:44 +00:00
Luke-Ervin commented 2026-11-27 16:54:18 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by Luke-Ervin on 2026-11-27T16:54:18Z.


Change

The Python model (emu/rdna2_exec_vop3.py) now refuses the VOP3 form of v_cndmask_b32 with an unreadable lane mask even when no lane is active, as the Rust port already does.

S2 of v_cndmask_b32 (VOP3) is the lane mask, read as a scalar operand: an SGPR, an SGPR pair in wave64, or VCC. The model read it inside the loop over active lanes:

for lane in wave.active():
    ...
    condition = wave.read_mask(fields.sources[2], literal) >> lane & 1

So with EXEC = 0 the mask was never read. A mask the model refuses (a VGPR, or a reserved code such as 209) went through, and the instruction did nothing. With any lane active, the same instruction raised Untranslated. The Rust port (vop3_forms.rs) reads the mask once, before the lanes, and refuses it in both cases. The two models therefore disagreed whenever an earlier instruction had switched every lane off, a v_cmpx for example:

v_cndmask_b32 v3, v1, v2, <mask> (VOP3) EXEC Python before Python now Rust
mask v4 or code 209 all lanes error untranslated error untranslated error untranslated
mask v4 or code 209 0 runs, writes nothing error untranslated error untranslated
mask VCC 0 or all lanes runs runs, same result runs

Why the Python side changes:

  • Whether an operand can be read depends on the instruction, not on which lanes are active.
  • Rule 3 of AGENTS.md asks for an untranslated instruction to be refused.
  • The model's other VOP3 checks in the same function already run before the lanes: 16-bit results with op_sel or clamp, clamp on integer results, and the literal forms without a literal.

What changed: the mask is read once into select before the loop, and each lane takes its bit from it.

  • For every readable mask the result is the same as before, bit for bit: the mask is the same value on every lane.
  • Only a refused operand with EXEC = 0 changes, from running to Untranslated.
  • The literal case is unchanged.

docs/rust-full-status.md and docs/fr/rust-full-status.md record the finding. No README row or test-count change (1969 collected with this change, still 1900+).

Linked issue: none.

Verification

Linux (Ubuntu, Python 3.13, Rust 1.98.1), on top of main at a445308, with anyxboxx-rdna2-ref built by cargo build --release -p anyxboxx-rdna2-ref (no Rust change in this PR):

python -m pytest → 1504 passed, 465 skipped
python -m pytest tests/test_rdna2_ref_parity.py tests/test_rdna2_exec_vop3_more.py → 63 passed, 1 skipped (dxc absent)
python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools → All checks passed!

Without the change in rdna2_exec_vop3.py, the new tests fail: 3 failed, the two EXEC = 0 cases of the Python test and the parity test.

Not run here: the 465 skipped tests, which need Windows, the C++ runtime, dxc or a GPU. No Windows machine was available. No game was run.

Oracle and test data

  • Oracle: the Rust port (crates/anyxboxx-rdna2-ref, vop3_forms.rs), through tests/test_rdna2_ref_parity.py, and the model's own rule for operands it cannot read (Untranslated).
  • How it was found: the parity generator of tests/test_rdna2_ref_parity.py, run on 120,000 more seeds on main (with #402, #403, #437, #484, #501 and #502).
    • Apart from the register groups past v255 (the open question on #437), the models disagreed on only four programs. Each switched every lane off, then ran v_cndmask_b32 with a VGPR as its mask.
    • With this change all four agree: both refuse.
    • A sweep of every VOP1, VOP2, VOP3, VOP3P and VOPC opcode with EXEC = 0 found no other such case, apart from the half-precision instructions still being ported in #503 and #505.
  • Test data: built in the tests (no external data).
  • Failure cases:
    • test_cndmask_refuses_an_unreadable_mask_whatever_exec_holds (tests/test_rdna2_exec_vop3_more.py) runs a VGPR and a reserved code, each with all lanes active and with EXEC = 0.
    • test_cndmask_mask_refusals_do_not_depend_on_exec_in_both_models (tests/test_rdna2_ref_parity.py) covers both models in wave32 and wave64: the refused masks with and without lanes, and VCC as a readable mask with and without lanes.
  • Control: test_cndmask_with_a_readable_mask_and_no_lane_writes_nothing checks that a readable mask with EXEC = 0 still runs and leaves the destination unchanged.

Checklist

  • The PR covers a single reviewable behaviour.
  • A test fails without this change and passes with it.
  • The commands and results of each check are given above.
  • An unimplemented function returns an error (E_NOTIMPL), never a fake success.
  • README: the same change in the English and French READMEs (test_readme_sync.py checks it). No README change needed.
  • No game, console or SDK file, no key, no dump, no download link.
  • Findings drawn from a title: none in this PR.
  • Code taken from another project: none in this PR.

This change was made with AI assistance (Claude Code): the difference was found, fixed and tested by the AI as described above. It was not tested on Windows.

🤖 Generated with Claude Code

<!-- greyfinch-sync:LooperSalty/AnyXboxX:issue:5530245000 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/525). Originally posted by [Luke-Ervin](https://github.com/Luke-Ervin) on 2026-11-27T16:54:18Z. --- ## Change The Python model (`emu/rdna2_exec_vop3.py`) now refuses the VOP3 form of `v_cndmask_b32` with an unreadable lane mask even when no lane is active, as the Rust port already does. S2 of `v_cndmask_b32` (VOP3) is the lane mask, read as a scalar operand: an SGPR, an SGPR pair in wave64, or VCC. The model read it inside the loop over active lanes: ```python for lane in wave.active(): ... condition = wave.read_mask(fields.sources[2], literal) >> lane & 1 ``` So with EXEC = 0 the mask was never read. A mask the model refuses (a VGPR, or a reserved code such as 209) went through, and the instruction did nothing. With any lane active, the same instruction raised `Untranslated`. The Rust port (`vop3_forms.rs`) reads the mask once, before the lanes, and refuses it in both cases. The two models therefore disagreed whenever an earlier instruction had switched every lane off, a `v_cmpx` for example: | `v_cndmask_b32 v3, v1, v2, <mask>` (VOP3) | EXEC | Python before | Python now | Rust | |---|---|---|---|---| | mask `v4` or code 209 | all lanes | `error untranslated` | `error untranslated` | `error untranslated` | | mask `v4` or code 209 | 0 | runs, writes nothing | `error untranslated` | `error untranslated` | | mask VCC | 0 or all lanes | runs | runs, same result | runs | Why the Python side changes: - Whether an operand can be read depends on the instruction, not on which lanes are active. - Rule 3 of AGENTS.md asks for an untranslated instruction to be refused. - The model's other VOP3 checks in the same function already run before the lanes: 16-bit results with op_sel or clamp, clamp on integer results, and the literal forms without a literal. What changed: the mask is read once into `select` before the loop, and each lane takes its bit from it. - For every readable mask the result is the same as before, bit for bit: the mask is the same value on every lane. - Only a refused operand with EXEC = 0 changes, from running to `Untranslated`. - The literal case is unchanged. `docs/rust-full-status.md` and `docs/fr/rust-full-status.md` record the finding. No README row or test-count change (1969 collected with this change, still `1900+`). Linked issue: none. ## Verification Linux (Ubuntu, Python 3.13, Rust 1.98.1), on top of `main` at `a445308`, with `anyxboxx-rdna2-ref` built by `cargo build --release -p anyxboxx-rdna2-ref` (no Rust change in this PR): ``` python -m pytest → 1504 passed, 465 skipped python -m pytest tests/test_rdna2_ref_parity.py tests/test_rdna2_exec_vop3_more.py → 63 passed, 1 skipped (dxc absent) python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools → All checks passed! ``` Without the change in `rdna2_exec_vop3.py`, the new tests fail: 3 failed, the two `EXEC = 0` cases of the Python test and the parity test. Not run here: the 465 skipped tests, which need Windows, the C++ runtime, `dxc` or a GPU. No Windows machine was available. No game was run. ## Oracle and test data - Oracle: the Rust port (`crates/anyxboxx-rdna2-ref`, `vop3_forms.rs`), through `tests/test_rdna2_ref_parity.py`, and the model's own rule for operands it cannot read (`Untranslated`). - How it was found: the parity generator of `tests/test_rdna2_ref_parity.py`, run on 120,000 more seeds on `main` (with #402, #403, #437, #484, #501 and #502). - Apart from the register groups past v255 (the open question on #437), the models disagreed on only four programs. Each switched every lane off, then ran `v_cndmask_b32` with a VGPR as its mask. - With this change all four agree: both refuse. - A sweep of every VOP1, VOP2, VOP3, VOP3P and VOPC opcode with EXEC = 0 found no other such case, apart from the half-precision instructions still being ported in #503 and #505. - Test data: built in the tests (no external data). - Failure cases: - `test_cndmask_refuses_an_unreadable_mask_whatever_exec_holds` (`tests/test_rdna2_exec_vop3_more.py`) runs a VGPR and a reserved code, each with all lanes active and with EXEC = 0. - `test_cndmask_mask_refusals_do_not_depend_on_exec_in_both_models` (`tests/test_rdna2_ref_parity.py`) covers both models in wave32 and wave64: the refused masks with and without lanes, and VCC as a readable mask with and without lanes. - Control: `test_cndmask_with_a_readable_mask_and_no_lane_writes_nothing` checks that a readable mask with EXEC = 0 still runs and leaves the destination unchanged. ## Checklist - [x] The PR covers a single reviewable behaviour. - [x] A test fails without this change and passes with it. - [x] The commands and results of each check are given above. - [x] An unimplemented function returns an error (`E_NOTIMPL`), never a fake success. - [x] README: the same change in the English and French READMEs (`test_readme_sync.py` checks it). No README change needed. - [x] No game, console or SDK file, no key, no dump, no download link. - [x] Findings drawn from a title: none in this PR. - [x] Code taken from another project: none in this PR. This change was made with AI assistance (Claude Code): the difference was found, fixed and tested by the AI as described above. It was not tested on Windows. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chatgpt-codex-connector[bot] commented 2026-11-27 16:54:31 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by chatgpt-codex-connector[bot] on 2026-11-27T16:54:31Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T16:55:45.740650Z b77565b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7223808000 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/525#issuecomment-7223808000). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-27T16:54:31Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"b77565b12eb881db3f243461d6e8bb171818a0fc","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-27T16:55:45.740650Z">2026-11-27T16:55:45.740650Z</relative-time> | `b77565b` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
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
LooperSalty/AnyXboxX!525
No description provided.