mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:30:52 +01:00
[PR #2303] f16_ref: preserve signed zero in to_f16/scale and mask 16-bit inputs #2306
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#2306
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/2303
Author: @kirigayakazima
Created: 11/26/2026
Status: 🔄 Open
Base:
main← Head:fix/f16-ref-safety📝 Commits (1)
95b1cb7f16_ref: preserve signed zero in to_f16/scale and mask 16-bit inputs📊 Changes
2 files changed (+66 additions, -1 deletions)
View changed files
📝
tests/semantic/f16_ref.py(+17 -1)➕
tests/test_f16_ref.py(+49 -0)📄 Description
Claimed in the coordination issue as: F16-REF-NEGATIVE-ZERO-SIGN-AND-MASK-SAFETY (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7193007298)
What and why
0x8000) into_f16()when passedfloat(-0.0)soscale(0x0000, -1.0)andscale(0x8000, 1.0)no longer collapse-0.0throughFraction(-0.0)into+0.0(0x0000).& 0xFFFF) consistently acrossis_nan(),same_f16(),ref_add(),ref_sub(),ref_mul(),ref_fma(),neg(),scale(), andclamp01()intests/semantic/f16_ref.py(so upper word bits cannot leak throughneg(),scale(),clamp01(), or break-0.0/same_f16()equality checks).tests/test_f16_ref.py.Tested
python -I tests/test_f16_ref.py -v: 3 passed, 0 failed (detachedupstream/mainbaseline with only the new test file fails with 3 failures).f16_ref-using semantic suites (test_alu_min3_max3_med3_16,test_alu_round,test_interp_guards,test_interp_p1lv_f16,test_valu_add_f16,test_valu_fma_f16,test_valu_mul_f16,test_valu_pk_add_f16,test_valu_pk_fma_f16,test_valu_pk_minmax_f16,test_valu_pk_mul_f16,test_valu_sub_f16,test_valu_subrev_f16): 162 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_ref.py tests/test_f16_ref.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.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.