mad_denorm_probe: harden CLI parsing, hw oracle validation, and error lifecycle #1674

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

@⁠IlyassRS3 on GitHub · 2026-11-25 07:46 UTC · original
IlyassRS3:fix/mad-denorm-probe-cli-and-oracle → main · +139 −10 · 2 files · 1 commits · open

Item ID: MAD-DENORM-PROBE-CLI-AND-ORACLE (claimed in #1608)

Summary

  • Hardware oracle result validation (tools/mad_denorm_probe.py):
    • Added _extract_hw_words() used by both check_mode_denorm_effect() and run_hw() to validate that oracle.run() returns a list/tuple matching the exact kernel count and that every non-string element is a non-empty list/tuple with a non-bool int first word, preventing false passes on empty/truncated sweep responses and uncaught IndexError/TypeError on malformed payloads.
  • Oracle lifecycle & exception handling:
    • Moved asm.valu_skip_reason("v_mad_f32", oracle.arch) inside the try ... finally: oracle.close() block so the oracle is always closed on every exit path.
    • Catch runner.Unavailable (exit 77) and RuntimeError (exit 2) raised during oracle.run() inside try ... finally.
  • CLI validation:
    • Reject empty/whitespace --hw-arch and empty/trailing-comma --oracle tokens ("", "hw,", ",translator") with argparse exit code 2.
  • Regression tests (tests/test_mad_denorm_probe.py):
    • Added tests covering empty/malformed CLI flags, malformed sanity and sweep oracle responses (including empty/short/long/bool payloads), runner.Unavailable during run() -> exit 77, and RuntimeError during run() -> exit 2, verifying oracle.close() on every path.

Checklist & Verification

  • AI-assisted: yes
  • Game data included: none (python3 -I scripts/check_no_game_data.py tools/mad_denorm_probe.py tests/test_mad_denorm_probe.py passed)
  • GPUs tested: none (hostless macOS synthetic/unit test run)
  • Tests run:
    • python3 -W error -I tests/test_mad_denorm_probe.py -v: Ran 5 tests ... OK
    • Mutation test (new tests/test_mad_denorm_probe.py against unpatched main tools/mad_denorm_probe.py): Ran 5 tests ... FAILED (failures=11, errors=6)
    • 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 07:46 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1674) `IlyassRS3:fix/mad-denorm-probe-cli-and-oracle` → `main` · +139 −10 · 2 files · 1 commits · open Item ID: `MAD-DENORM-PROBE-CLI-AND-ORACLE` (claimed in https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ## Summary - **Hardware oracle result validation (`tools/mad_denorm_probe.py`)**: - Added `_extract_hw_words()` used by both `check_mode_denorm_effect()` and `run_hw()` to validate that `oracle.run()` returns a `list`/`tuple` matching the exact kernel count and that every non-string element is a non-empty `list`/`tuple` with a non-bool `int` first word, preventing false passes on empty/truncated sweep responses and uncaught `IndexError`/`TypeError` on malformed payloads. - **Oracle lifecycle & exception handling**: - Moved `asm.valu_skip_reason("v_mad_f32", oracle.arch)` inside the `try ... finally: oracle.close()` block so the oracle is always closed on every exit path. - Catch `runner.Unavailable` (exit `77`) and `RuntimeError` (exit `2`) raised during `oracle.run()` inside `try ... finally`. - **CLI validation**: - Reject empty/whitespace `--hw-arch` and empty/trailing-comma `--oracle` tokens (`""`, `"hw,"`, `",translator"`) with argparse exit code `2`. - **Regression tests (`tests/test_mad_denorm_probe.py`)**: - Added tests covering empty/malformed CLI flags, malformed sanity and sweep oracle responses (including empty/short/long/bool payloads), `runner.Unavailable` during `run()` -> exit `77`, and `RuntimeError` during `run()` -> exit `2`, verifying `oracle.close()` on every path. ## Checklist & Verification - **AI-assisted**: yes - **Game data included**: none (`python3 -I scripts/check_no_game_data.py tools/mad_denorm_probe.py tests/test_mad_denorm_probe.py` passed) - **GPUs tested**: none (hostless macOS synthetic/unit test run) - **Tests run**: - `python3 -W error -I tests/test_mad_denorm_probe.py -v`: `Ran 5 tests ... OK` - Mutation test (new `tests/test_mad_denorm_probe.py` against unpatched `main` `tools/mad_denorm_probe.py`): `Ran 5 tests ... FAILED (failures=11, errors=6)` - `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:18 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 07:47 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 07:47 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1674#pullrequestreview-6053665900) · **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.
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/1674/head:github-bot/gh-1674'
git switch 'github-bot/gh-1674'

Merge

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