fix(tools): report invalid HIP dispatch sizes cleanly #12562

Closed
MarcZX10 wants to merge 1 commit from upstream-pr/12562 into main
MarcZX10 commented 2026-10-28 20:33:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T20:33:48Z.


What

Report non-integer THREADS and OUT_DWORDS arguments through argparse's normal usage-error path instead of leaking a ValueError traceback. Add regressions for each argument and assert the CLI exits before reading inputs or calling HIP. Fixes #12314.

Tested

Linux x86_64, Python 3.11:

  • python3 -m unittest test_hw_oracle from tools/hw-oracle: 48 tests passed, 2 platform-dependent skips.
  • Ran both malformed-dispatch cases against the base script and this change. Base: exit 1 with a ValueError traceback. This change: exit 2 with field-specific argparse diagnostics and no traceback.
  • git diff --check upstream/main...HEAD: passed.

Windows, HIP runtime, and GPU execution were not tested; these invalid arguments are rejected before file or HIP access.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: #12314
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5057288162 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12562). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T20:33:48Z. --- ### What Report non-integer `THREADS` and `OUT_DWORDS` arguments through argparse's normal usage-error path instead of leaking a `ValueError` traceback. Add regressions for each argument and assert the CLI exits before reading inputs or calling HIP. Fixes #12314. ### Tested Linux x86_64, Python 3.11: - `python3 -m unittest test_hw_oracle` from `tools/hw-oracle`: 48 tests passed, 2 platform-dependent skips. - Ran both malformed-dispatch cases against the base script and this change. Base: exit 1 with a `ValueError` traceback. This change: exit 2 with field-specific argparse diagnostics and no traceback. - `git diff --check upstream/main...HEAD`: passed. Windows, HIP runtime, and GPU execution were not tested; these invalid arguments are rejected before file or HIP access. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: #12314 - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
rooklz commented 2026-10-28 20:50:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-28T20:50:57Z.

Review: APPROVED


Independent check on macOS arm64 at 3f59497359 (based on current main 319621ba2e).

  • python3 -m unittest test_hw_oracle from tools/hw-oracle: 48 tests OK (3 skips) on Python 3.9.6, 3.13 and 3.14.
  • Main's oracle_hip.py with the new test: both new subtests error (ValueError), and nothing else changes.
  • CLI: oracle_hip.py code x in out 16 gives a ValueError traceback on main and error: THREADS must be an integer with exit 2 on this branch. 1.5 and '' for OUT_DWORDS are reported the same way. 1_6 and 32 are still accepted, because int() accepts them, the same as type=int would.
  • Mutants: removing either except is caught, and so is swapping the two messages. int(out_dwords or 0) is not caught, but it only changes which exit-2 message an empty string gets, so I see no real gap.
  • check_conventions --base upstream/main, pr_overlap --branch (no open overlap) and a merge-tree against main are all clean.

LGTM.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5689521654 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12562#pullrequestreview-5689521654). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-28T20:50:57Z. **Review:** APPROVED --- Independent check on macOS arm64 at 3f59497359 (based on current main 319621ba2e). - `python3 -m unittest test_hw_oracle` from `tools/hw-oracle`: 48 tests OK (3 skips) on Python 3.9.6, 3.13 and 3.14. - Main's `oracle_hip.py` with the new test: both new subtests error (`ValueError`), and nothing else changes. - CLI: `oracle_hip.py code x in out 16` gives a `ValueError` traceback on main and `error: THREADS must be an integer` with exit 2 on this branch. `1.5` and `''` for OUT_DWORDS are reported the same way. `1_6` and ` 32` are still accepted, because `int()` accepts them, the same as `type=int` would. - Mutants: removing either `except` is caught, and so is swapping the two messages. `int(out_dwords or 0)` is not caught, but it only changes which exit-2 message an empty string gets, so I see no real gap. - `check_conventions --base upstream/main`, `pr_overlap --branch` (no open overlap) and a `merge-tree` against main are all clean. LGTM.

Pull request closed

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
boykopovar/AnyPS5!12562
No description provided.