Repository navigation
d16 typed buffer loads round the exact UNORM/SNORM quotient once, as RDNA2 does (BUILD-161) - #1759
Conversation
…RDNA2 does (BUILD-161) docs/design.md narrowed the f16 of a typed d16 buffer load from the f32 decode with round to nearest even, and called that rounding inferred, not measured. tools/d16_format_probe.py measures it through tools/hw_oracle: every UNORM8, SNORM8, UNORM10, UNORM16 and SNORM16 value through buffer_load_format_d16_x, tbuffer_load_format_d16_x and buffer_load_format_x, in wave32 and wave64, against several candidate rules, with a 16_FLOAT load, the kept high half of d16_x and the staged inputs as controls. On an RX 6700 (gfx1031) the hardware rounds the exact quotient once, straight to f16. Rounding to f32 first is 1 ulp high on exactly four values (UNORM16 0xffaf and 0xffef, SNORM16 0x7ff7 and 0x8009); over every width up to 16 bits only two f32 quotients land on an f16 halfway point (0x3f7ff000, 0x3f7fb000). Gen.d16_norm_f16 takes the f16 below for those two, for normalized formats only. The f32 (non-d16) result was already right. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent hardware run of Setup: AMD Radeon Graphics, the Ryzen 7 7800X3D iGPU (gfx1036, RDNA2). Windows 11, AMD Windows driver 32.0.21043.5001 (Vulkan driverInfo 26.3.1), HIP runtime Default sweep, all formats, waves 32 and 64; exit 0.
(AI-assisted run; synthetic kernels, no game files.) |
# Conflicts: # docs/design.md # tools/rdna2spirv.py
|
Tested Independent translated Vulkan check on Linux 7.0.0-43-generic with a GeForce RTX 5090, NVIDIA driver 595.99.02, LLVM 21.1.8, and SPIRV-Tools 2026.1. All ten result words matched in a synthetic wave32 fixture. The four distinguishing UNORM16 and SNORM16 inputs matched single rounding through both MUBUF and MTBUF, and every load preserved the destination's upper half. A true 32_FLOAT halfway control rounded to even through both paths. Returning the uncorrected f32-to-f16 result from the narrowing helper changed all eight normalized outputs by one f16 ULP and left the two float outputs unchanged. Both versions passed AI-assisted verification. |
|
Ran the probe at 6b5c01d on a third RDNA2 die, an AMD Radeon RX 6600 (Navi 23, gfx1032): AMD 26.11.2 (Vulkan driver 32.0.21045.29003), HIP runtime
Every format: wave32/64 differ 0, MUBUF/MTBUF d16 differ 0. As on gfx1036,
On the earlier run of the merged branch: semantic 1572 OK, AI-assisted (Claude Code): it set up the oracle toolchain, ran the probe and wrote this comment. |
|
Tested
No regression against AI-assisted (Claude Code). |
Claimed in the coordination issue as: BUILD-161 (claimed in #1548; the tracker is now #1745)
What and why
docs/design.mdnarrowed the f16 of a typed d16 buffer load from the f32 decode, rounding to nearest even, and said that rounding was inferred, not measured. @shelbykb2 measured it on an RX 6800 in #806: the exact quotient is rounded once, straight to f16. The translator still rounds twice (f32 first, thenf16_bits).This PR adds:
tools/d16_format_probe.py, built ontools/hw_oracle. It loads every UNORM8, SNORM8, UNORM10, UNORM16 and SNORM16 value throughbuffer_load_format_d16_x,tbuffer_load_format_d16_xandbuffer_load_format_x, in wave32 and wave64, and counts which candidate rule each result fits. The kernels write their own inputs. Controls: a 16_FLOAT load, the kept high half ofd16_x, and the input words read back.Gen.d16_norm_f16takes the f16 below for those two, for UNORM/SNORM formats only; a 32_FLOAT 0x3f7ff000 is a real tie and still rounds to even. This costs a few instructions per d16 component and no new function.docs/design.md("d16 and f16 format narrowing") now says measured for typed buffer loads. Image d16 stays inferred.Tested
On an RX 6700 (gfx1031) with AMD Windows driver 32.0.21045.29003 and the ROCm wheel's clang:
The f32 result column is the correctly rounded f32 quotient. MUBUF matched MTBUF and wave32 matched wave64 everywhere, 16_FLOAT returned its own bits for all 65,536 encodings, and the sweep took 36 s.
tests/test_d16_format_probe.py(17 tests, including one on the GPU) passes on that machine.Here:
tests/semantic(1455 tests, with 5 new ones intest_buffer_load_format.pythat fail without the fix),tests/test_translate.py(469 tests) andtests/test_d16_pack.pypass.spirv-valaccepts translated d16 MUBUF/MTBUF loads.Not run: translated shaders on a GPU. A gfx1036 run (@abnalstlll-byte offered one) or the RX 6800 would be a good second check.
Checklist
docs/design.md, with how it was confirmed.AI-assisted change and verification using synthetic inputs.