fix(hw-oracle): reject invalid dispatch sizes #12326

Merged
malekaifa merged 1 commit from upstream-pr/12326 into main 2026-10-28 22:47:48 +00:00
malekaifa commented 2026-10-28 09:36:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by malekaifa on 2026-10-28T09:36:22Z.


What

tools/hw-oracle/oracle_hip.py currently converts the positional THREADS and OUT_DWORDS values with raw int(). Non-integer text therefore escapes as a ValueError traceback before any HIP or input-file work.

Convert each dispatch size at the CLI boundary and route malformed text through argparse with a field-specific diagnostic. Existing numeric range validation is unchanged. The regression covers both malformed positions and asserts rejection occurs before input reads or HIP dispatch.

Tested

  • Current-main negative control: malformed THREADS and malformed OUT_DWORDS each exit 1 with a raw ValueError traceback; numeric THREADS=0 already exits 2 cleanly.
  • Windows 11, Python 3.12: HipOracleTests - 7 passed, 1 skipped.
  • Windows 11, Python 3.9: HipOracleTests - 7 passed, 1 skipped.
  • WSL, Python 3.12: HipOracleTests - 7 passed, 1 skipped.
  • Ubuntu 22.04, Python 3.10 (pre-rebase byte-identical patch): 7 passed, 1 skipped.
  • py -3.12 tools/check_conventions.py --base origin/main - passed.
  • git diff --check origin/main...HEAD - passed.
  • py_compile on both changed files - passed.
  • Open-PR overlap scan: no open PR touches oracle_hip.py; #12084 shares only the test file in a disjoint class/hunk and synthetic merge is clean.
  • Independent exact-SHA review: PASS, no P0/P1/P2; exact published tree verified at 1f38fbf8dc.

Checklist

  • Based on current main; no other open PR implements the same behavior
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; silent stubs are documented where applicable
  • No notes, investigation .md files or images added to the repository
  • 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 (OpenAI Codex)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5048284454 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12326). Originally posted by [malekaifa](https://github.com/malekaifa) on 2026-10-28T09:36:22Z. --- ### What `tools/hw-oracle/oracle_hip.py` currently converts the positional `THREADS` and `OUT_DWORDS` values with raw `int()`. Non-integer text therefore escapes as a `ValueError` traceback before any HIP or input-file work. Convert each dispatch size at the CLI boundary and route malformed text through argparse with a field-specific diagnostic. Existing numeric range validation is unchanged. The regression covers both malformed positions and asserts rejection occurs before input reads or HIP dispatch. ### Tested - Current-main negative control: malformed `THREADS` and malformed `OUT_DWORDS` each exit 1 with a raw `ValueError` traceback; numeric `THREADS=0` already exits 2 cleanly. - Windows 11, Python 3.12: `HipOracleTests` - 7 passed, 1 skipped. - Windows 11, Python 3.9: `HipOracleTests` - 7 passed, 1 skipped. - WSL, Python 3.12: `HipOracleTests` - 7 passed, 1 skipped. - Ubuntu 22.04, Python 3.10 (pre-rebase byte-identical patch): 7 passed, 1 skipped. - `py -3.12 tools/check_conventions.py --base origin/main` - passed. - `git diff --check origin/main...HEAD` - passed. - `py_compile` on both changed files - passed. - Open-PR overlap scan: no open PR touches `oracle_hip.py`; #12084 shares only the test file in a disjoint class/hunk and synthetic merge is clean. - Independent exact-SHA review: PASS, no P0/P1/P2; exact published tree verified at 1f38fbf8dc9f661d4254602fe9e874ef102d1f79. ### Checklist - [x] Based on current `main`; no other open PR implements the same behavior - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; silent stubs are documented where applicable - [x] No notes, investigation `.md` files or images added to the repository - [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 (OpenAI Codex)
copilot-pull-request-reviewer[bot] commented 2026-10-28 09:37:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-28T09:37:45Z.

Review: COMMENTED


No active review issues are recorded for the change improving malformed HIP dispatch-size diagnostics.

No open issues 🎉

What changed in this PR

Fixes #12314 by reporting malformed HIP oracle dispatch sizes as argparse errors instead of raw ValueError tracebacks.

Changes:

  • Adds field-specific integer validation for THREADS and OUT_DWORDS, preserving existing numeric range checks.
  • Adds regression coverage confirming both malformed arguments exit with code 2 before input reads or HIP dispatch.
File Description
tools/​hw-oracle/​test_hw_oracle.py Tests clean rejection of malformed dispatch sizes before file or HIP work.
tools/​hw-oracle/​oracle_hip.py Routes integer conversion failures through argparse with field-specific diagnostics.

Review effort: Balanced

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5680552974 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12326#pullrequestreview-5680552974). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-10-28T09:37:45Z. **Review:** COMMENTED --- <!-- ccr-overview-v2 --> ### 🟢 Approval recommended No active review issues are recorded for the change improving malformed HIP dispatch-size diagnostics. **No open issues** 🎉 <details> <summary><strong>What changed in this PR</strong></summary> Fixes #12314 by reporting malformed HIP oracle dispatch sizes as argparse errors instead of raw `ValueError` tracebacks. **Changes:** - Adds field-specific integer validation for `THREADS` and `OUT_DWORDS`, preserving existing numeric range checks. - Adds regression coverage confirming both malformed arguments exit with code 2 before input reads or HIP dispatch. | File | Description | | ---- | ----------- | | `tools/​hw-oracle/​test_hw_oracle.py` | Tests clean rejection of malformed dispatch sizes before file or HIP work. | | `tools/​hw-oracle/​oracle_hip.py` | Routes integer conversion failures through argparse with field-specific diagnostics. | </details> <sub>Review effort: Balanced</sub>
MarcZX10 commented 2026-10-28 09:38:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T09:38:07Z.

Review: APPROVED


Reviewed exact head 1f38fbf8dc9f661d4254602fe9e874ef102d1f79. The CLI conversion catches malformed positional THREADS and OUT_DWORDS at the argument boundary and emits field-specific argparse errors before file reads or HIP dispatch; existing numeric range validation is unchanged. The added regression covers both positions. I ran the exact-head test_hw_oracle.py suite locally: 47 passed, 2 skipped. tools/check_conventions.py --base refs/remotes/review/upstream-main and git diff --check refs/remotes/review/upstream-main...HEAD passed. The one shared test file with #12084 has a separate SourceEncodingTests addition; no overlapping test hunks. Hosted conventions pass; remaining generic relinker jobs are pending and unrelated to this Python-only change.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5680557392 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12326#pullrequestreview-5680557392). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T09:38:07Z. **Review:** APPROVED --- Reviewed exact head `1f38fbf8dc9f661d4254602fe9e874ef102d1f79`. The CLI conversion catches malformed positional `THREADS` and `OUT_DWORDS` at the argument boundary and emits field-specific argparse errors before file reads or HIP dispatch; existing numeric range validation is unchanged. The added regression covers both positions. I ran the exact-head `test_hw_oracle.py` suite locally: 47 passed, 2 skipped. `tools/check_conventions.py --base refs/remotes/review/upstream-main` and `git diff --check refs/remotes/review/upstream-main...HEAD` passed. The one shared test file with #12084 has a separate `SourceEncodingTests` addition; no overlapping test hunks. Hosted conventions pass; remaining generic relinker jobs are pending and unrelated to this Python-only change.
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!12326
No description provided.