tools: a native RDNA 2 reference for float arithmetic (T5) #420
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/420"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from brcly/TuxBox. Originally posted by JeffreyBytes on 2026-11-28T22:03:20Z.
Summary
First piece of T5 (#412): a hardware reference for the float arithmetic family, recorded on an RX 6700 XT, plus a no-GPU test that holds the models to it.
It builds on @JohnVonWells's
tools/native_rdna2/. Two routes, same inputs:float.hip+check_float.py, same structure as the f64/half/SAD checks. 20 hand-written instructions, each run under all 1,024MODE[9:0]values: 329,728 comparisons against the model, 0 mismatches. On gfx1031/gfx1032 it setsHSA_OVERRIDE_GFX_VERSION=10.3.0for its own runs and says so in the receipt.vulkan_float.py+vulkan.c. One GLSL compute shader per instruction through RADV, and it refuses to record unless the instruction shows up inRADV_DEBUG=shadersdisassembly. 17 instructions under the five SPIR-V float modes.The two agree on every bit they share: RADV's default is exactly MODE
0xc0(what the translator starts from),DenormPreserveis0xf0,DenormFlushToZerois0x00.Instructions:
v_add_f32,v_sub_f32,v_mul_f32,v_fmac_f32,v_fma_f32,v_fma_mix_f32,v_fma_mixlo_f16,v_pk_fmac_f16,v_min_f32,v_max_f32,v_rndne_f32,v_trunc_f32,v_floor_f32,v_ceil_f32,v_cvt_f32_i32,v_cvt_i32_f32,v_cvt_u32_f32, and on the ROCm side alsov_mul_legacy_f32,v_fmac_legacy_f32,v_fma_legacy_f32.What it found
Which MODE bits matter (full table in
docs/CONSOLE_REFERENCE.md): for add/sub/mul/fma it's0x233, i.e. f32 rounding (1:0), f32 denormals kept for sources (4) and for results (5), and IEEE (9). IEEE quiets NaN results and makes min/max return a quieted signaling NaN source. DX10 clamp changed nothing here.Under MODE
0xc0the card:ceil(0x00000001)is +0, not 1.0), and flushes on "tiny after rounding";0xffc00000for invalid operations, and0 × infin an fma wins over a NaN addend;v_sub_f32;tools/check_basic_alu_gpu.py's models disagree with the card in three places. I have not changed them in this PR, the test just pins the disagreements down:Float.matchesonly allows a flushed result. 250 of the card's results are rejected for this, and the check can't see it becauseFLOAT_EDGEhas no f32 denormals and the random inputs stay between 2^-30 and 2^30.Float.matchesreturns as soon as the expectation is a NaN and never looks atalso, so withseparateputting the twice-rounded result first it rejects the card's fused -inf for 2^127·2^127 - inf.I'll send the model fixes and denormal inputs as a follow-up, since that touches a translator check and needs a GPU run on both vendors.
Limits
v_mac_f32,v_mad_f32,v_madak_f32,v_madmk_f32,v_mac_legacy_f32andv_mad_legacy_f32, and recorded shaders do usev_mad_f32. So this can't be the reference for the GFX10.1 side.v_fmac_legacy_f32/v_fma_legacy_f32have the same encodings as RDNA 1'smac_legacy/mad_legacy(VOP2 6, VOP3 0x140); they fuse here, and I don't know that they do on the console.0xc0as the console's starting value comes from the title's stage descriptors (#333), not from hardware, and that only covers bits 7:0.Layout
tools/native_rdna2/:float.hip,check_float.py,vulkan_float.py,vulkan.c,ieee_float.py(exact IEEE model),rdna2_float.py(the card as a function of MODE)evidence/native-rdna2-float.json(234 KB, a hash per MODE combination plus raw words under0xc0),evidence/native-rdna2-vulkan-float.json(430 KB, raw words for 5 modes)tests/test_native_rdna2_float.py,tests/test_native_rdna2_vulkan.py: no GPU, about 12 s togetherdocs/CONSOLE_REFERENCE.md, the README, and the T5 row in the roadmap marked in progressThe Vulkan receipt is the big file. If 430 KB is too much for
evidence/I can cut it to hashes plus the default mode like the other one.Tested
No Lanes scenario: this runs native instructions outside TuxBox's providers, so there's nothing for Lanes to exercise. No NVIDIA run: the recorders only run on an RDNA 2 card, and the PR changes no provider, translator or shared check code. The tests that hold the models to the receipts need no GPU and run in CI.
GPU, driver and backend: AMD Radeon RX 6700 XT (
1002:73df, gfx1031), Mesa RADV 26.3.1, Linux 7.3.6, ROCm under/opt/rocm. No Proton involved.Commands run and their results:
I only have Python 3.14 here, so 3.10 is syntax-checked and CI will be the real test.
Checks
docs/RESULTS.mdanddocs/progress.svgregenerate to what's already there; the new receipts aren't a type those views count.