vinterp_hw_probe: harden CLI validation, run_hw batch/tuple handling, and harness error exits #1682

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

@⁠IlyassRS3 on GitHub · 2026-11-25 08:01 UTC · original
IlyassRS3:fix/vinterp-hw-probe-oracle-and-cli → main · +125 −8 · 2 files · 1 commits · open

Item ID: VINTERP-HW-PROBE-ORACLE-AND-CLI (claimed in #1608)

Summary

  • Hardware oracle batch/result validation (tools/vinterp_hw_probe.py):
    • In run_hw(), validate that oracle.run([k] * 4, words=5) returns a list/tuple of length 4, accept both list and tuple per-kernel entries when selecting CU0 ((r[4] & 0x100) == 0) or falling back to a valid entry, verify at least 5 non-bool int words per non-string entry (masking to 32 bits), and raise RuntimeError when a batch is malformed or all 4 kernels are rejected as strings (instead of crashing with IndexError/TypeError or misreporting rejections as MISMATCH exit 1).
  • CLI & harness error handling:
    • Reject empty/whitespace --hw-arch with argparse exit code 2.
    • Catch rdna2spirv.Unsupported, spirv_mini_interp.UnsupportedConstruct, RuntimeError, and OSError around run_translator_checks(), plus RuntimeError around run_hw(), returning exit 2 cleanly instead of unhandled tracebacks.
  • Regression tests (tests/test_vinterp_hw_probe.py):
    • Added tests covering empty --hw-arch, translator harness errors -> exit 2, tuple CU0 selection over CU1, malformed & all-rejected hardware oracle batches, and RuntimeError/runner.Unavailable raised from oracle.run(), verifying oracle.close() on every path.

Checklist & Verification

  • AI-assisted: yes
  • Game data included: none (python3 -I scripts/check_no_game_data.py tools/vinterp_hw_probe.py tests/test_vinterp_hw_probe.py passed)
  • GPUs tested: none (hostless macOS synthetic/unit test run)
  • Tests run:
    • python3 -W error -I tests/test_vinterp_hw_probe.py -v: Ran 7 tests ... OK
    • Mutation test (new tests/test_vinterp_hw_probe.py against unpatched main tools/vinterp_hw_probe.py): Ran 7 tests ... FAILED (failures=3, errors=1)
    • python3 -m compileall -q make_game.py tools tests: passed
    • python3 -I tests/test_text_write_line_endings.py: Ran 3 tests ... OK
**@⁠IlyassRS3** on GitHub · 2026-11-25 08:01 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1682) `IlyassRS3:fix/vinterp-hw-probe-oracle-and-cli` → `main` · +125 −8 · 2 files · 1 commits · open Item ID: `VINTERP-HW-PROBE-ORACLE-AND-CLI` (claimed in https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ## Summary - **Hardware oracle batch/result validation (`tools/vinterp_hw_probe.py`)**: - In `run_hw()`, validate that `oracle.run([k] * 4, words=5)` returns a `list`/`tuple` of length `4`, accept both `list` and `tuple` per-kernel entries when selecting CU0 (`(r[4] & 0x100) == 0`) or falling back to a valid entry, verify at least 5 non-bool `int` words per non-string entry (masking to 32 bits), and raise `RuntimeError` when a batch is malformed or all 4 kernels are rejected as strings (instead of crashing with `IndexError`/`TypeError` or misreporting rejections as `MISMATCH` exit `1`). - **CLI & harness error handling**: - Reject empty/whitespace `--hw-arch` with argparse exit code `2`. - Catch `rdna2spirv.Unsupported`, `spirv_mini_interp.UnsupportedConstruct`, `RuntimeError`, and `OSError` around `run_translator_checks()`, plus `RuntimeError` around `run_hw()`, returning exit `2` cleanly instead of unhandled tracebacks. - **Regression tests (`tests/test_vinterp_hw_probe.py`)**: - Added tests covering empty `--hw-arch`, translator harness errors -> exit `2`, tuple CU0 selection over CU1, malformed & all-rejected hardware oracle batches, and `RuntimeError`/`runner.Unavailable` raised from `oracle.run()`, verifying `oracle.close()` on every path. ## Checklist & Verification - **AI-assisted**: yes - **Game data included**: none (`python3 -I scripts/check_no_game_data.py tools/vinterp_hw_probe.py tests/test_vinterp_hw_probe.py` passed) - **GPUs tested**: none (hostless macOS synthetic/unit test run) - **Tests run**: - `python3 -W error -I tests/test_vinterp_hw_probe.py -v`: `Ran 7 tests ... OK` - Mutation test (new `tests/test_vinterp_hw_probe.py` against unpatched `main` `tools/vinterp_hw_probe.py`): `Ran 7 tests ... FAILED (failures=3, errors=1)` - `python3 -m compileall -q make_game.py tools tests`: passed - `python3 -I tests/test_text_write_line_endings.py`: `Ran 3 tests ... OK`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:00:38 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 08:01 UTC · original · reviewed

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-25 08:01 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1682#pullrequestreview-6053823893) · **reviewed** Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Author
Owner

@⁠whoalin1 on GitHub · 2026-11-25 08:52 UTC · original

Independent verification (Windows, Python 3.11.9 -I -W error): run_hw batch/tuple handling, CU0 preference + first-valid fallback, RuntimeError->exit 2, --hw-arch empty guard, str->exit 2 — all match claims. test_vinterp_hw_probe.py 7 OK; neighbors hw_oracle 59 + asm_strip + workdir_leak 9 all OK; bad-CLI probes exit 2 correctly; compileall + line-endings + check_no_game_data clean. AI-assisted verification.

**@⁠whoalin1** on GitHub · 2026-11-25 08:52 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1682#issuecomment-7157577205) Independent verification (Windows, Python 3.11.9 `-I -W error`): `run_hw` batch/tuple handling, CU0 preference + first-valid fallback, RuntimeError->exit 2, `--hw-arch` empty guard, str->exit 2 — all match claims. `test_vinterp_hw_probe.py` 7 OK; neighbors hw_oracle 59 + asm_strip + workdir_leak 9 all OK; bad-CLI probes exit 2 correctly; compileall + line-endings + check_no_game_data clean. AI-assisted verification.
Author
Owner

@⁠GrahamboJangles on GitHub · 2026-11-25 12:06 UTC · original

Independent review (CPU-only Windows 11, python 3.14.9 -I; head c80e31bc6, current main 57ba40bd6).

Coordination. Claim 7156493260 (IlyassRS3) was posted at 08:00:13Z — about half a minute AFTER PR creation (07:59:45Z), unlike the sibling items whose claims precede the PR. Roster shows done: VINTERP-HW-PROBE-ORACLE-AND-CLI -> #1682 and gh pr list --search vinterp_hw_probe --state all returns only this PR, so there is no duplicate work; just flagging the ordering.

The new tests bite (inverse check). tests/test_vinterp_hw_probe.py at head: Ran 7 tests ... OK; main's copy: Ran 5 tests ... OK — net +2 as claimed. The head test file against main's tool: FAILED (failures=3, errors=1), every failure inside the two new methods — empty/whitespace --hw-arch passes through to the oracle on main (AttributeError traceback), and malformed run_hw batches crash with TypeError/IndexError instead of clean exit-2 harness errors. The 5 pre-existing tests stay green against main.

Code notes.

  • The rejection handling is a real fix: main picked batch[0] when no CU0-flagged word came back, so a string rejection flowed into the comparison as a raw string and printed MISMATCH with exit 1 (a hardware mismatch claim that never happened). The patch raises RuntimeError(f"... kernel rejected: {rejected[0]}") when all four are strings and picks the first valid fallback row otherwise; verified by the tuple/CU0 subtests at head.
  • run_hw now accepts tuples as well as lists per kernel result and masks words to 32 bits before comparing, matching the sibling interp_hw_probe hardening (#1680).
  • run_translator_checks() is wrapped with (rdna2spirv.Unsupported, spirv_mini_interp.UnsupportedConstruct, RuntimeError, OSError) -> exit 2: translator failures that used to traceback now get a harness error: line. Exit-code discipline (77 for unavailable oracle, 2 for harness errors) matches the repo's probe-tool convention.
  • One behavior note, not a blocker: the RuntimeError catch also swallows genuine harness bugs raised deep inside the check functions — but exit 2 with the message is the intended classification for those, same as the other probe tools in this family.

Mergeability & hygiene. git diff 3f81d46ac..origin/main over both files: 0 bytes — rebases clean onto moved main. check_no_game_data.py exits 0 on both files; compileall clean. CI (change-scope, no-game-data) pending at head when I looked.

Verdict: LGTM — the crash-to-harness-error conversions are confirmed against unpatched main, the +2 test delta is real, and the branch is disjoint from main's later merges.

AI-assisted (Hermes overnight shift). Complements whoalin1's verification comment with the count-move gate (5→7) and the rebase check.

**@⁠GrahamboJangles** on GitHub · 2026-11-25 12:06 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1682#issuecomment-7161933447) Independent review (CPU-only Windows 11, python 3.14.9 `-I`; head `c80e31bc6`, current main `57ba40bd6`). **Coordination.** Claim 7156493260 (IlyassRS3) was posted at 08:00:13Z — about half a minute AFTER PR creation (07:59:45Z), unlike the sibling items whose claims precede the PR. Roster shows `done: VINTERP-HW-PROBE-ORACLE-AND-CLI -> #1682` and `gh pr list --search vinterp_hw_probe --state all` returns only this PR, so there is no duplicate work; just flagging the ordering. **The new tests bite (inverse check).** `tests/test_vinterp_hw_probe.py` at head: `Ran 7 tests ... OK`; main's copy: `Ran 5 tests ... OK` — net +2 as claimed. The head test file against **main's** tool: `FAILED (failures=3, errors=1)`, every failure inside the two new methods — empty/whitespace `--hw-arch` passes through to the oracle on main (AttributeError traceback), and malformed `run_hw` batches crash with `TypeError`/`IndexError` instead of clean exit-2 harness errors. The 5 pre-existing tests stay green against main. **Code notes.** - The rejection handling is a real fix: main picked `batch[0]` when no CU0-flagged word came back, so a string rejection flowed into the comparison as a raw string and printed `MISMATCH` with exit 1 (a hardware mismatch claim that never happened). The patch raises `RuntimeError(f"... kernel rejected: {rejected[0]}")` when all four are strings and picks the first valid fallback row otherwise; verified by the tuple/CU0 subtests at head. - `run_hw` now accepts tuples as well as lists per kernel result and masks words to 32 bits before comparing, matching the sibling interp_hw_probe hardening (#1680). - `run_translator_checks()` is wrapped with `(rdna2spirv.Unsupported, spirv_mini_interp.UnsupportedConstruct, RuntimeError, OSError) -> exit 2`: translator failures that used to traceback now get a `harness error:` line. Exit-code discipline (77 for unavailable oracle, 2 for harness errors) matches the repo's probe-tool convention. - One behavior note, not a blocker: the `RuntimeError` catch also swallows genuine harness bugs raised deep inside the check functions — but exit 2 with the message is the intended classification for those, same as the other probe tools in this family. **Mergeability & hygiene.** `git diff 3f81d46ac..origin/main` over both files: 0 bytes — rebases clean onto moved main. `check_no_game_data.py` exits 0 on both files; `compileall` clean. CI (`change-scope`, `no-game-data`) pending at head when I looked. **Verdict: LGTM** — the crash-to-harness-error conversions are confirmed against unpatched main, the +2 test delta is real, and the branch is disjoint from main's later merges. AI-assisted (Hermes overnight shift). Complements whoalin1's verification comment with the count-move gate (5→7) and the rebase check.
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/1682/head:github-bot/gh-1682'
git switch 'github-bot/gh-1682'

Merge

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