GPU: the rectangle fallback's f16 narrowing keeps NaN and rounds ties to even #326

Open
github-bot wants to merge 1 commit from github-bot/gh-326 into main AGit
Owner

@⁠RenzoWit35 on GitHub · 2026-11-24 23:34 UTC · original
RenzoWit35:fix/245-rect-f16-nan-and-ties → main · +120 −3 · 1 files · 1 commits · open

Fixes #245.

f32_to_half in the CPU rectangle expansion sent NaN through the overflow branch (giving
infinity, 0x7c00) and rounded exact ties up (1 + 2^-11 gave 0x3c01). NaN now returns a quiet
NaN that keeps the sign (sign | 0x7e00), and normal values round ties to even like the
subnormal path already did. A rounding carry still moves into the exponent, and overflow still
gives infinity.

Tests: the issue's tie and NaN corners through expand_rects; NaN payloads, including one only
in the dropped bits; and a hand-written ties-to-even reference compared against every half
value, every halfway point and its neighbours, and a strided f32 sweep. All failed before.

Testing

On Windows 11, MSVC Rust 1.98.1, branch alone on top of main (2119b0e): cargo clippy --workspace --all-targets --locked -- -D warnings, the same with --all-features, and cargo test --workspace --locked all pass. The new regression test fails on main and passes here. All nine fix branches for #242-#250 also pass together when merged.

🤖 Generated with Claude Code

**@⁠RenzoWit35** on GitHub · 2026-11-24 23:34 UTC · [original](https://github.com/fxceless/victory-fork/pull/326) `RenzoWit35:fix/245-rect-f16-nan-and-ties` → `main` · +120 −3 · 1 files · 1 commits · open Fixes #245. `f32_to_half` in the CPU rectangle expansion sent NaN through the overflow branch (giving infinity, 0x7c00) and rounded exact ties up (`1 + 2^-11` gave 0x3c01). NaN now returns a quiet NaN that keeps the sign (`sign | 0x7e00`), and normal values round ties to even like the subnormal path already did. A rounding carry still moves into the exponent, and overflow still gives infinity. Tests: the issue's tie and NaN corners through `expand_rects`; NaN payloads, including one only in the dropped bits; and a hand-written ties-to-even reference compared against every half value, every halfway point and its neighbours, and a strided f32 sweep. All failed before. ## Testing On Windows 11, MSVC Rust 1.98.1, branch alone on top of `main` (2119b0e): `cargo clippy --workspace --all-targets --locked -- -D warnings`, the same with `--all-features`, and `cargo test --workspace --locked` all pass. The new regression test fails on `main` and passes here. All nine fix branches for #242-#250 also pass together when merged. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The CPU rectangle expansion narrows the generated fourth corner of an
R16_FLOAT element from f32. A NaN took the overflow path and became
infinity, and normal values exactly halfway between two halves always
rounded up (1 + 2^-11 gave 0x3c01, not 0x3c00). NaN now becomes a quiet
NaN with its sign, and normal values round ties to the even mantissa as
the subnormal path already did; overflow still gives infinity.

Tests: the tie and a quiet NaN corner through expand_rects, NaN payloads
only in dropped bits, and a check against a search-based ties-to-even
reference over every half, every halfway point and its neighbours, and a
sweep of f32 values.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:40:47 +00:00
Author
Owner

@⁠kaayzouee on GitHub · 2026-11-25 00:58 UTC · original

Duplicate of #315?

**@⁠kaayzouee** on GitHub · 2026-11-25 00:58 UTC · [original](https://github.com/fxceless/victory-fork/pull/326#issuecomment-7149081972) Duplicate of #315?
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/326/head:github-bot/gh-326'
git switch 'github-bot/gh-326'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-326'
git switch 'github-bot/gh-326'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-326'
git switch 'github-bot/gh-326'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-326'
git switch 'main'
git merge --squash 'github-bot/gh-326'
git switch 'main'
git merge --ff-only 'github-bot/gh-326'
git switch 'main'
git merge 'github-bot/gh-326'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.