GPU: f32_to_half keeps NaN and rounds ties to even (fixes #843) #1069
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1069"
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 Marvisak/VIctory. Originally posted by acleofe on 2026-11-24T15:27:53Z.
What
f32_to_half(used for F16 elements when rectangle lists are expanded) converts NaN to a quiet half NaN, keeping the payload's top bits, and rounds normal values to nearest with ties to even:(man + 0xfff + ((man >> 13) & 1)) >> 13in place of(man + 0x1000) >> 13.Why
exp >= 31branch and came out as infinity.+ 0x1000rounds a value exactly halfway between two halves away from zero; IEEE 754 and the GPU round to the even one. The subnormal branch already rounded to even.Test
halves_keep_nan_and_round_ties_to_even: NaN, -NaN and the smallest NaN payload stay NaN; infinities stay;1 + 2^-11gives0x3c00,1 + 3·2^-11gives0x3c02, just past halfway rounds up. Fails before this change.cargo clippy --workspace --all-targets [--all-features] --locked -- -D warningsandcargo test --workspace --lockedpass.🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T16:30:01Z.
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
5f026f3:cargo test -p victory-gpupasses, 51 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
upstream-sync referenced this pull request2026-11-25 04:06:50 +00:00
Pull request closed