F16-UNARY-CASES-16BIT-MASKING-AND-REF-TESTS #2347
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2347"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-26T14:24:45Z.
Claimed in the coordination issue as: F16-UNARY-CASES-16BIT-MASKING-AND-REF-TESTS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7194729737)
What and why
h &= 0xFFFFat the entry ofref_rcp,ref_sqrt,ref_rsq, andref_fractintests/semantic/f16_unary_cases.pyso upper bits in 32-bit test words do not leak past NaN checks (0x17E01 | 0x7E00) or bypass the+inf/-0exact comparisons (0x17C00triggeringOverflowErrorinFraction(...)).exact_sqrt_ratio(num, den, k=64)domain parameters up front (num >= 0,den > 0,k >= 0, rejecting booleans and non-integers withValueError).tests/test_f16_unary_cases.py.Tested
python -I tests/test_f16_unary_cases.py -v: 3 passed, 0 failed (detachedupstream/mainbaseline with only the new test file fails: 9 failures, 3 errors across subtests).test_valu_fract_f16,test_valu_pack_b32_f16,test_valu_rcp_f16,test_valu_rsq_f16,test_valu_sqrt_f16): 46 passed, 0 failed.python -I tests/test_ci_registration.py: 16 passed.python -I tests/test_text_write_line_endings.py: 3 passed.python -I scripts/check_no_game_data.py,python -I -m compileall -q tests/semantic/f16_unary_cases.py tests/test_f16_unary_cases.py, andgit diff --cached --check: passed.GPUs tested: n/a
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.Imported from ubiquitarianism/leonida. Originally posted by wavehs on 2026-11-26T18:35:12Z.
Review: COMMENTED
macOS arm64 check of #2347 (F16-UNARY-CASES-16BIT-MASKING-AND-REF-TESTS). A test-harness change only: no translator, runtime or GPU code.
Tested head
fe131376fwith its diff applied to a copy ofmainbdbc7e923(the branch is 82 commits behind;git applyandgit merge-treeare clean).Environment: Apple M3 Pro, arm64, macOS 27.2.1, CPython 3.15.2.
Result
python -I tests/test_f16_unary_cases.py: 3 tests, OK.test_valu_fract_f16.py,test_valu_pack_b32_f16.py,test_valu_rcp_f16.py,test_valu_rsq_f16.py,test_valu_sqrt_f16.py- all OK.tests/semantic/f16_unary_cases.pyput back tomain's): the failures and errors the description predicts -ref_rcp/ref_sqrt/ref_rsqon words with upper bits set (0x17E01,0x17C00), and theexact_sqrt_ratioarguments(0, 0),(1, 0),(True, 1),(1, True),(1, 1, False)no longer raising. So both halves of the change are pinned.python -I scripts/run_semantic_tests.py tests/semantic: 500 files / 6,367 tests / 0 failed, the same asmain(the new test file is intests/, nottests/semantic/).runtime/,tools/rdna2spirv.pyorscripts/run_gpu_tests.pychanges, and the semantic f16 suites usespirv_mini_interp, not a device. This is a harness fix, not a shader-rule change.Review
ref_rcp,ref_sqrt,ref_rsq,ref_fract) mask at entry, and the file has no otherref_*helper, so the sweep is complete.run()still seeds each source withhi=0x5A5Aabove the 16-bit word, so a translator that reads the wrong half still fails the comparison; the reference now models the same low-half read the hardware does.exact_sqrt_ratio's callers passFraction.numerator/.denominator(Python ints), so rejecting bools and non-ints cannot break the existing suites; I checked the two call sites atf16_unary_cases.py:75,89.exact_sqrt_ratiochecks are the only place aValueErroris raised for a bad domain; no caller catches it, which is right for a test helper.No functional issue found. The one thing I would carry into a follow-up is a short comment on
run()'shi=0x5A5Apointing at the masking rule, because the two only make sense together and a future edit could remove the seed padding without noticing.No game files. AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-26T20:43:14Z.
Review: COMMENTED
On Windows 11 with CPython 3.12.1, all three direct reference tests and all 46 related semantic tests passed across
fract,pack_b32,rcp,rsqandsqrt.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-27T04:43:06Z.
Review: APPROVED
Approving
fe131376f.The
f16_unary_caseshelpers now mask their inputs to 16 bits and refuse non-integer or negative arguments. Sincef16_unary_casesandf16_refare references the translator tests compare against, I also ran every semantic test that imports either one on this batch: 208 passed (5,662 subtests).Merged onto
maind1dff7949in one batch with 15 other tool PRs of this series (no conflicts), on Linux with Python 3.13.tests/test_f16_unary_cases.py: 3 passed (new). AI-assisted (Claude Code, Claude Opus 5.5).Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T10:23:48Z.
#2347 | head
fe131376f5(merged cleanly with main901b6c1bf) |python -I tests/test_f16_unary_cases.py && python -I scripts/run_semantic_tests.py -p "test_*f16*.py" tests/semantic| red on main:FAILED (failures=9, errors=3)(unmasked upper bits above bit 15 inref_rcp/ref_sqrt/ref_rsq/ref_fractand unguardedexact_sqrt_ratiodomain/bool inputs) | green on PR+main:3 tests OKand55 files, 575 tests, 0 files failed| Windows 11, Python 3.12.10 | AI-assisted: yesAudited
exact_sqrt_ratioandref_rcp/ref_sqrt/ref_rsq/ref_fractintests/semantic/f16_unary_cases.pyplustests/test_f16_unary_cases.py. Verified both standalone and merged together with #2303 (tests/semantic/f16_ref.py):0merge conflicts and all unit, semantic (575/575),tests/test_ci_registration.py(18 OK),tests/test_text_write_line_endings.py(3 OK),tests/test_runner_calls_all_tests.py(3 OK), andscripts/check_no_game_data.pychecks pass.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T15:12:01Z.
Red/green: classified READY by oreo-lot3 (red on main
b1619e0a3, green on head merged with main); headfe131376f5unchanged since 2026-11-26, before that run.Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main
d48a957bbin GitHub Actions: no new failure.AI-assisted (Claude Code, Claude Opus 5.5)