upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authoriurysf <98192149+iurysf@users.noreply.github.com>2026-11-22 22:20:42 -0300
committeriurysf <98192149+iurysf@users.noreply.github.com>2026-11-22 22:57:33 -0300
commit50b889e3c19360e96eaa1c14a0e216f4fb8c0cfa (patch)
tree333257820e377660a000ad271a7b22182a8e8976 /docs
parent03b09a086592a197db64d91655c6e65c30764d96 (diff)
FUZZ-55: Harden binary64 differential probes
AI-assisted (OpenBot team). Explicitly count FTZ and implementation-defined GPU precision skips, execute known divergence probes, correct compare modeling, and reuse prepared GPU context when shrinking. CPU campaigns and RTX 4070 Vulkan shaderFloat64 campaigns finished with zero unexpected mismatches. Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
Diffstat (limited to 'docs')
-rw-r--r--docs/shader_validation.md68
1 files changed, 67 insertions, 1 deletions
diff --git a/docs/shader_validation.md b/docs/shader_validation.md
index b7fad4106..caa54dc4e 100644
--- a/docs/shader_validation.md
+++ b/docs/shader_validation.md
@@ -1061,7 +1061,8 @@ python -I tools/f32_fuzz.py --oracle hw --perturb mul_rtz --programs 500 # o
1061 `7cfc` on gfx1150); only mnemonics are shared. omod and clamp exist in VOP3 on both; no op_sel is used for f32. 1061 `7cfc` on gfx1150); only mnemonics are shared. omod and clamp exist in VOP3 on both; no op_sel is used for f32.
1062 The transcendental unit is separate on GFX11, so a `s_nop 7` follows the instruction in the native kernel 1062 The transcendental unit is separate on GFX11, so a `s_nop 7` follows the instruction in the native kernel
1063 (`--no-hw-guard` leaves it out). 1063 (`--no-hw-guard` leaves it out).
1064 - *Not covered:* wave64 (the f32 ALU does not depend on it), `v_fma_mix*`, f16 and f64 arithmetic. 1064 - *Not covered:* wave64 (the f32 ALU does not depend on it), `v_fma_mix*` and f16 arithmetic. The translated f64 VALU
1065 forms have a separate CPU differential harness in `tools/f64_diff.py` (below).
1065- **Programs.** The seeded random ones, plus `--probes N` (default 12) per op and kind: denormal operand, denormal 1066- **Programs.** The seeded random ones, plus `--probes N` (default 12) per op and kind: denormal operand, denormal
1066 result, NaN payloads, clamp of NaN/-0, invalid operations (inf - inf, 0 * inf, ...), and `cancel` (`z = -round(x * y)`, 1067 result, NaN payloads, clamp of NaN/-0, invalid operations (inf - inf, 0 * inf, ...), and `cancel` (`z = -round(x * y)`,
1067 which separates fused from unfused). `v_min/max/min3/max3/med3_f32` are in the table for the hardware only, with the 1068 which separates fused from unfused). `v_min/max/min3/max3/med3_f32` are in the table for the hardware only, with the
@@ -1197,6 +1198,71 @@ python -I tools/fmisc_diff.py --programs 3000 --seed 11 --max-ops 8
1197python -I tools/fmisc_diff.py --oracle hw --programs 500 --seed 1 1198python -I tools/fmisc_diff.py --oracle hw --programs 500 --seed 1
1198python -I tests/test_fmisc_diff.py 1199python -I tests/test_fmisc_diff.py
1199``` 1200```
1201
1202### binary64 VALU on the CPU and Vulkan (`tools/f64_diff.py`, FUZZ-55)
1203
1204`tools/f64_diff.py` covers the 47 binary64 instruction forms `tools/rdna2spirv.py` translates on main: four rounding
1205ops, add, f64-to-f32 conversion, reciprocal/reciprocal-square-root/square-root, division fixup and scaled FMA, both
1206frexp results, all 16 `v_cmp_*_f64` and 16 `v_cmpx_*_f64` predicates, and both class compares. It generates one-lane
1207programs with VGPR and SGPR pairs, float immediates, inline constants, 32-bit literals where the translator marks
1208them as upper-half f64 literals, and full-width literals in other instruction forms; it compares the four exported
1209dwords. Compare predicates are read through a mask-to-word operation, and `v_cmpx` cases also export the resulting
1210`EXEC` mask. Its reference decodes IEEE binary64 words and uses exact
1211`Fraction` arithmetic for finite addition and fused multiply-add; it does not import code from the translator or the
1212other fuzzer references. It models all four `MODE.FP_ROUND[3:2]` encodings for addition; the translator currently
1213rejects directed rounding (+infinity and -infinity), so those generated cases are counted skips. Any NaN matches any
1214NaN. Binary64 subnormal operands or results for `v_rcp_f64`, `v_rsq_f64` and `v_sqrt_f64`, and subnormal f32 results
1215from `v_cvt_f32_f64`, are counted skips because shader drivers may flush them to zero (FTZ).
1216
1217`--sweep` (the default) tries each translated form, followed by `--programs N` seeded programs (`--seed S` and
1218`--max-ops N` control the campaign). `--no-sweep`, `--ops`, `--no-literals`, `--known`, `--all-failures`,
1219`--list-ops` and `--self-test` are available. The translator oracle executes generated SPIR-V with the local semantic
1220interpreter. The current CPU interpreters do not implement binary64 `OpFConvert` or `OpFDiv`; these are reported as
1221counted skips. Negative-input `Sqrt` and
1222`InverseSqrt` cases are also skipped because GLSL.std.450 leaves them undefined. `s_round_mode` encodings for directed
1223rounding that the translator rejects are counted as skips. The reference uses IEEE binary64 for reciprocal and square
1224root; native RDNA2 `v_rcp_f64`, `v_rsq_f64` and `v_sqrt_f64` have about 26 bits of precision (PROC-216), so this
1225oracle checks the translated SPIR-V contract, not the native instruction's approximation. Other unsupported interpreter
1226instructions are counted as skips with their reason. Vulkan's [SPIR-V environment](https://docs.vulkan.org/spec/latest/appendices/spirvenv.html)
1227leaves the precision of these GLSL [extended instructions](https://registry.khronos.org/SPIR-V/specs/unified1/GLSL.std.450.html)
1228implementation-defined for binary64; the GPU oracle therefore counts `v_rsq_f64` and
1229`v_sqrt_f64` as unjudged skips instead of requiring bit-exact results. This was confirmed on an NVIDIA RTX 4070 with
1230`shaderFloat64`: `v_rsq_f64 3.25` produced matching high 32 bits but zero low 32 bits, unlike the exact reference.
1231
1232Known divergence probes are excluded and counted by default, then reinserted with `--known`: binary64 output modifiers
1233(SHADER-721), binary64 `OpFNegate`/`FAbs` that the CPU interpreter rounds through binary32 (TEST-912, #4172),
1234driver-dependent NaN or signed-zero clamp results, and `v_div_fixup_f64` with a NaN `S0` and an ordinary finite
1235division. The latter follows the RDNA2 ISA reference (`NaN(S0) -> signed infinity`), while the current translator
1236preserves the NaN payload. Therefore `--known` can intentionally return 1 when this known mismatch is reproduced;
1237the minimized case is printed. `--oracle gpu` translates the same
1238fragment shader and runs it through `runtime/build/vk_harness`, comparing the raw RGBA32F output words. It assembles
1239the fragment module with `spirv-as` and the full-screen vertex shader with the Vulkan SDK's `glslc`; use `--exe PATH`
1240to select another `vk_harness`. It exits 77 if the executable, SDK tools, Vulkan device or required `shaderFloat64`
1241feature is unavailable. `--oracle hw` requires the AMD `tools/hw_oracle` setup and likewise exits 77 when unavailable.
1242Exit codes are 0 for no unexpected
1243mismatch, 1 for a mismatch (with instruction-removal shrinking), 2 for CLI/harness errors and 77 for unavailable
1244oracles. Skips always include a reason.
1245
1246```
1247python -I tools/f64_diff.py --programs 300 --seed 1
1248python -I tools/f64_diff.py --known --programs 300 --seed 1
1249python -I tools/f64_diff.py --oracle gpu --programs 300 --seed 1
1250python -I tools/f64_diff.py --self-test
1251python -I tests/test_f64_diff.py
1252```
1253
1254**Vulkan check on an NVIDIA GeForce RTX 4070** (Windows 11, driver 621.01, Vulkan `shaderFloat64` enabled):
1255
1256| Command | Match | Mismatch | Total | Skips |
1257|---|---:|---:|---:|---:|
1258| `--oracle gpu --programs 300 --seed 1` | 331 | 0 | 347 | 16 |
1259| `--oracle gpu --programs 200 --seed 2 --max-ops 4` | 218 | 0 | 247 | 29 |
1260| `--oracle gpu --ops v_cvt_f32_f64,v_rcp_f64,v_rsq_f64,v_sqrt_f64 --programs 80 --seed 1` | 39 | 0 | 84 | 45 |
1261| `--oracle gpu --ops v_cmpx_lt_f64,v_cmpx_eq_f64,v_cmpx_class_f64 --programs 40 --seed 1` | 43 | 0 | 43 | 0 |
1262
1263The skips are counted by reason: subnormal FTZ, implementation-defined binary64 `InverseSqrt`/`Sqrt` precision,
1264non-finite scaled FMA, and translator-rejected directed rounding. The compared cases had no mismatches.
1265
1200**Default-mode DX9 multiply regression.** `v_mul_legacy_f32` now explicitly flushes each f32 operand before the 1266**Default-mode DX9 multiply regression.** `v_mul_legacy_f32` now explicitly flushes each f32 operand before the
1201DX9 `0 * anything => +0` override, and flushes the nonzero product before its VOP3 output modifier. The output is 1267DX9 `0 * anything => +0` override, and flushes the nonzero product before its VOP3 output modifier. The output is
1202flushed again before the active omod's `-0 => +0` rule. Previously it emitted an unguarded `OpFMul`, so on a Vulkan 1268flushed again before the active omod's `-0 => +0` rule. Previously it emitted an unguarded `OpFMul`, so on a Vulkan