[PR #1674] mad_denorm_probe: harden CLI parsing, hw oracle validation, and error lifecycle #1689

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

📋 Pull Request Information

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

Base: main ← Head: fix/mad-denorm-probe-cli-and-oracle


📝 Commits (1)

  • 28e797e mad_denorm_probe: harden CLI parsing, hw oracle validation, and error lifecycle

📊 Changes

2 files changed (+139 additions, -10 deletions)

View changed files

📝 tests/test_mad_denorm_probe.py (+102 -0)
📝 tools/mad_denorm_probe.py (+37 -10)

📄 Description

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

🔄 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/1674 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/mad-denorm-probe-cli-and-oracle` --- ### 📝 Commits (1) - [`28e797e`](https://github.com/ubiquitarianism/leonida/commit/28e797e63c5568ad042e17fd76fe1ba8133bdd44) mad_denorm_probe: harden CLI parsing, hw oracle validation, and error lifecycle ### 📊 Changes **2 files changed** (+139 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_mad_denorm_probe.py` (+102 -0) 📝 `tools/mad_denorm_probe.py` (+37 -10) </details> ### 📄 Description 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` --- <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#1689
No description provided.