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

Merged
leonida/mandy
quietfold merged 1 commit from fix/mad-denorm-probe-cli-and-oracle into main 2026-11-28 15:18:06 +00:00

Pull request successfully merged and closed

quietfold commented 2026-11-25 07:46:52 +00:00

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
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] reviewed 2026-11-25 07:47:07 +00:00
copilot-pull-request-reviewer[bot] left a comment
No description provided.
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

#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.

#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

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)

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 description provided.