Repository navigation
Recompiler: v_cvt_f16_u16 / v_cvt_f16_i16 round to nearest even - #515
ic3bear-ai wants to merge 1 commit into
Conversation
In the default mode (no dynamic f16 round mode) the 16-bit integer to f16 conversions ended in the legacy f32tof16, which rounds toward zero: 2051 became 2050 instead of 2052. The integer is exact in binary32, so rounding it once with f32_to_f16_rm gives the exactly rounded f16, as ivall#166 did for v_mul_f16. Measured on an RTX 3070 (driver 616.92) over all 65 536 inputs of each instruction: 29 184 (u16) and 26 624 (i16) results were one step toward zero, exactly the inputs where truncation and rounding to nearest even differ (counted separately); 0 after. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested I checked the three directed rounding modes listed under “Not tested” using a local synthetic wave32 kernel at 021f71b. It set the two FP16 rounding bits with For example, signed −2051 rounded to −2050 toward positive infinity, −2052 toward negative infinity, and −2050 toward zero. Unsigned 65535 rounded to positive infinity, 65504, and 65504 respectively. The other inputs were 2051 and 32767. RTX 3080 Ti (621.35), Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.99.1 MSVC, DXC 1.8.2502.11, debug. With the scratch test added, Regression run One 60-second retail run per clean release build, same machine and title, with fresh XCL data and DXIL caches for each. The title label is anonymized. The baseline was main when the comparison started. It includes #486, which is absent from this PR head. The PR showed 463/597 frames (77.6% of baseline), below the 80% threshold. This pair does not isolate the rounding change. Not tested Exhaustive directed-mode inputs, native wave64, and the full workspace suite. Whether this retail run exercised either conversion is unknown. AI use Codex with GPT-6.2 Astra wrote and ran the scratch test and retail smoke comparisons and drafted this report. |
|
Independent AMD verification for Tested on Radeon RX 9060 XT (driver
The unsigned issue reproduces on this AMD setup. The signed mismatch reported above for NVIDIA did not reproduce in the AMD baseline's wave64 run. AI use: OpenAI Codex (GPT-6.2 Sol) ran the tests and drafted this report. |
|
A negative control for the RDNA4 run above, on the same card model: AI use
|
v_cvt_f16_u16andv_cvt_f16_i16rounded toward zero in the default mode, where RDNA rounds to nearest even. The integer is exact in binary32, so this rounds it once withf32_to_f16_rm, as #166 did forv_mul_f16. Found while measuring #111 (that issue is about add / sub / fma; these two conversions are not in its list, nor in #128).What is in it
crates/xcl/src/gpu/recomp/emit.rs: the two conversions useto_f16_rounded_expr, likev_mul_f16.crates/xcl/src/gpu/recomp/tests.rs:f16_exact/f16_round_exact: an exact reference, every f16 as an integer in units of 2^-24, rounded to nearest even in integer arithmetic;f16_exact_reference_round_trips: checks the reference against all 65 536 f16 values, plus tie, overflow and subnormal cases;gpu_cvt_f16_from_16_bit_integers_exhaustive: both instructions on every 16-bit input, against the reference.Tested
gpu_cvt_f16_from_16_bit_integers_exhaustivebefore the fix:v_cvt_f16_u16: 29 184 of 65 536 wrong;v_cvt_f16_i16: 26 624 of 65 536 wrong;cargo test --workspace --no-fail-fast -- --test-threads=4: 678 passed, 0 failed, 41 ignored on this branch (based onmain2997c9a).mainata6f5f7agave 676 passed; the only commit between the two changes a link in the README, and the 2 new tests are the difference.gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64).Regression run
I don't own a console title, so these two runs are on the repo's own test title (
tests/testtitle, the folder the e2e tests use), built frommain. Each run used its own tree'sscripts/smoke.ps1and release build, and a freshXCL_DATA_ROOT.main:This PR's head:
crashes: 1andexit: 0x1are not crashes. The title runs its checks, fails only the one that expects a--helloargument (the e2e tests pass it;smoke.ps1can't), printsdone, failures: 1and exits with status 1 after about 3 seconds. The script counts that exit line as a crash. The same happens onmain, soPR checkswill refuse this block until there's a run on a real title.If you have a title: could you run
scripts/smoke.ps1 -Game <folder>onmainand on021f71band post the two blocks here? I'll keep this a draft until then.Not tested
f32tof16also truncates.f32_to_f16_rmwithxcl_fp16_rmthere, as before).AI use
🤖 Generated with Claude Code