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

Merged
IlyassRS3 merged 1 commit from upstream-pr/1674 into main 2026-11-28 15:18:06 +00:00
IlyassRS3 commented 2026-11-25 07:46:52 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T07:46:52Z.


Item ID: MAD-DENORM-PROBE-CLI-AND-ORACLE (claimed in https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156204400)

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
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5487293995 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1674). Originally posted by [IlyassRS3](https://github.com/IlyassRS3) on 2026-11-25T07:46:52Z. --- Item ID: `MAD-DENORM-PROBE-CLI-AND-ORACLE` (claimed in https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156204400) ## 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`
copilot-pull-request-reviewer[bot] commented 2026-11-25 07:47:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T07:47:07Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6053665900 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1674#pullrequestreview-6053665900). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-25T07:47:07Z. **Review:** COMMENTED --- 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.
zmasi commented 2026-11-28 10:47:30 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T10:47:30Z.


#1674 | head 28e797e63c (merged cleanly with main 95b2e6c67) | python -I tests/test_mad_denorm_probe.py | red on main: FAILED (failures=11, errors=6) (false 0 exit on empty/short sweep lists due to silent zip, bool word accepted as 0x1, malformed --oracle/--hw-arch flags accepted, and uncaught IndexError/TypeError/Unavailable in run_hw / check_mode_denorm_effect) | green on PR+main: 5 tests OK | Windows 11, Python 3.12.10 | AI-assisted: yes

Audited _extract_hw_words (enforcing exact batch length and strict integer/non-bool 32-bit words across both check_mode_denorm_effect and run_hw), upfront --oracle/--hw-arch validation, and unified try/finally: oracle.close() handling for valu_skip_reason, runner.Unavailable -> exit 77, and RuntimeError -> exit 2 in tools/mad_denorm_probe.py. Also passed tests/test_ci_registration.py (18 OK), tests/test_text_write_line_endings.py (3 OK), tests/test_runner_calls_all_tests.py (3 OK), and scripts/check_no_game_data.py.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238124490 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1674#issuecomment-7238124490). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T10:47:30Z. --- #1674 | head 28e797e63c5568ad042e17fd76fe1ba8133bdd44 (merged cleanly with main 95b2e6c67) | `python -I tests/test_mad_denorm_probe.py` | red on main: `FAILED (failures=11, errors=6)` (false `0` exit on empty/short sweep lists due to silent `zip`, `bool` word accepted as `0x1`, malformed `--oracle`/`--hw-arch` flags accepted, and uncaught `IndexError`/`TypeError`/`Unavailable` in `run_hw` / `check_mode_denorm_effect`) | green on PR+main: `5 tests OK` | Windows 11, Python 3.12.10 | AI-assisted: yes Audited `_extract_hw_words` (enforcing exact batch length and strict integer/non-`bool` 32-bit words across both `check_mode_denorm_effect` and `run_hw`), upfront `--oracle`/`--hw-arch` validation, and unified `try`/`finally: oracle.close()` handling for `valu_skip_reason`, `runner.Unavailable -> exit 77`, and `RuntimeError -> exit 2` in `tools/mad_denorm_probe.py`. Also passed `tests/test_ci_registration.py` (`18 OK`), `tests/test_text_write_line_endings.py` (`3 OK`), `tests/test_runner_calls_all_tests.py` (`3 OK`), and `scripts/check_no_game_data.py`.
MoonEyes commented 2026-11-28 14:49:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T14:49:48Z.


Red/green: pytest tests/test_mad_denorm_probe.py fails on main (17 failed, 4 passed, 1 subtests passed) and passes on head 28e797e63c merged with main (5 passed, 17 subtests passed).
Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main d48a957bb in GitHub Actions: no new failure.
AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7240963476 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1674#issuecomment-7240963476). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T14:49:48Z. --- Red/green: `pytest tests/test_mad_denorm_probe.py` fails on main (17 failed, 4 passed, 1 subtests passed) and passes on head 28e797e63c55 merged with main (5 passed, 17 subtests passed). Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main d48a957bb in GitHub Actions: no new failure. AI-assisted (Claude Code, Claude Opus 5.5)
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
ProjectLeonida/mandy!1674
No description provided.