[PR #1670] fma_mix_probe: harden CLI parsing, hw oracle validation, and Vulkan/translator error handling #1684

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

📋 Pull Request Information

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

Base: main ← Head: fix/fma-mix-probe-cli-and-oracle


📝 Commits (1)

  • 5e8a78e fma_mix_probe: harden CLI parsing, hw oracle validation, and Vulkan/translator error handling

📊 Changes

2 files changed (+147 additions, -6 deletions)

View changed files

📝 tests/test_fma_mix_probe.py (+105 -0)
📝 tools/fma_mix_probe.py (+42 -6)

📄 Description

Item ID: FMA-MIX-PROBE-CLI-AND-ORACLE (claimed in https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156111455)

Summary

  • Hardware oracle validation & Unavailable handling (tools/fma_mix_probe.py):
    • In run_hw(), validate that oracle.run() returns a list/tuple matching len(cases) and that every non-string entry is a non-empty list/tuple whose first element is an int (not bool), raising RuntimeError (exit 2) instead of silently truncating via zip() or crashing with uncaught IndexError/TypeError.
    • Catch runner.Unavailable inside the run_hw() try/finally block in main() so ModeUnavailable during oracle.run() exits 77 cleanly while closing the oracle.
  • CLI validation:
    • Reject empty/whitespace --hw-arch and --build, and reject empty or trailing-comma --oracle tokens ("", "hw,", ",translator") with argparse exit code 2.
  • Vulkan, translator, and word-masking hardening:
    • Catch rdna2spirv.Unsupported alongside spirv_mini_interp.UnsupportedConstruct in main() (exit 2 harness error).
    • Pass errors="replace" to spirv-as and vk_compute_test subprocess runs in run_vulkan() to prevent uncaught UnicodeDecodeError on non-UTF-8 output, and avoid duplicating runtime/test/shaders in sys.path.
    • Mask word &= 0xFFFFFFFF in half() so high-bit masking is exact.
  • Regression tests (tests/test_fma_mix_probe.py):
    • Added 3 tests covering malformed/empty CLI flags, malformed hw oracle payloads + Unavailable during run() + rdna2spirv.Unsupported, and half() masking + run_vulkan(..., errors="replace").

Checklist & Verification

  • AI-assisted: yes
  • Game data included: none (python3 -I scripts/check_no_game_data.py tools/fma_mix_probe.py tests/test_fma_mix_probe.py passed)
  • GPUs tested: none (hostless macOS synthetic/unit test run)
  • Tests run:
    • python3 -W error -I tests/test_fma_mix_probe.py -v: Ran 21 tests ... OK
    • Mutation test (new tests/test_fma_mix_probe.py against unpatched main tools/fma_mix_probe.py): Ran 21 tests ... FAILED (failures=12, errors=3)
    • 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/1670 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/fma-mix-probe-cli-and-oracle` --- ### 📝 Commits (1) - [`5e8a78e`](https://github.com/ubiquitarianism/leonida/commit/5e8a78e5a8cfaca491640db12faef7cd151077df) fma_mix_probe: harden CLI parsing, hw oracle validation, and Vulkan/translator error handling ### 📊 Changes **2 files changed** (+147 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_fma_mix_probe.py` (+105 -0) 📝 `tools/fma_mix_probe.py` (+42 -6) </details> ### 📄 Description Item ID: `FMA-MIX-PROBE-CLI-AND-ORACLE` (claimed in https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156111455) ## Summary - **Hardware oracle validation & `Unavailable` handling (`tools/fma_mix_probe.py`)**: - In `run_hw()`, validate that `oracle.run()` returns a `list`/`tuple` matching `len(cases)` and that every non-string entry is a non-empty `list`/`tuple` whose first element is an `int` (not `bool`), raising `RuntimeError` (exit `2`) instead of silently truncating via `zip()` or crashing with uncaught `IndexError`/`TypeError`. - Catch `runner.Unavailable` inside the `run_hw()` `try/finally` block in `main()` so `ModeUnavailable` during `oracle.run()` exits `77` cleanly while closing the oracle. - **CLI validation**: - Reject empty/whitespace `--hw-arch` and `--build`, and reject empty or trailing-comma `--oracle` tokens (`""`, `"hw,"`, `",translator"`) with argparse exit code `2`. - **Vulkan, translator, and word-masking hardening**: - Catch `rdna2spirv.Unsupported` alongside `spirv_mini_interp.UnsupportedConstruct` in `main()` (exit `2` harness error). - Pass `errors="replace"` to `spirv-as` and `vk_compute_test` subprocess runs in `run_vulkan()` to prevent uncaught `UnicodeDecodeError` on non-UTF-8 output, and avoid duplicating `runtime/test/shaders` in `sys.path`. - Mask `word &= 0xFFFFFFFF` in `half()` so high-bit masking is exact. - **Regression tests (`tests/test_fma_mix_probe.py`)**: - Added 3 tests covering malformed/empty CLI flags, malformed hw oracle payloads + `Unavailable` during `run()` + `rdna2spirv.Unsupported`, and `half()` masking + `run_vulkan(..., errors="replace")`. ## Checklist & Verification - **AI-assisted**: yes - **Game data included**: none (`python3 -I scripts/check_no_game_data.py tools/fma_mix_probe.py tests/test_fma_mix_probe.py` passed) - **GPUs tested**: none (hostless macOS synthetic/unit test run) - **Tests run**: - `python3 -W error -I tests/test_fma_mix_probe.py -v`: `Ran 21 tests ... OK` - Mutation test (new `tests/test_fma_mix_probe.py` against unpatched `main` `tools/fma_mix_probe.py`): `Ran 21 tests ... FAILED (failures=12, errors=3)` - `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#1684
No description provided.