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

Open
opened 2026-11-26 20:22:08 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1682
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/vinterp-hw-probe-oracle-and-cli


📝 Commits (1)

  • c80e31b vinterp_hw_probe: harden CLI validation, run_hw batch/tuple handling, and harness error exits

📊 Changes

2 files changed (+125 additions, -8 deletions)

View changed files

📝 tests/test_vinterp_hw_probe.py (+91 -1)
📝 tools/vinterp_hw_probe.py (+34 -7)

📄 Description

Item ID: VINTERP-HW-PROBE-ORACLE-AND-CLI (claimed in https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156493260)

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1682 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/vinterp-hw-probe-oracle-and-cli` --- ### 📝 Commits (1) - [`c80e31b`](https://github.com/ubiquitarianism/leonida/commit/c80e31bc63976788750d53e512fc5f23bfdb6f5f) vinterp_hw_probe: harden CLI validation, run_hw batch/tuple handling, and harness error exits ### 📊 Changes **2 files changed** (+125 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_vinterp_hw_probe.py` (+91 -1) 📝 `tools/vinterp_hw_probe.py` (+34 -7) </details> ### 📄 Description Item ID: `VINTERP-HW-PROBE-ORACLE-AND-CLI` (claimed in https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156493260) ## 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` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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
starred/leonida#1696
No description provided.