[PR #1546] bvh_tri_probe: fix skipped-kernel compare/exit, check_kernel stores, and atomic I/O (BVH-TRI-PROBE-COMPARE-CHECK-AND-IO) #1573

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

📋 Pull Request Information

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

Base: main ← Head: fix/bvh-tri-probe-compare-and-io


📝 Commits (1)

  • 4cc96d1 bvh_tri_probe: fix skipped-kernel compare/exit, check_kernel stores, and atomic I/O

📊 Changes

2 files changed (+206 additions, -25 deletions)

View changed files

📝 tests/test_bvh_tri_probe.py (+115 -1)
📝 tools/bvh_tri_probe.py (+91 -24)

📄 Description

What

Fix comparison, safety-check, architecture-skip, and file-output bugs in tools/bvh_tri_probe.py without changing any kernel assembly lines (PINNED hashes are unchanged):

  1. Skipped hardware kernels vacuously reported as "OK" (compare, main):
    • When run_hw() skips a kernel (e.g., 8192-word lane kernels under Linux DRM's 4096-word limit) and the translator backend is not enabled, vals in compare() is empty, so all(v == want for v in vals) vacuously evaluated to True, marking 448–896 skipped rows "OK" and counting them as matches.
    • Mark rows with no backend results as "SKIP", report skipped counts separately in main()'s summary ({matched} match, {bad} mismatch, {skipped} skipped), and exit 77 when every selected row was skipped.
  2. Safety-checker gaps in check_kernel():
    • Raise ValueError (instead of raw StopIteration) on an empty k.cases list and guard guard < 2 before slicing lines[guard - 2:guard].
    • Validate every global_store* instruction (including implicit offset:0 stores without an offset: suffix), use the instruction's actual byte width (previously s[24:25] hardcoded + 4, missing global_store_dwordx4 overflows past ctl + 16), reject negative offsets (off < 0), and reject unknown store ops/bases with ValueError instead of raw KeyError.
  3. Unsupported GPU architecture skip (main):
    • Catch ValueError from asm.family(oracle.arch) (e.g. gfx900) so --oracle hw prints SKIP: <arch> is not GFX10 (RDNA1/RDNA2) and returns 77 as documented instead of crashing with an uncaught traceback.
  4. CLI validation & atomic LF-only output (write_kernels, main):
    • Validate --write-kernels against empty/whitespace strings and existing non-directory paths with error: ... and exit 2 (previously --write-kernels "" was silently ignored and an existing file raised FileExistsError), and catch (OSError, ValueError) cleanly.
    • Write .s, .json, and --json outputs atomically via a sibling temp file (newline="\n", file_mode.published_mode, replace_retry.replace, allow_nan=False) and terminate per-kernel .json files with "\n".

Claimed in the coordination issue as

BVH-TRI-PROBE-COMPARE-CHECK-AND-IO — verified 0 open PRs and 0 prior claims; unable to post a comment on #14 because GitHub disabled commenting once #14 reached its 2,500-comment cap (and no successor "Coordinating who works on what" issue is open yet).

Testing

  • python3 -I -W error tests/test_bvh_tri_probe.py -v: 22/22 OK (including all 5 PINNED kernel SHA-256 checks and 5 new/extended regression tests).

  • python3 -I tools/bvh_tri_probe.py --self-test: OK (22 kernels, 564 single-lane cases, 2 x 7 lane cases).

  • python3 -I tests/test_text_write_line_endings.py: 3/3 OK.

  • python3 -I scripts/check_no_game_data.py tools/bvh_tri_probe.py tests/test_bvh_tri_probe.py: clean.

  • python3 -m compileall -q tools/bvh_tri_probe.py tests/test_bvh_tri_probe.py: clean.

  • Mutation check against unpatched main:tools/bvh_tri_probe.py: all 6 new/extended tests fail on main (FAILED (failures=3, errors=3)).

  • AI-assisted: yes

  • GPUs tested: none (CPU-only tests with stand-in oracle on macOS; no GPU or game files needed)


🔄 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/1546 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/bvh-tri-probe-compare-and-io` --- ### 📝 Commits (1) - [`4cc96d1`](https://github.com/ubiquitarianism/leonida/commit/4cc96d17230581dd8153af0908af8d8d9d1024ba) bvh_tri_probe: fix skipped-kernel compare/exit, check_kernel stores, and atomic I/O ### 📊 Changes **2 files changed** (+206 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_bvh_tri_probe.py` (+115 -1) 📝 `tools/bvh_tri_probe.py` (+91 -24) </details> ### 📄 Description ## What Fix comparison, safety-check, architecture-skip, and file-output bugs in `tools/bvh_tri_probe.py` without changing any kernel assembly lines (`PINNED` hashes are unchanged): 1. **Skipped hardware kernels vacuously reported as `"OK"` (`compare`, `main`)**: - When `run_hw()` skips a kernel (e.g., 8192-word lane kernels under Linux DRM's 4096-word limit) and the translator backend is not enabled, `vals` in `compare()` is empty, so `all(v == want for v in vals)` vacuously evaluated to `True`, marking 448–896 skipped rows `"OK"` and counting them as matches. - Mark rows with no backend results as `"SKIP"`, report skipped counts separately in `main()`'s summary (`{matched} match, {bad} mismatch, {skipped} skipped`), and exit `77` when every selected row was skipped. 2. **Safety-checker gaps in `check_kernel()`**: - Raise `ValueError` (instead of raw `StopIteration`) on an empty `k.cases` list and guard `guard < 2` before slicing `lines[guard - 2:guard]`. - Validate **every** `global_store*` instruction (including implicit `offset:0` stores without an `offset:` suffix), use the instruction's actual byte width (previously `s[24:25]` hardcoded `+ 4`, missing `global_store_dwordx4` overflows past `ctl + 16`), reject negative offsets (`off < 0`), and reject unknown store ops/bases with `ValueError` instead of raw `KeyError`. 3. **Unsupported GPU architecture skip (`main`)**: - Catch `ValueError` from `asm.family(oracle.arch)` (e.g. `gfx900`) so `--oracle hw` prints `SKIP: <arch> is not GFX10 (RDNA1/RDNA2)` and returns `77` as documented instead of crashing with an uncaught traceback. 4. **CLI validation & atomic LF-only output (`write_kernels`, `main`)**: - Validate `--write-kernels` against empty/whitespace strings and existing non-directory paths with `error: ...` and exit `2` (previously `--write-kernels ""` was silently ignored and an existing file raised `FileExistsError`), and catch `(OSError, ValueError)` cleanly. - Write `.s`, `.json`, and `--json` outputs atomically via a sibling temp file (`newline="\n"`, `file_mode.published_mode`, `replace_retry.replace`, `allow_nan=False`) and terminate per-kernel `.json` files with `"\n"`. ## Claimed in the coordination issue as `BVH-TRI-PROBE-COMPARE-CHECK-AND-IO` — verified 0 open PRs and 0 prior claims; unable to post a comment on `#14` because GitHub disabled commenting once `#14` reached its 2,500-comment cap (and no successor `"Coordinating who works on what"` issue is open yet). ## Testing - `python3 -I -W error tests/test_bvh_tri_probe.py -v`: **22/22 OK** (including all 5 `PINNED` kernel SHA-256 checks and 5 new/extended regression tests). - `python3 -I tools/bvh_tri_probe.py --self-test`: OK (`22 kernels, 564 single-lane cases, 2 x 7 lane cases`). - `python3 -I tests/test_text_write_line_endings.py`: **3/3 OK**. - `python3 -I scripts/check_no_game_data.py tools/bvh_tri_probe.py tests/test_bvh_tri_probe.py`: clean. - `python3 -m compileall -q tools/bvh_tri_probe.py tests/test_bvh_tri_probe.py`: clean. - Mutation check against unpatched `main:tools/bvh_tri_probe.py`: all 6 new/extended tests fail on `main` (`FAILED (failures=3, errors=3)`). - AI-assisted: yes - GPUs tested: none (CPU-only tests with stand-in oracle on macOS; no GPU or game files needed) --- <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#1573
No description provided.