Repository navigation
fix(shader): quiet NaN results of native scalar f16 add, sub and mul with IEEE_MODE - #20099
Conversation
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — comments
The native scalar f16 path now quiets NaN results when IEEE_MODE is set; the remaining review feedback concerns the new test’s coverage of modifiers.
What I ran
Reviewed head 4f4d7c0e024d07ff53e1782af21346c2e0fb144f from the prepared diff and pinned reader. No commands or tests were run.
Results
| Check | Result | Note |
|---|---|---|
| Diff and changed source review | passed | Three changed files read |
| Runtime tests | not run | Author reports tests; not independently verified |
Findings
Blocking
None.
Non-blocking
Float16Native.cpp:230only checks whether the result is quiet, and excludes indices4..10. That means the regression assertion does not verify quieting for those operation forms (including FMA forms, which the description says are intentionally outside this fix). Consider documenting the index-to-operation mapping or limiting the assertion explicitly to the changed add/sub/subrev/mul forms. As written, the condition is difficult to audit and could omit a changed form if the result ordering changes.
Not verified
- No test or build command was run; reported hardware results and CI claims were not independently verified.
- The changed files read were
core/libs/prx/libSceAgcDriver/tests/execution/Float16Native.cpp,core/shader/recompiler/Translation/src/FloatInstructions.cpp, anddocs/dev/debt/shader.md. All three files listed as reviewed in the manifest were read; no files were excluded. - Linux, lavapipe, NVIDIA, a device with
VK_KHR_shader_fma, and console gfx1013 behavior were not tested in this review.
To get this to a good state
Nothing is required. Optional: make the tested operation-index range self-documenting so it stays aligned with the intended add/sub/subrev/mul coverage.
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Cross-HW verified on real AMD RADV across three generations (Mesa 26.2.6, validation layer 1.4.363), head
All three advertise Float16 + RoundingModeRTE + DenormPreserve, so the native Negative control (gen-independent, run on Vega): with the pre-fix The per-lane source AI-assisted: yes |
…with IEEE_MODE With IEEE_MODE set, RDNA2 quiets a signaling NaN source of v_add_f16, v_sub_f16, v_subrev_f16 and v_mul_f16 (measured on gfx1035). The native f16 path returned the driver's NaN unchanged, which can be signaling; it now sets the quiet bit of a NaN result. The native fma forms are not changed: no device here has VK_KHR_shader_fma to test them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4f4d7c0 to
797dbc6
Compare
|
@MarcZX10 AI-assisted: yes. |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
Nothing blocks this change; the focused code review found no verified defect.
What I ran
Reviewed head 797dbc6479e5628d703c7ee744f0b87dcb0246c6. I inspected the prepared description, commit list, manifest and diff, then read all three changed files at the pinned head. No commands or tests were run.
Results
| Check | Result | Note |
|---|---|---|
| Diff and changed code | passed | All three changed files read |
| Tests | not run | Author-reported results were not rerun |
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not run the reported Windows hardware tests, the broader test selection, convention checks, or merge simulation. Linux, lavapipe, NVIDIA, FMAKHR hardware and gfx1013 behavior remain unverified as stated in the description. All files listed under reviewed in the manifest were read; no changed files were excluded.
To get this to a good state
Nothing is required.
|
Windows + NVIDIA (Blackwell) run of head Setup: Windows 11 Pro, NVIDIA GeForce RTX 5070 Ti, driver 621.01, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 UCRT, Release,
The startup probe on this driver reports AI-assisted: yes |
|
Ran the focused tests with the Khronos validation layer on Linux and an NVIDIA GPU, since CI runs the GPU tests only on lavapipe, the Tested section is on an AMD 680M and the NVIDIA run in the comments is on Windows. Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, NVIDIA GeForce RTX 4090 (vendor
All four tests from the Tested section pass on both sides; Negative control: with main's No new AI-assisted: yes (Claude Code) |
|
Tested head Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release,
Whole batch: the full This is one combined tree, not a run of this PR alone. AI-assisted: yes (Claude Code) |
|
Tested on Intel Arc B390 (Mesa 26.2.7 ANV, Linux 7.2.10), PR head
AI-assisted: yes (Claude Code) |
|
GPU run on RDNA4 (gfx1201) with the AMD Windows driver and the validation layer. The rule the change applies holds on gfx1201: every NaN result of What this run adds.
Code.
Evidence.
Negative control and mutation.
GPU. Head
Validation.
Host:
AI-assisted: yes |
What
With
IEEE_MODEset, the native scalar f16 path (float16NativeinFloatInstructions.cpp, used when the device has Float16, RTE and DenormPreserve) returned the driver's NaN result unchanged forv_add_f16,v_sub_f16,v_subrev_f16andv_mul_f16. The AMD Windows driver returns a signaling NaN source unquieted:v_sub_f16of 0x00ff and 0x7dbe gives 0xfdbe. RDNA2 quiets it to 0xffbe.Measured on gfx1035 (Radeon 680M) with the hardware oracle, for the four ops in their VOP2, VOP3 clamp and SDWA forms, at
IEEE_MODE0/1 andDX10_CLAMP0/1 (evidence: https://gist.github.com/c1b3r-p3d1a/9721280d2211f292a46b84a239a1d654):IEEE_MODE1, every NaN result is the NaN source quieted;v_sub_f16negates src1 first.IEEE_MODE0, the NaN source is returned unchanged.The native path now sets the quiet bit (0x0200) of a NaN result when
IEEE_MODEis set. The payload is still the driver's, as the clamp-modifier entry already says.IEEE_MODE0 is unchanged.Not changed: the native
v_fma_f16/v_fmac_f16/v_fmamk_f16/v_fmaak_f16path (float16NativeFma, only on devices withVK_KHR_shader_fma). The hardware quiets there too (same gist), but this device has no FMAKHR, so I couldn't run a fix. A new debt entry records that gap first, and what the add/sub/mul path now does.Tested
Windows 11, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh r7), Release, AMD Radeon 680M (gfx1035), driver 32.0.21030.12001 (no
VK_KHR_shader_fma).agc_driver_float16_nativenow requires every NaN result of its add, sub, subrev and mul forms to be quiet in theIEEE_MODEmodes, from both the native and the emulated path; the fma forms are left out. Onmain'sFloatInstructions.cppit fails:dx10 ieee ovfl, v_sub_f16 v11, v4, v5 with v4=0x39fcfd3b v5=0xe3d4feab ... is the signaling NaN 0x0000fd3b, which IEEE_MODE quiets. It also fails when the fix counts only quiet NaNs as NaN.v_fma*forms) instead of by result index, so a reordered result table can't drop a changed form (MarcZX10's review). It selects the same 9 of 16 forms as before. With the merge-baseFloatInstructions.cpp, it fails atv_sub_f16 v11, v4, v5, signaling NaN0xfd3b; with this PR's it passes.f16|float16|fp16|sdwa|vop2_modifier|ldexppass, exceptguest_harfbuzz_buffer_utf16(Not Run: another library's test, not built).agc_driver_float16_native,agc_driver_sdwa_float_selectors,agc_driver_float16_modifiersandagc_driver_fp16_overflowwithANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(SDK 1.4.363.1),ctest -V: pass onmainand on this branch, 0VUID-lines on both.python tools/check_conventions.py --base origin/mainpasses. Merge simulation: clean onmainand after each of the 78 open PRs touching these files that merge cleanly withmain, including perf(shader): keep the device's f16 NaN results with IEEE_MODE clear when a startup probe matches RDNA #15719, which changes the same functions forIEEE_MODEclear.VK_KHR_shader_fma, the console's gfx1013.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)