Repository navigation
fix(translator): round v_fma_mixlo/hi_f16 once to f16 (finding 7079901079) - #1774
Conversation
|
Tested
About F on RADV: my guess, not confirmed by dumping the driver's output, is that AI-assisted (Claude Code). 🤖 Generated with Claude Code |
Hardware measurement on RDNA2 (gfx1036, finding 7079901079) confirms that v_fma_mixlo_f16 / v_fma_mixhi_f16 round the exact fma once, straight to f16, across all rounding modes (7 of 7 discriminating cases in tools/fma_mix_probe.py match single rounding). The translator previously double-rounded in nearest-even mode (f32 Fma then f16 narrow). Change v_fma_mixlo_f16 / v_fma_mixhi_f16 to use Gen.fma_mix_odd across all modes, which rounds to odd at f32 so that narrowing to f16 gives the exact single-rounded result in both nearest-even and toward-zero modes. Update tests/test_fma_mix_probe.py and docs/shader_validation.md to reflect the RDNA2 hardware measurement, and add discriminating semantic tests in tests/semantic/test_valu_fma_mix.py. AI-assisted.
383c68b to
40e17da
Compare
|
Three-way before/after with Setup: Windows 11. AMD Radeon Ryzen 7 7800X3D iGPU (gfx1036, RDNA2), driver 32.0.21043.5001 (Vulkan driverInfo 26.3.1), used for both
On main the discriminating cases F and G come out 0x3c00 and 0x3c02, the double-rounded words; with this PR they are 0x3c01, as on the silicon. The H control is 0x4100 everywhere. Note on @esteban-dcp's Radeon 740M result (RADV, 7 of 8 on the Vulkan side): the AMD Windows driver gives 8 of 8 here on the same translation, so that word looks specific to RADV or that GPU, not to the translation. GPU suite at (AI-assisted runs; synthetic probes, no game files.) |
# Conflicts: # docs/design.md # docs/shader_validation.md
|
Tested 40e17da on AMD Radeon(TM) Graphics (Ryzen 9 9950X3D iGPU, RDNA2, subgroup 32..64), driver 26.10.1, and NVIDIA GeForce RTX 5080 (subgroup 32..32), driver 616.92, Windows 11 (26200): pass. Detached worktree at the PR head (base 003e781); main for the red check is a second worktree at 003e781. Runtime built from the PR head (-j 4).
Not run: the negative control and an RDNA2 AI-assisted. |
|
Tested
No regression against AI-assisted (Claude Code). |
… one still off PROC-96: the Known approximations row still listed mix ops with the packs that round to nearest because the mode says so. SHADER-135 (#1722) measured v_fma_mixlo/mixhi_f16 on gfx1036: they round the exact x*y+z once in every mode, 7 of 7 discriminating tie inputs. The toward-zero path already does that; the nearest-even path narrows an f32 Fma, which is 1 f16 ulp off on ties until #1774 (SHADER-296) lands, so the row now says which of the two is the approximation instead of implying both are correct by construction. The f16 inline constants row needed no change: #1722 already replaced its "Not measured" note with the measured per-operand rule.
Overview
Hardware measurement on AMD RDNA2 (gfx1036, reported by @Sanonymous01 in comment 7079901079) confirms that �_fma_mixlo_f16 and �_fma_mixhi_f16 round the exact x * y + z once, straight to f16, in nearest-even mode as well as toward zero (all 7 discriminating tie inputs in ools/fma_mix_probe.py follow the single-rounding rule).
Previously, in nearest-even mode the translator computed f32 Fma and then narrowed (16_res), which produced a double rounding error (1 f16 ulp off on ties).
Changes
Testing
Tested on Windows 11 with AMD Radeon RX 7800 XT, driver 24.20.19.05. Zero game content, executables, or shaders involved.
AI-assisted.