cvt_pknorm_f16_probe: harden --ops/--waves, upfront atomic JSON writes, and result count guard #1640

Open
github-bot wants to merge 1 commit from github-bot/gh-1640 into main AGit
Owner

@⁠IlyassRS3 on GitHub · 2026-11-25 06:47 UTC · original
IlyassRS3:fix/cvt-pknorm-f16-probe-json-and-cli → main · +229 −13 · 2 files · 1 commits · open

Item ID: CVT-PKNORM-F16-PROBE-JSON-AND-CLI
Claim: #1608

Summary

Harden CLI argument parsing, JSON report writing, and harness error handling in tools/cvt_pknorm_f16_probe.py:

  • --ops / --waves / --hw-arch guards: reject empty/trailing comma tokens (32,, ,v_cvt_pknorm_i16_f16, 32,,64), deduplicate repeated ops/waves so kernels and sweep_words/case_words are not double-counted, and reject empty/whitespace --hw-arch.
  • Upfront --json validation: reject empty/whitespace paths, trailing separators, directories, non-directory parent blockers, and unwritable existing targets before opening hw_oracle and running the 1M-half exhaustive sweep.
  • Atomic write_report(): serialize upfront with allow_nan=False and LF endings, handle non-regular targets like /dev/null directly, resolve symlinks before staging to preserve symlink targets, apply file_mode.published_mode, and publish via replace_retry.replace.
  • Harness guards: return a harness_errors entry when len(raw_results) != len(meta) in evaluate_results() (preventing KeyError after zip() truncation), and catch ValueError from asm.family(oracle.arch) cleanly (exit 77).
  • Tests (tests/test_cvt_pknorm_f16_probe.py): added 3 test methods covering malformed/duplicate --ops/--waves, empty --hw-arch/--json, upfront blocker/trailing-sep rejection, atomic/symlink/NaN//dev/null writes, result count mismatch, and unknown arch family.

Verification

  • AI-assisted: yes
  • GPUs tested: none (CPU synthetic unit tests + FakeOracle on macOS; no GPU, AMD clang, or game data present)
  • python3 -W error -I tests/test_cvt_pknorm_f16_probe.py -v: 9 passed, 1 skipped (AMD clang absent)
  • Mutation check against unpatched main: ran=10 failures=1 errors=11 (skipped=1)
  • python3 -I tests/test_text_write_line_endings.py: 3/3 passed
  • python3 -I scripts/check_no_game_data.py tools/cvt_pknorm_f16_probe.py tests/test_cvt_pknorm_f16_probe.py: passed
  • python3 -m compileall -q tools/cvt_pknorm_f16_probe.py tests/test_cvt_pknorm_f16_probe.py: passed
**@⁠IlyassRS3** on GitHub · 2026-11-25 06:47 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1640) `IlyassRS3:fix/cvt-pknorm-f16-probe-json-and-cli` → `main` · +229 −13 · 2 files · 1 commits · open Item ID: `CVT-PKNORM-F16-PROBE-JSON-AND-CLI` Claim: https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608 ### Summary Harden CLI argument parsing, JSON report writing, and harness error handling in `tools/cvt_pknorm_f16_probe.py`: - **`--ops` / `--waves` / `--hw-arch` guards**: reject empty/trailing comma tokens (`32,`, `,v_cvt_pknorm_i16_f16`, `32,,64`), deduplicate repeated ops/waves so kernels and `sweep_words`/`case_words` are not double-counted, and reject empty/whitespace `--hw-arch`. - **Upfront `--json` validation**: reject empty/whitespace paths, trailing separators, directories, non-directory parent blockers, and unwritable existing targets *before* opening `hw_oracle` and running the 1M-half exhaustive sweep. - **Atomic `write_report()`**: serialize upfront with `allow_nan=False` and LF endings, handle non-regular targets like `/dev/null` directly, resolve symlinks before staging to preserve symlink targets, apply `file_mode.published_mode`, and publish via `replace_retry.replace`. - **Harness guards**: return a `harness_errors` entry when `len(raw_results) != len(meta)` in `evaluate_results()` (preventing `KeyError` after `zip()` truncation), and catch `ValueError` from `asm.family(oracle.arch)` cleanly (exit `77`). - **Tests (`tests/test_cvt_pknorm_f16_probe.py`)**: added 3 test methods covering malformed/duplicate `--ops`/`--waves`, empty `--hw-arch`/`--json`, upfront blocker/trailing-sep rejection, atomic/symlink/NaN/`/dev/null` writes, result count mismatch, and unknown arch family. ### Verification - AI-assisted: yes - GPUs tested: none (CPU synthetic unit tests + FakeOracle on macOS; no GPU, AMD clang, or game data present) - `python3 -W error -I tests/test_cvt_pknorm_f16_probe.py -v`: 9 passed, 1 skipped (AMD clang absent) - Mutation check against unpatched `main`: `ran=10 failures=1 errors=11 (skipped=1)` - `python3 -I tests/test_text_write_line_endings.py`: 3/3 passed - `python3 -I scripts/check_no_game_data.py tools/cvt_pknorm_f16_probe.py tests/test_cvt_pknorm_f16_probe.py`: passed - `python3 -m compileall -q tools/cvt_pknorm_f16_probe.py tests/test_cvt_pknorm_f16_probe.py`: passed
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:59:05 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 06:48 UTC · original · reviewed

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.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-25 06:48 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1640#pullrequestreview-6053057681) · **reviewed** 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.
Author
Owner

@⁠GeorgiyDemo on GitHub · 2026-11-25 06:50 UTC · original

Tested 4446d1ac5 on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against main 42537e7b6 (Python GPU probe; hardware oracle not run):

  • pytest 9.2.0 on tests/test_cvt_pknorm_f16_probe.py: 9 passed, 1 skipped, 9 subtests passed at this head.
  • The same file on main: 12 failed, 6 passed, 1 skipped — the --ops/--waves token guards, dedup, upfront atomic JSON validation and the result-count guard are not there.
  • Not run: the hardware oracle on a real AMD GPU (none here); the skip is the hardware-dependent test.

AI-assisted; synthetic fixtures only, no game data.

**@⁠GeorgiyDemo** on GitHub · 2026-11-25 06:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1640#issuecomment-7155211885) Tested `4446d1ac5` on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against `main` `42537e7b6` (Python GPU probe; hardware oracle not run): - pytest 9.2.0 on `tests/test_cvt_pknorm_f16_probe.py`: **9 passed, 1 skipped, 9 subtests passed** at this head. - The same file on `main`: **12 failed**, 6 passed, 1 skipped — the `--ops`/`--waves` token guards, dedup, upfront atomic JSON validation and the result-count guard are not there. - Not run: the hardware oracle on a real AMD GPU (none here); the skip is the hardware-dependent test. AI-assisted; synthetic fixtures only, no game data.
Author
Owner

@⁠whoalin1 on GitHub · 2026-11-25 09:52 UTC · original

Independent verification (Windows, Python 3.11.9 -I -W error): same hardening pattern confirmed — CLI token guards, dedup, upfront --json validation (blocked parent -> exit 2 pre-oracle), atomic writes, result-count guard, asm.family->77. test_cvt_pknorm_f16_probe.py 10 OK (1 skip, matches claim); --self-test ok (33 cases, 65,536 f16 entries); hygiene checks clean. AI-assisted verification.

**@⁠whoalin1** on GitHub · 2026-11-25 09:52 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1640#issuecomment-7158924040) Independent verification (Windows, Python 3.11.9 `-I -W error`): same hardening pattern confirmed — CLI token guards, dedup, upfront `--json` validation (blocked parent -> exit 2 pre-oracle), atomic writes, result-count guard, `asm.family`->77. `test_cvt_pknorm_f16_probe.py` 10 OK (1 skip, matches claim); `--self-test` ok (33 cases, 65,536 f16 entries); hygiene checks clean. AI-assisted verification.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1640/head:github-bot/gh-1640'
git switch 'github-bot/gh-1640'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1640'
git switch 'github-bot/gh-1640'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1640'
git switch 'github-bot/gh-1640'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1640'
git switch 'main'
git merge --squash 'github-bot/gh-1640'
git switch 'main'
git merge --ff-only 'github-bot/gh-1640'
git switch 'main'
git merge 'github-bot/gh-1640'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.