diff options
| author | Danil <danielsh200@gmail.com> | 2026-11-23 23:40:19 +0200 |
|---|---|---|
| committer | Danil <danielsh200@gmail.com> | 2026-11-23 23:40:19 +0200 |
| commit | d2901fa549917a88ee978ef716c50be2f57647c8 (patch) | |
| tree | 5bdb95ba03fa94fa0f52cae07ad2c68a2aa88ff1 /tools/fmisc_diff.py | |
| parent | 5c6d6cc1f8036258f96a61f2bfbf7d34fedbe805 (diff) | |
fmisc_diff: validate the hardware rows before the Vulkan comparison
With --oracle hw,vk, run_suite called vk_verdict on each hardware row
before check() validated it, so a None row raised a TypeError and a
short or empty row an IndexError, both uncaught by main() (traceback,
exit 1). A None batch also reached len(hw). check_hw_rows() now refuses
a None batch, a wrong result count, and a None or sub-4-word row right
after oracle.run(), before either comparison path; str rows (skip
reasons) pass as before. main-level hw,vk regressions cover None, []
and a 2-word row, as the review asked.
AI-assisted (Claude Code)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tools/fmisc_diff.py')
| -rw-r--r-- | tools/fmisc_diff.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tools/fmisc_diff.py b/tools/fmisc_diff.py index 6a098d9a6..78d97b149 100644 --- a/tools/fmisc_diff.py +++ b/tools/fmisc_diff.py | |||
| @@ -671,6 +671,21 @@ def vk_verdict(lines, hw, got): | |||
| 671 | return "mismatch", f"word {i} ({lines[-N_OBS + i].split(', ')[1]}): hardware 0x{hw[i]:08x}, translated on the GPU 0x{got[i]:08x}" | 671 | return "mismatch", f"word {i} ({lines[-N_OBS + i].split(', ')[1]}): hardware 0x{hw[i]:08x}, translated on the GPU 0x{got[i]:08x}" |
| 672 | 672 | ||
| 673 | 673 | ||
| 674 | def check_hw_rows(hw, count): | ||
| 675 | """Refuse a hardware batch that can't be compared: no list, the wrong number of results, or a result that is None | ||
| 676 | or has fewer than 4 words. A str result (why the program was skipped) is kept. Runs before both comparison paths, | ||
| 677 | so vk_verdict never sees a row check() would have refused.""" | ||
| 678 | if hw is None: | ||
| 679 | raise RuntimeError("no result from the hardware runner") | ||
| 680 | if len(hw) != count: | ||
| 681 | raise RuntimeError(f"the hardware runner returned {len(hw)} results for {count} programs") | ||
| 682 | for i, row in enumerate(hw): | ||
| 683 | if row is None: | ||
| 684 | raise RuntimeError(f"no result from the hardware runner for program {i}") | ||
| 685 | if not isinstance(row, str) and len(row) < 4: | ||
| 686 | raise RuntimeError(f"the hardware runner returned {len(row)} words for program {i} (expected 4)") | ||
| 687 | |||
| 688 | |||
| 674 | def run_suite(programs, seed, max_ops, ops, backends=("translator",), oracle=None, wave=32, build=None, work=None): | 689 | def run_suite(programs, seed, max_ops, ops, backends=("translator",), oracle=None, wave=32, build=None, work=None): |
| 675 | counts = {"pass": 0, "mismatch": 0, "skip": {}, "vk": {}} | 690 | counts = {"pass": 0, "mismatch": 0, "skip": {}, "vk": {}} |
| 676 | failures = [] | 691 | failures = [] |
| @@ -678,8 +693,7 @@ def run_suite(programs, seed, max_ops, ops, backends=("translator",), oracle=Non | |||
| 678 | progs = [generate(rng, rng.randrange(1, max_ops + 1), ops) for _ in range(programs)] | 693 | progs = [generate(rng, rng.randrange(1, max_ops + 1), ops) for _ in range(programs)] |
| 679 | if "hw" in backends: | 694 | if "hw" in backends: |
| 680 | hw = oracle.run([hw_kernel(p, wave) for p in progs]) | 695 | hw = oracle.run([hw_kernel(p, wave) for p in progs]) |
| 681 | if len(hw) != len(progs): | 696 | check_hw_rows(hw, len(progs)) |
| 682 | raise RuntimeError(f"the hardware runner returned {len(hw)} results for {len(progs)} programs") | ||
| 683 | else: | 697 | else: |
| 684 | hw = [None] * programs | 698 | hw = [None] * programs |
| 685 | vk_failures = [] | 699 | vk_failures = [] |