Repository navigation
fix(shader): flush v_fma_mix_f32 f16 sources by the f16 denormal field - #7040
Merged
oneandonlydean merged 1 commit intoOct 17, 2026
Merged
Conversation
v_fma_mix_f32 used its f16 sources unflushed in every mode. On RDNA2 (gfx1031) f16 denormal modes 0 and 2 flush each f16 source to a zero of its sign, whatever the f32 denormal field, so v_fma_mix_f32 0, 0, 0x0001 (all f16) is 0 there instead of 2^-24. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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.
|
This was referenced Oct 17, 2026
Contributor
|
Another AMD driver, since the description lists other AMD drivers as untested. Windows 11 (26300), Radeon 860M (RDNA 3.5,
AI-assisted: yes (Claude Code). |
12 tasks done
11 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
v_fma_mix_f32used its f16 sources (op_sel_hiset) unflushed in every mode; the technical debt entry on f32 denormals says "f16 inputs retain their previous conversion and denormal handling". On the GPU, f16 denormal mode 0 or 2 (bit 6 ofFLOAT_MODEclear) flushes each f16 source to a zero of its sign before the fused multiply-add, whatever the f32 denormal field. Sov_fma_mix_f32 0, 0, 0x0001with all three sources f16 gives0x00000000there;maingives0x33800000(2^-24).readMixF32now passes an f16 source throughflushF16InputValue, asv_cvt_f32_f16already does. f32 sources, modes that keep f16 denormals, and shaders without a known float mode are translated as before.v_fma_mixlo/mixhi_f16sharereadMixF32but still throw in the modes that flush f16 denormals, so they are unchanged.Measured
The same instruction was run directly on the GPU with the
tools/hw-oracletemplate, launched through the driver's HIP runtime, and through the recompiler on Vulkan, at IEEE 0 and 1, with f32 denormal modes 0 and 3 and f16 denormal modes 0 to 3:mainvs GPU, f16 modes 0 and 2op_sel_hi:[1,1,1]), 14 halvesop_sel:[1,1,1])-src0, |src1|, -src2, three f16 sourcesop_sel_hi:[1,0,1]), f32 denormals flushedThe rows left in the last line are not about the f16 field: on
mainthe same form already gives 61 mismatches with f16 denormals kept, and every remaining row (plus 2 that differ only in NaN payload) has an f32 denormal source or an f32 denormal GPU result while f32 denormals are kept (the GPU keeps a result like -2^-140 andf16 inf * f32 0x807fffff= -inf, where the translation gives 0 and NaN). Flushing a denormal f16 addend makes more of those f32 results denormal, which is where the extra 38 rows come from.Tested
Windows 11 26200, AMD Radeon RX 6700 XT (gfx1031), driver 32.0.21045.5002, WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ON,ANYPS5_REQUIRE_VULKAN=1:agc_driver_fma_mix_f16_denormal_modes: three f16 sources, and f16 * f32 + f16, over 16 rows (denormal f16 sources, products and sums at the f16 and f32 denormal boundaries, inf * denormal, signed zeros) in f32 denormal modes 0 and 3 with f16 denormal modes 0 to 3 at IEEE 0 and 1, against the GPU's results; none of the expected values is an f32 denormal. Onmainit fails:v_fma_mix_f32 of three f16 sources f32 denormals flushed, f16 denormal mode 0, IEEE mode off of 0x00010000, 0x00000000, 0x3f800000 is 0x33800000, expected 0x00000000. With this change it passes.ctest --parallel 4 --timeout 120onmainf8b22edfbwith this change: 1368 tests, 2 fail, both failing onmainon this GPU too:agc_driver_lds_mixed_width_atomics(agc_* tests: 3 of 483 fail on AMD Radeon RX 6400, pass on NVIDIA RTX 4080 SUPER #5271) andagc_driver_layered_volume_vertex_no_gpl(AMD Windows: GPL-mode cache failures (alpha/wave32 pass after local driver update) #4768). The f16, fma and interpolation tests pass.python tools/check_conventions.py --base origin/mainwith this title and body passes.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)🤖 Generated with Claude Code