Recompiler: round f16 conversions and products to nearest-even by default #166
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!166
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/166/head"
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?
@ebarr24 on GitHub · 2026-11-23 18:23 UTC · original
ebarr24:fix/recomp-default-f16-rounding→main· +65 −5 · 2 files · 1 commits · merged 2026-11-23 20:51 UTCThe default RDNA binary16 rounding mode is round-to-nearest-even. XCL has used legacy HLSL
f32tof16for that path, which narrows toward zero. On the RTX 3080, converting3075.0gives0x6A01instead of0x6A02, and converting65520.0gives0x7BFFinstead of infinity. Direct3D conversion rules, sections 3.2.2 and 22.13.2Use the existing
f32_to_f16_rmhelper forv_cvt_f16_f32,v_mul_f16, andv_pk_mul_f16, with a constant nearest-even mode when the shader leaves the default in place. The finite product of two binary16 inputs fits exactly in binary32, so one narrowing is sufficient. The regression covers midpoint and adjacent values, negative input, overflow, a subnormal and scalar and packed multiplication with midpoint products.Issue #111 tracks the exact product and sum needed for a single-rounding FMA. Rounding issue #111 · CPU reproduction
Verification
Windows 11 25H2 (26200.9711), Rust 1.100.0
x86_64-pc-windows-gnu, RTX 3080 (driver 616.92), DXC 1.9.2609.5.db5dc26.deccf2bthe expanded conversion, scalar product and packed product regression passes. The full workspace run on10f25f4, with #157, #158 and #160 applied alongside this patch, reported 571 passes, zero failures and 39 ignored. Two native-wave64 tests and the unconfigured retail-sample tests returned early.mainat956a476.AI-assisted patch preparation and verification.
@WarmMilkCodes on GitHub · 2026-11-23 18:55 UTC · original
Tested #166
deccf2bmerged onto main956a476on AMD Radeon RX 6600 XT (RDNA2), driver 32.0.21045.29003, Windows 11 23H2 (22631.6199): passcargo test --workspace --no-fail-fast -- --test-threads=4, noXCL_SAMPLE_*data:No new failures vs main. The PR's new test passes on RDNA2. The one failure on both,
gpu_wave64_ps_whole_wave_reductions, is the 32-lane PS case on this card (#155).@TheHoracio on GitHub · 2026-11-23 19:28 UTC · original
Tested on AMD RDNA3: Radeon RX 7800 XT (16 GB, wave 32–64), driver 32.0.32015.7029, Windows 11 Pro 10.0.26300, Rust 1.100.0
x86_64-pc-windows-msvc, DXC 1.9.2602.17. The PR headdeccf2bwas tested as is, with no other PRs applied.cargo test --workspace --no-fail-fast: 568 passed, 1 failed, 39 ignored, 0SKIPPED.gpu_f16_defaults_to_round_to_nearest_evenpasses on AMD as well. The existing f16 rounding tests also pass:gpu_s_round_mode_controls_f16_rounding_across_modes,gpu_mad_nf_f16_rounds_intermediate_in_binary16,gpu_cvt_norm_f16_exact_rounding_and_edge_cases,gpu_cmp_class_f16_preserves_snan.gpu_wave64_ps_whole_wave_reductions. It fails the same way onmain956a476on this GPU and is fixed by #155 (see my comment there). It is unrelated to this PR.@Kalmarv on GitHub · 2026-11-23 20:34 UTC · original
Additional default-mode check on the RTX 5070 Ti (driver 610.74, Windows x64 MSVC, Rust 1.99.0): I tested PR head
deccf2ba3c0f09023bc9ccf2f49cb5af8aae798fdirectly, and carried its test plus a 14-lane synthetic conversion probe to main956a476bf738a098f39df4f4c8acef682e43030f.387fe000(midpoint between the largest subnormal and smallest normal)03ff04003f801000,3f803000(successive midpoints)3c00,3c013c00,3c0233000000,33000001,b30000010000,0000,80000000,0001,8001The tie results agree with half-precision round mode 0. The NaN assertion checked the quiet-NaN class only. AMD RDNA 2 ISA, §6.4 and V_CVT_F16_F32
Of seven recompiler tests matching
f16, five passed on main and all seven passed on the head. The failures were the verbatim PR regression (including scalar and packed products) and the added conversion probe. Each dispatched synthetic shaders. No retail shaders, merge build, or explicit denorm-mode sweep. AI-assisted review.@ivall on GitHub · 2026-11-23 20:52 UTC · original
Merged (main
2abc562). Checked on an RX 9070 (RDNA4) with the 11 PRs merged together on main38b05b7:cargo build --workspace && cargo test --workspace -- --test-threads=4- 547 unit tests passed, 0 failed (19 ignored); the integration and e2e tests passed too.