T2: GPU checks for vector float instructions #333
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 NickStallman on 2026-11-27T21:23:36Z.
Taking this part of T2 from ROADMAP.md: GPU checks for the vector float instructions recorded shaders use and no check runs yet. This is the starter list in the roadmap, plus the float ops just below it in INSTRUCTIONS.md:
v_mul_legacy_f32,v_fmac_f32,v_fma_mix_f32v_rsq_f32,v_rcp_iflag_f32,v_exp_f32,v_log_f32v_sin_f32,v_cos_f32,v_fract_f32v_cvt_f32_ubyte0–3v_cmpx_*family (gt,lg,ltand the rest that are used)Plan
tools/check_basic_alu_gpu.pyand its siblings), with a reference model.0 × inf = 0, denormals, NaN and inf inputs, the transcendentals' input ranges and their documented precision, and EXEC writes forv_cmpx.Not covered here, so others can take them: the scalar and buffer loads (
s_buffer_load_*,buffer_load_*,tbuffer_*),s_inst_prefetch, the scalar ALU (s_cselect_*, …) and the integerv_cmpx_*. If nobody claims them once these are done, we'll pick up the next block and say so here.Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-27T21:25:53Z.
I've started work on this, already. Apologies for not stating sooner.
Hold off on doing this for now
Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-27T21:49:31Z.
No problem, we'll stop here. We had already written three checks and run them on both cards, so here's what they found. All of it is measured unless marked otherwise.
Setup: AMD Raphael iGPU (1002:13c0, RADV, an RDNA 2 part) and RTX 5090 (10de:2b85, 620.70.10), GE-Proton11-14,
mainatfa7333b8.1.
v_sin_f32/v_cos_f32: wrong for large inputs on NVIDIA. The transcendental check covers rsq, rcp_iflag, exp, log, sin, cos, and special values of rcp and sqrt, with 384 inputs each.0x497FF004NVIDIA returns about 1.0 where the answer is about 0.sin(x * 6.28318530718)without first reducing x to a fraction of a turn, sox·2πoverflows or loses the fraction. RADV happens to get it right. Reducing tox - trunc(x)first (keeping sin(−0) = −0) should fix it.2. Float multiply-add forms: 21 of 99 forms wrong on AMD, 23 on NVIDIA. The check covers
v_mul_legacy_f32,v_fmac_f32,v_fma_mix_f32,v_fract_f32andv_cvt_f32_ubyte0–3, in the VOP2/VOP3/SDWA forms and modifiers the recorded shaders use, 128 inputs each. The existingalucheck passed 144/144 on both cards in the same run.v_fma_mix_f32with clamp: 86–110 of 128 wrong in 7 forms, both cards. From the code:emit_fma_mixnever reads the VOP3P clamp bit. The recorded shaders have about 3,500 with clamp on this instruction.v_fmac_f32 v, v4, v5(and with an SGPR source): 30 of 128 wrong, both cards. Not yet explained. We haven't ruled out our model, for example f32 denormal-input handling, so treat this as open.v_fma_mix_f32with-v5(op_sel_hi [1,0,0]), 4–6 wrong, without clamp.saturate()gives 0; DX10_CLAMP off would pass NaN): mul_legacy and fmac clamp forms, 4–9 wrong each.mul:2/div:2keeping −0 where IEEE = 0 would give +0: 1–3 wrong each.3. Float
v_cmp/v_cmpx, all 16 predicates plus class. 114 programs in wave32, native wave64 and paired form, with EXEC, VCC and branch readback. It is queued on both cards and hasn't run yet. Predicted from the emitted HLSL:s_cbranch_execzafter av_cmpxthat some lanes fail is decided per lane in the native forms;s24also zeroess25.The checks are on local branches:
checks/t2-float-transcendental,checks/t2-float-madandchecks/t2-float-cmpx. Each is a separatecheck_*_gpu.pywith a reference model and unit tests. I can push them, or the fixes, whichever is useful to you. Otherwise we'll leave T2 to you.Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-27T21:52:10Z.
We've found the cause of the
v_fmac_f32failure I said was still open: double rounding, a translation fault, not our model.a * b + dst, which DXC lowers tofmul fastplusfadd fast. Single rounding then depends on the driver fusing the two.v_mul_legacy_f32computes the samev4 * v5. DXC computes the product once and the fmac's add reads it, so the driver can't fuse an add whose product has another user.0x33800000.v_fma_mix_f32failures with-v5, no clamp: the same thing. All 8 listed results equal a separately rounded multiply and add, bit for bit. NVIDIA didn't fuse there; AMD did.From the title's own data, on the start-up mode: every stage descriptor we sampled (1,109, from 1 in 25 requests, compute included) holds
0x000000c0at offset +0x44. That is the f32/f64 round-and-denormal byte the translator assumes, so f32 denormals flushed and f16/f64 kept is consistent with the title. Our reading of that field comes from its value alone. We found nothing showing DX10_CLAMP or IEEE (MODE bits 8–9), so the NaN-through-clamp and OMOD −0 questions stay open.Local branches, not pushed:
xshader/fused-fma: writes the fused forms withmad(), which DXC keeps as one FMad. DXIL doesn't promise FMad is fused, so it would need a GPU run to confirm.xshader/fma-mix-clamp: applies the VOP3P clamp bit. It changes 5,212 wave64 and 1,992 wave32 outputs, with nothing newly refused.Neither has been run on a GPU. Say if you want either.
Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-27T22:58:04Z.
Two more findings, from a float
v_cmp/v_cmpxcheck that runs whole waves: 32 or 64 lanes with partial EXEC, in wave32, native wave64 and paired form. The new checks incheck_basic_alu_gpu.pyrun one lane per wave, so they can't see either.AMD (RADV, 1002:13c0),
mainat5324096e: 559 of 1,254 cases fail. The same result came onfa7333b8.v_cmpxis decided per lane in the native (unpaired) translations: 198 wave32 cases and 144 wave64 cases.s_cbranch_execz.v_cmpx_lt_f32passes in 10 lanes, thens_cbranch_execzskips overs_mov_b32 s22, 2. The console runs the block for the whole wave. In the translation, lane 0 (which left) readss22 = 0.tb_skipis taken from the lane's own EXEC bit. The paired form testsexec_lo | exec_hifor the wave and passes.s24also zeroess25: 228 cases, in every native wave32 program with a plain compare. NVIDIA shows the same.s25 = 0uis emitted unless some VOP3 compare in the program writes an odd SGPR (wave32_compare_masks).Everything else matched the ISA model on AMD: ordered and unordered NaN, ±0, denormals flushed and kept, modifiers, constants, class bits, the EXEC that
v_cmpxleaves, inactive lanes, and VCC.RTX 5090 (620.70.10): the device was lost, twice, on the same case. The first case with a partly active EXEC in one wave32 program (
v_cmp_lt_f32with a scalar source and with denormals, plus severalv_cmp_eq_f32forms) givesVK_ERROR_DEVICE_LOSTandXid 109 … CTX SWITCH TIMEOUT, at 08:42 and again at 09:20 with nothing else on the GPU. The translatedmainhas no loop. We're narrowing it down to a minimal program now. It matters to us because #232's in-game hang is the same Xid.Check:
tools/check_float_compares_gpu.pyon our local branchchecks/t2-float-cmpx. Say if you want it.Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-27T23:42:41Z.
Thanks for posting these, they're useful. T2's one-lane checks are on main now (369 of the 372 used instructions run on both cards, see INSTRUCTIONS.md), and the sine/cosine reduction and
mad()for the fused forms are merged.Your checks cover what ours can't: whole waves with a partly active EXEC, and operand modifiers. Could you open pull requests for these?
checks/t2-float-cmpx: the per-lane branch afterv_cmpxand thes25write are both findings we don't have a check for.checks/t2-float-mad: for the clamp, OMOD and SDWA forms.xshader/fma-mix-clamp, with the check as its test.These are really T3 (#334), so feel free to take that.
xshader/fused-fmaisn't needed any more.Two notes from our side:
mad(), NVIDIA fuses in our check and RADV still rounds twice. Your shared-product explanation may be why: our check hasv_mul_legacy_f32andv_fmac_f32on the same inputs in one shader. We're testingv_fmac_f32alone on RADV next.Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-27T23:49:38Z.
Will do. Rebased PRs for the float-compares check, the float-forms check and
fma_mixclamp are on the way, and we'll take that part of T3. We're droppingxshader/fused-fma.An update on the NVIDIA device loss from the float-compares check. All of it is measured on the RTX 5090 (620.70.10).
WaveActiveMin((exec_lo & 1u) ? WaveGetLaneIndex() : 0xffffffffu), run with a partly active EXEC. Replacing it withfirstbitlowof aWaveActiveBallotstops the hang, and the check then reads back with no Xid. Changing theWaveReadLaneAtthat follows does not stop it.WaveActiveBitOrandWaveActiveSumon that phi, and aselect()form. So the hang needs something else in the translated program as well. We're now trimming the real program down to find what.