Repository navigation
Conversation
Kam471
left a comment
There was a problem hiding this comment.
Ran this at 50b889e3 on Windows 11: python -I tests/test_f64_diff.py -> 16 tests, OK (41 s); git diff --check clean.
The new tools/f64_diff.py binary64 differential fuzzer and its hardening checks pass; docs remain counts/rules only. No blocking issue.
|
Tested
AI-assisted (Devin). |
|
Tested
No GPU, no game data. AI-assisted. |
|
Tested 50b889e merged with main 03b09a0 (already up to date) on Linux (WSL2) Python 3.12.16 and native Windows 11 Python 3.13.1: pass, with a coverage note.
|
|
Cross-platform check on Apple M2 (macOS 26.4, arm64, Python 3.13.18) at head 50b889e: AI-assisted. |
Flyander
left a comment
There was a problem hiding this comment.
Two actionable issues below: the advertised hardware oracle is unreachable, and the reference mishandles one directed-rounding signed-zero case.
| if args.self_test: return 0 if self_test() else 1 | ||
| gpu = None | ||
| if args.oracle == "hw": | ||
| print("hardware oracle unavailable: this host has no configured AMD hw_oracle", file=sys.stderr); return 77 |
There was a problem hiding this comment.
[P2] This returns 77 unconditionally, so --oracle hw can never use an AMD tools/hw_oracle, even when configured; --hw-arch is consequently unused and run_one() sends every non-GPU oracle through the translator. That contradicts the CLI/docs contract and blocks using this fuzzer to adjudicate the documented RDNA2 divergence. Please detect whether the hardware oracle is unavailable, and route available runs through it.
| if is_inf(a) or is_inf(b): | ||
| af, bf = to_float(a), to_float(b) | ||
| return from_float(af + bf) | ||
| negzero = (is_zero(a) and is_zero(b) and bool((a & b) >> 63)) or mode == 2 |
There was a problem hiding this comment.
[P3] or mode == 2 makes every exact zero sum negative under round-toward-negative, including +0 + +0. IEEE 754-2019 section 6.3 says x + x retains the sign of x when x is zero, so this case must stay +0; only opposite-sign cancellation gets the directed-rounding zero sign. The translator currently skips directed-rounding programs, which makes this latent in current comparisons, but the reference claims to model all four modes. Please distinguish same-sign zero operands from exact cancellation and pin both signs in a reference test.
…the reference Review follow-up on ItsNotRexed#4536 (CHANGES_REQUESTED by Flyander; coverage note by kapitche). - --oracle hw no longer always exits 77. It opens tools/hw_oracle (same pattern as tools/fmisc_diff.py), runs each program as a one-lane wave32 raw kernel in the game's inferred MODE, honours --hw-arch, and compares the four words with the reference. 77 is returned only when the oracle is unavailable. v_rcp/v_rsq/v_sqrt_f64 are counted skips there (native results are approximations, PROC-216); the translator-only known-divergence exclusions do not apply to hardware. - add_bits: an exact zero sum now follows IEEE 754-2019 6.3. +0 + +0 stays +0 in every mode; only opposite-signed zeros and x + (-x) give -0 when rounding toward negative. Before, every exact zero was -0 in that mode. - tests: direct table tests for compare (16 conditions x 28 operand pairs), class (10 classes plus boundaries), div_fixup, frexp and add_bits (NaN, inf, zero signs in all four modes), plus fake-oracle tests for hw routing, --hw-arch, exit 77, skips and shrinking. Mutating lt to <=, add_bits NaN to 0, or dropping the signed-zero rule now fails them. - docs/shader_validation.md describes the hw contract. No AMD hardware run has been done. KNOWN_DIVERGENCES keeps div-fixup-nan-s0 (it waits for TEST-983 to reach main). AI-assisted (OpenBot team). Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
|
@Flyander, @kapitche, thanks. All three points are addressed in a new commit on top of 50b889e (no force-push): 7bd5f01.
Checks at 7bd5f01 (Windows 11, AI-assisted (OpenBot team). |
|
Tested head 7bd5f01 on current main: the Setup: Linux 6.18 host, Python 3.13, CPU oracle only, main 7b7d73f. Its 1. Mismatches at 12000 programs per seed (
All 40 are 2. Two tests fail on current main (
The cause is that main now maps What main implements (the
Patch to - if is_nan(s2): return s2 | (1 << 51)
- if is_nan(s1): return s1 | (1 << 51)
+ if is_nan(s2): return s2
+ if is_nan(s1): return s1
@@
- if i1 or z2 or ediff < -1074: return sign
- if z1 or i2 or ediff >= 1024 or is_nan(s0): return sign | EXP
+ if i1 or z2 or ediff <= -1076: return sign
+ if z1 or i2 or is_nan(s0): return sign | EXP
@@ (the KNOWN_DIVERGENCE guard in the step function)
- and -1074 <= ediff < 1024)
+ and ediff > -1076)With the patch, the same two seeds give 10845/12047 and 10890/12047 matching, 0 mismatches, exit 0 for both. The skips are the same reasons as before. What else needs updating for the patch:
Every other f64 op in both runs matched. AI-assisted (Claude Code), every number above is from a real run. |
…Rexed#2477 is on main ItsNotRexed#2477 (48a1a98) makes the translator return signed infinity for v_div_fixup_f64 with NaN(S0), as measured on RDNA2 gfx1036, which is what the reference already modelled. The case is no longer a known divergence (as TreXito's review of ItsNotRexed#4536 observed: two tests fail on main because they expect the old divergence). - Remove the div-fixup-nan-s0 entry, its reference skip and its dedicated --known program; NaN(S0) programs are compared like any other. - Add a positive test that the reference and the translator give +-inf for qNaN, -qNaN and sNaN with both output signs. - Rework the two --known tests so they no longer depend on div_fixup: the three remaining forms are excluded with a reason by default, run with --known, and a planted clamp-only translator error exits 1 and prints the shrunk program. - docs/shader_validation.md no longer lists the div_fixup case. Same change as 41525870 (prepared for ItsNotRexed#4586, which ItsNotRexed#2477 made redundant). AI-assisted (OpenBot team). Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
…nts on main (ItsNotRexed#2477) TreXito's review of ItsNotRexed#4536 found 40 mismatches in 24000 programs (seeds 776401 and 776402, exp(S2) - exp(S1) >= 1024): the reference predates ItsNotRexed#2477 (48a1a98), whose measured RDNA2 gfx1036 rules are in the docs/design.md v_div_fixup row. The translator is the side that is right. Checked against that row and against the v_div_fixup_f64 lowering in tools/rdna2spirv.py on main, not only against the proposed patch: - NaN in S2 or S1 passes through unchanged (a signalling NaN is not quieted with IEEE=0); the priority NaN(S2) over NaN(S1) is unchanged. - The underflow cutoff is exp(S2) - exp(S1) <= -1076 (was < -1074). - There is no overflow check (was >= 1024). - NaN(S0) gives signed infinity, still below the underflow case. test_div_fixup_table is updated row by row (gap 1074/1075 pass S0, 1076 gives a signed zero, no overflow rows, unquieted sNaN) and docs/shader_validation.md records the rule. AI-assisted (OpenBot team). Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
Found while validating the ItsNotRexed#2477 follow-up on the RTX 4070: with the current translator, `v_cmp_eq_i32_e32 vcc_lo, 0, 0; v_div_fmas_f64 v[8:9], s[4:5], -1.0, 1` mismatched. The reference scaled by a fixed 2^64 when VCC is set; main now follows the hardware-verified (gfx1036, 153/153 f64 stress cases) rule in the docs/design.md v_div_fmas row: 2^+128 when exp(S2) > 1023 (|S2| >= 2.0), 2^-128 otherwise. Same class of stale reference as the v_div_fixup_f64 one fixed in the previous commit (TreXito's review of ItsNotRexed#4536). A table test pins both sides of the |S2| = 2.0 threshold and the VCC-clear case; reverting to the fixed 2^64 fails it. AI-assisted (OpenBot team). Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
|
Tested head Live hardware test on native RDNA2 |
|
Tested 7bd5f01 merged with main 98fa503 on Linux (Python 3.12.16): fail - tests/test_f64_diff.py 29 tests, 2 FAIL, 27 OK; tests/test_docs_*.py all OK. The two failures are test_div_fixup_nan_s0_is_skipped_by_default_and_runs_with_known (known run returns "match", the test expects "mismatch") and test_known_divergences_only_reinserted_with_known (returncode 0, expected 1). Cause: main now has 48a1a98 ("v_div_fixup: match native RDNA2 gfx1036 hardware measurements"), which landed after this branch's base 03b09a0 and makes the translator handle NaN(S0), so the |
The reviewer's `--oracle gpu --ops v_div_fmas_f64 --programs 300 --seed 1` run had one mismatch: `v_div_fmas_f64 v[8:9], 16, 0xa5126aa7ea6efc1f, 0` (VCC clear), reference -0, GPU +0. Diagnosis (RTX 4070): - IEEE is -0: the exact result is a negative nonzero that underflows, and the C library fma and the reference agree. Denormal operands are preserved by the GPU, so it is not operand flush-to-zero. - The translator emits a plain GLSL `Fma` for that path (SPIR-V checked), and adding SignedZeroInfNanPreserve/DenormPreserve 64 does not change the GPU result. - The same `Fma(2^-600, -2^-600, +0)` on runtime operands (a FragCoord-derived shader) returns -0 on the GPU. Only an all-constant `Fma` loses the zero sign, which points at the driver folding it. The fuzz shaders are all constants. So neither the reference nor the translator is wrong. A GPU result that differs from the reference only in the sign of such a zero (an underflowing Fma against an opposite-signed zero addend) is now a counted skip with that reason; any other difference still fails. ref_program reports the case through an optional notes list. Tests pin the flag, the skip, and that a flip without the underflow, or with another differing word, stays a mismatch (four mutations fail them). docs/shader_validation.md records the diagnosis. AI-assisted (OpenBot team). Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
|
Tested 8803b72 merged with main ec34b54 on Linux (WSL), Python 3.12.16 (-I), and native Windows 11, Python 3.13.1: pass Re-check of my earlier fail at 7bd5f01 (2 failing tests, stale
Counts:
Negative control (new files, so reference mutations in |
|
Tested on Windows 11 with Python 3.14 on HEAD \8803b723: \python -m unittest tests/test_f64_diff.py\ ran 33 tests with 1 failure in \ est_div_fixup_nan_s0_gives_signed_infinity_in_reference_and_translator:
|
|
Merged cleanly with current main: all 33 new tests pass, the f64 suites (2 + 4) and docs guards pass, and the CPU campaign reproduces here — 318 match, 0 mismatch, 29 reasoned skips on the documented seed. Both text writes pin UTF-8 and LF; the DXBC stub is constructed, not game data. One scope note: the signed-zero exception is described through the RTX 4070 observation but the exclusion applies to every GPU-oracle run — since the underlying Fma divergence could show on any driver, consider vendor-neutral wording or gating by device so the exclusion reason stays honest on AMD results. #4543 overlaps compare coverage independently. Checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tests origin/main already carries tools/f64_diff.py at 7bd5f01 plus two small maintainer edits (the stdout reconfigure guard in tools/f64_diff.py, and the two --known tests adapted to a translator that matches NaN(S0)). This branch drops div-fixup-nan-s0 from KNOWN_DIVERGENCES and rewrites those two tests, so the merge keeps this branch's versions of them and main's stdout guard. Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
…-sign skip vendor-neutral Review follow-ups on ItsNotRexed#4536. abnalstlll-byte ran `--oracle hw` on a gfx1036 and got 1 mismatch ("word 1: expected 00000001 ffffffff, actual 00000001 00000001"). The hardware kernel runs one thread of a wave32, so EXEC starts as 1: a v_cmpx result read back through exec_lo is 1 or 0 there, while the translator and Vulkan oracles show the full 32-lane mask. The reference assumed 32 lanes for every oracle. ref_program now takes the starting EXEC mask and run_one passes HW_LANE_MASK (1) for --oracle hw; the other oracles keep 0xffffffff. A fake one-lane machine reproduces the reported mismatch with the old assumption and matches with the new one. Not confirmable here (no AMD GPU): that the same one-lane reading is all that differs on the real device. memorypressure noted that the constant-folded Fma zero-sign exclusion applies to every --oracle gpu run while its reason and the doc named one vendor. The reason is now vendor-neutral, the doc says it was observed on an NVIDIA RTX 4070 only, and a test pins that --oracle hw never uses it. AI-assisted (OpenBot team). Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
…d v_sqrt_f64 After merging current main, CPU seeds 1-3 and `--programs 3000 --seed 9` reported mismatches on v_frexp_mant_f64, v_frexp_exp_i32_f64, v_rsq_f64 and v_sqrt_f64 only, for example `v_frexp_mant_f64 v[8:9], 0x3470fbc87309e9cc` (expected 7309e9cc 3fe0fbc8, actual 00000000 3fe9e9cc), and `--oracle gpu --programs 300 --seed 1` also reported v_rcp_f64 (the CPU run skips it: no OpFDiv in the interpreter). Main's translator now reads the literal of those forms as the upper half of the f64 operand and takes only its low 32 bits, which is the ISA rule for a 32-bit literal (measured on gfx1036); the generator printed a full-width text literal for them. They now get 32-bit literals like the rounding, add, compare and class forms, so the listings are also valid assembler input for --oracle hw. v_div_fmas_f64 and v_div_fixup_f64 keep full-width literals: v_div_fixup_f64 reads a printed 32-bit literal as the low word on main (a 32-bit literal there mismatches the ISA rule; reported, not worked around). Checked on origin/main 561b65a: CPU seeds 1-5 and 7 clean, `--programs 3000 --seed 9` 2737 match / 0 mismatch, a 4000-program run of the affected forms (seed 11) 1980 match / 0 mismatch, and on the RTX 4070 `--oracle gpu` seed 1 (300 programs) 331 / 0 and `--programs 1500 --seed 9` 1460 / 0. A test pins the literal width per form. AI-assisted (OpenBot team). Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
|
Thanks @TreXito, @abnalstlll-byte, @memorypressure and @kapitche (and @kapitche for the re-check at 8803b72). One reply for all four, with what changed. @TreXito: you were right, the @abnalstlll-byte, 8803b72 test failure: @abnalstlll-byte, the gfx1036 mismatch at 7bd5f01 ( @memorypressure: agreed. The zero-sign skip for a constant-folded While validating on current main I also found that the translator now reads the printed literal of Numbers on origin/main 561b65a, each with its seed: CPU AI-assisted (OpenBot team). |
|
Tested |
FUZZ-55 - differential fuzzer for the binary64 (
*_f64) VALU family, claimed in#4257 (comment) (tracked as FUZZ-55 in the
coordination list).
Depends on: none.
Files:
tools/f64_diff.py(new),tests/test_f64_diff.py(new),docs/shader_validation.md(a newharness subsection only; no existing rows are touched).
Scope - the 47
*_f64instruction formsmainactually translates:v_trunc_f64,v_ceil_f64,v_rndne_f64,v_floor_f64(per-source abs/neg on the high word;omod first, then clamp);
v_add_f64(includings_round_modefor MODE.FP_ROUND[3:2]),v_cvt_f32_f64,v_rcp_f64,v_rsq_f64,v_sqrt_f64;v_div_fixup_f64,v_div_fmas_f64;v_frexp_mant_f64,v_frexp_exp_i32_f64;v_cmp_*_f64/v_cmpx_*_f64, plusv_cmp_class_f64/v_cmpx_class_f64.Excluded (not translated on
main;--list-opsnames them):v_mul_f64,v_min_f64,v_max_f64,v_fract_f64,v_cvt_f64_f32,v_ldexp_f64,v_mad_f64,v_cvt_i32_f64,v_cvt_u32_f64,v_div_scale_f64.Design - the
fmisc_diff.py/sad_diff.pyconventions: seeded straight-line programs, standardlibrary only,
python -I,newline="\n"; two independent oracles compared word for word: areference written from the RDNA2 ISA pseudocode with exact rational arithmetic (
Fraction, oneround-to-nearest-even per operation; shares no code with the translator), and
tools/rdna2spirv.pyexecuted through
tests/semantic/spirv_mini_interp.py;--oracle gpuruns the translated SPIR-V onthe local device via the
vk_harness. Exit 0 all match / 1 mismatch (shortest failing program aftershrinking) / 2 harness error / 77 requested hardware oracle unavailable. Skips are always counted
with their reason.
KNOWN_DIVERGENCES (excluded by default;
--knownruns them):div-fixup-nan-s0-v_div_fixup_f64with a NaN quotient: the ISA comment and the measured f32row map
NaN(S0)to+-inf, the translation preserves the payload. Reproduced by--known(3 of 4 probes match, this one mismatches, exit 1 by design) and reported as a
finding:in Coordinating who works on what (23) (moved to #4571) #4421(Coordinating who works on what (23) (moved to #4571) #4421 (comment)) - not fixed in this PR;
f64-omod- the f64 output-modifier forms (SHADER-721, not this PR's to fix);double-neg-abs- the%doubleOpFNegate/FAbsoperand paths, pending TEST-912 (tests: preserve binary64 in SPIR-V negate and abs (TEST-912) #4172);fclamp-nan-zero- the driver-dependentFClampNaN /-0classes.Real runs (Windows 11, Python 3.14; every program synthetic, no game files):
347 total each, skips counted with reasons (exit 0 each). Seed 7, 150 programs,
--max-ops 4:138 matches, 0 mismatches, 197 total (exit 0).
--known --no-sweep --programs 0 --all-failures: 4 probes, 3 match, 1 mismatch(
div-fixup-nan-s0), exit 1 as designed.program) and the run passes again after restoring it;
--self-testplants a translator mismatch,shrinks it to one instruction and checks 10 invariants.
tests/test_f64_diff.py: 16 tests OK. Docs gates:tests/test_docs_links.py6 OK,tests/test_docs_repo_paths.py2 OK,tests/test_docs_list_items.py2 OK,tests/test_text_write_line_endings.py3 OK.python -m compileall -q tools testsclean;git diff --checkclean.Optional GPU oracle (NVIDIA GeForce RTX 4070, subgroup 32, driver 621.01, Windows 11 build 26300,
Vulkan SDK 1.4.363.1, MSVC 14.44;
vk_harnessbuilt in the worktree):--oracle gpu --programs 300 --seed 1: 331 match, 0 mismatch, 347 total, 16 skips (exit 0).--oracle gpu --programs 200 --seed 2 --max-ops 4: 218 match, 0 mismatch, 247 total, 29 skips(exit 0).
v_cvt_f32_f64/v_rcp_f64/v_rsq_f64/v_sqrt_f64(80 programs): 39 match,84 total, 45 skips;
v_cmpx_lt/eq/class(40 programs): 43 match, 43 total, 0 skips.InverseSqrt/Sqrtprecision isimplementation-defined per the SPIR-V contract, NVIDIA flushes subnormal inputs (FTZ), plus the
CPU-interpreter classes.
--oracle hw(AMD RDNA2 hardware oracle) is unavailable on this machineand exits 77 by design; adjudicating the
div-fixupNaN(S0)rule needs an RDNA2 measurement(see Coordinating who works on what (23) (moved to #4571) #4421 (comment)).
No translator changes in this PR: any divergence found is reported as a
finding:in thecoordination issue first. No game data anywhere. AI-assisted (OpenBot team).