[PR #1676] sampler_lod_probe: validate oracle payloads, non-finite calibration starts, and run errors #1692

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

📋 Pull Request Information

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

Base: main ← Head: fix/sampler-lod-probe-oracle-and-calibration


📝 Commits (1)

  • 299325c sampler_lod_probe: validate oracle payloads, non-finite calibration starts, and run errors

📊 Changes

2 files changed (+101 additions, -4 deletions)

View changed files

📝 tests/test_sampler_lod_probe.py (+73 -0)
📝 tools/sampler_lod_probe.py (+28 -4)

📄 Description

Item ID: SAMPLER-LOD-PROBE-ORACLE-AND-CALIBRATION (claimed in https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156290731)

Summary

  • Hardware oracle payload validation (tools/sampler_lod_probe.py):
    • Validate that oracle.run([k]) returns a list/tuple of length 1, and that its non-string element is a list/tuple of exact length len(table) containing only non-bool int words (masking w & 0xFFFFFFFF before struct.pack("<I", ...)), returning exit 2 with a clear diagnostic instead of crashing with uncaught IndexError/TypeError/struct.error or accepting extra/bool words.
  • Calibration finiteness & runtime error lifecycle:
    • Reject non-finite (inf/NaN) calibration level starts with exit 2 instead of accepting +inf as a valid level start when wave32 and wave64 agree.
    • Catch runner.Unavailable (exit 77) and RuntimeError (exit 2) raised during oracle.run() inside try ... finally: oracle.close().
  • Regression tests (tests/test_sampler_lod_probe.py):
    • Added tests covering malformed batch/word payloads across wave32 and wave64, +inf calibration start rejection, runner.Unavailable during run() -> exit 77, and RuntimeError during run() -> exit 2, verifying oracle.close() on every path.

Checklist & Verification

  • AI-assisted: yes
  • Game data included: none (python3 -I scripts/check_no_game_data.py tools/sampler_lod_probe.py tests/test_sampler_lod_probe.py passed)
  • GPUs tested: none (hostless macOS synthetic/unit test run)
  • Tests run:
    • python3 -W error -I tests/test_sampler_lod_probe.py -v: Ran 15 tests ... OK
    • Mutation test (new tests/test_sampler_lod_probe.py against unpatched main tools/sampler_lod_probe.py): Ran 15 tests ... FAILED (failures=9, errors=10)
    • python3 -m compileall -q make_game.py tools tests: passed
    • python3 -I tests/test_text_write_line_endings.py: Ran 3 tests ... OK

🔄 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/1676 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/sampler-lod-probe-oracle-and-calibration` --- ### 📝 Commits (1) - [`299325c`](https://github.com/ubiquitarianism/leonida/commit/299325cb202ddd263ff488b24f0fc374d8e58398) sampler_lod_probe: validate oracle payloads, non-finite calibration starts, and run errors ### 📊 Changes **2 files changed** (+101 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_sampler_lod_probe.py` (+73 -0) 📝 `tools/sampler_lod_probe.py` (+28 -4) </details> ### 📄 Description Item ID: `SAMPLER-LOD-PROBE-ORACLE-AND-CALIBRATION` (claimed in https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156290731) ## Summary - **Hardware oracle payload validation (`tools/sampler_lod_probe.py`)**: - Validate that `oracle.run([k])` returns a `list`/`tuple` of length `1`, and that its non-string element is a `list`/`tuple` of exact length `len(table)` containing only non-bool `int` words (masking `w & 0xFFFFFFFF` before `struct.pack("<I", ...)`), returning exit `2` with a clear diagnostic instead of crashing with uncaught `IndexError`/`TypeError`/`struct.error` or accepting extra/bool words. - **Calibration finiteness & runtime error lifecycle**: - Reject non-finite (`inf`/`NaN`) calibration level starts with exit `2` instead of accepting `+inf` as a valid level start when wave32 and wave64 agree. - Catch `runner.Unavailable` (exit `77`) and `RuntimeError` (exit `2`) raised during `oracle.run()` inside `try ... finally: oracle.close()`. - **Regression tests (`tests/test_sampler_lod_probe.py`)**: - Added tests covering malformed batch/word payloads across wave32 and wave64, `+inf` calibration start rejection, `runner.Unavailable` during `run()` -> exit `77`, and `RuntimeError` during `run()` -> exit `2`, verifying `oracle.close()` on every path. ## Checklist & Verification - **AI-assisted**: yes - **Game data included**: none (`python3 -I scripts/check_no_game_data.py tools/sampler_lod_probe.py tests/test_sampler_lod_probe.py` passed) - **GPUs tested**: none (hostless macOS synthetic/unit test run) - **Tests run**: - `python3 -W error -I tests/test_sampler_lod_probe.py -v`: `Ran 15 tests ... OK` - Mutation test (new `tests/test_sampler_lod_probe.py` against unpatched `main` `tools/sampler_lod_probe.py`): `Ran 15 tests ... FAILED (failures=9, errors=10)` - `python3 -m compileall -q make_game.py tools tests`: passed - `python3 -I tests/test_text_write_line_endings.py`: `Ran 3 tests ... OK` --- <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#1692
No description provided.