Shader tests: a cross-device VALU fuzzer (hardware adapters vs WARP) #1613
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1614"
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 Marvisak/VIctory. Originally posted by alexdeliu on 2026-11-24T19:47:24Z.
An ignored test that looks for shaders that compute different values on different GPUs. Every VOP3-encoded opcode the translator lowers runs as a one-thread compute shader on every hardware adapter and on WARP, on the same inputs, and the test reports where the devices disagree. The inputs are signed zeros, denormals, infinities, quiet and signalling NaNs, integer and f16 edges in either half, and seeded pseudo-random dwords.
Comparison rules:
rcp,rsq,sqrt,log,exp,sin,cos) get a few ULPs.A disagreement means the translation leans on behaviour that DXIL leaves to the device. The test is test-only and doesn't run in CI:
Environment variables:
VICTORY_FUZZ_CASES: inputs per opcode (default 160).VICTORY_FUZZ_OPS: comma-separated name filter.VICTORY_FUZZ_OUT: write a Markdown report.Each device runs alone, because two at once suspend WARP. A removed device is released before a new one is made, because D3D12 hands back the same removed device while a reference is alive.
What it found on
main@ffe310ebDevices: RX 9070 (RDNA4), Ryzen 7700 iGPU (gfx1036, RDNA2) and WARP. 212 opcodes, 200 inputs each.
v_cmp_*_{i64,u64}wrong when the operands share a dwordlegacyF32ToF16fcmp false/fcmp true(v_cmp_f/tru_f{16,32}) remove the devicev_min/max/min3/max3/med3_f32,v_cubesc/tc_f32,v_sin_f32v_fma_f32/v_fmac_f32are fused on AMD and not on WARP (1 ULP)FMadshortcut (lower.rs)v_cvt_f32_u32misrounds,v_log_f32is 20% off at1 - 2^-24The full report and the per-opcode tables are in the gist: https://gist.github.com/alexdeliu/ef9ef0ebc1776ff104b5aa8eaea18e87
Later commits add VOP3P (
v_pk_*,v_fma_mix*) and modifier variants (VICTORY_FUZZ_MODS=1): #422 also fixes the packed f16 ops andv_fmac_f16/v_fma_f16on AMD.Checks
#[ignore]d, socargo test --workspaceis unchanged.🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T19:56:46Z.
Review: APPROVED
Verified locally merged onto
origin/main(Windows 11 x64, Rust 1.98.1 MSVC):cargo test -p victory-shader --lib emit::fuzz_tests::— compiles cleanly and respects#[ignore]cargo clippy -p victory-shader --all-targets— 0 warningscargo xtask policy— okClean opt-in cross-device VALU fuzzer comparing hardware adapters against WARP. Looks good.
AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T20:05:27Z.
Review: COMMENTED
Static review only:
fuzz_testsis#[cfg(all(test, windows))]and every case is#[ignore]d (run viacargo test -p victory-shader --lib fuzz_tests -- --ignored), so nothing here executes on macOS (suite stays at 96). The harness design is sound — deterministic cross-device VALU fuzzing of hardware adapters vs WARP with per-case reporting is exactly what this codebase needs for the lowering churn. Two requests: (1) wire the--ignoredrun into the Windows CI leg (or document the exact command in the PR/README), since ignored tests rot quickly; (2) a note on how failures are minimized/reportered (shrinking to a minimal VALU case would make reports actionable).Imported from Marvisak/VIctory. Originally posted by alexdeliu on 2026-11-24T20:33:18Z.
@catminou4 thanks, both done in
f1125da, and @DenRakEiw thanks for the approval:cargo test --workspace. I didn't wire it into CI: the fuzzer only learns something by comparing two devices, and CI's runners have WARP alone. With fewer than two SM 6.6 devices it now returns ("nothing to compare") instead of failing. The useful runs are the ones contributors make on their own GPUs. @DrDarkDK's RTX 4070 Ti + Ryzen iGPU run on #1599 is the model.Imported from Marvisak/VIctory. Originally posted by tumbubu on 2026-11-24T21:51:46Z.
A run on RDNA3 (RX 7900 XT): same findings as on the RX 9070 and gfx1036, nothing specific to RDNA3.
c3372c1,cargo test -p victory-shader --locked --lib fuzz_tests -- --ignored --nocapture --test-threads=1, default 160 inputs. RX 7900 XT, driver 32.0.31036.15, Windows 11 26300.v_med3_f16, at 2 of 200 there, which 160 inputs may not reach. Counts per opcode are in the same range: i64/u64 compares 57 to 110,v_cubetc_f3232,v_sin_f3254,v_pk_add_f1611, and so on.v_cmp_f/tru_f{32,16}("device instance has been suspended"), as in your table (#1326). The 7900 XT lost no device.v_cvt_f32_u32(0xde84975e)=0x4f5e8498against0x4f5e8497on the 7900 XT: the same WARP misrounding you report. There is a second case:0xeb8bc49bgives0x4f6b8bc4on WARP and0x4f6b8bc5on AMD.v_cos_f32at half a turn gives exactly-1.0(0xbf800000) on the 7900 XT against0xbf7ffff9on WARP. That is WARP being inexact once more (FIND-5).The full report is available if useful. AI-assisted (Claude Code); every run was on this machine.
Imported from Marvisak/VIctory. Originally posted by tumbubu on 2026-11-24T22:30:23Z.
The new
mainon RDNA3: the same 17 disagreements as on the RX 9070 and gfx1036, and no lost device.50cbc89(this PR merged onto70564ae),VICTORY_FUZZ_CASES=200. RX 7900 XT, driver 32.0.31036.15, against WARP.ffe310e: 31 differ, 4 lost).70564aein #1633:v_cmp_{lt,le,gt,ge}_{i64,u64}(#1599);v_fma_f32/v_fmac_f32;v_cubesc/tc_f32(#1766);v_cvt_f32_u32,v_log_f32,v_sin/cos_f32,v_sin_f16.ffe310etable exactly for the i64/u64 compares (79 to 138),v_cubetc_f32(45) andv_sin_f32(63).v_sin_f16is 14 here against 11 in the gist, which ran before77053a0changed f16 rounding.So on all three AMD generations the f16 rounding, min/max/med3 and WARP device-loss findings are gone with
77053a0.AI-assisted (Claude Code); every run was on this machine.
Imported from Marvisak/VIctory. Originally posted by DeerSilver on 2026-11-24T23:06:31Z.
Ran the fuzzer at
50cbc89on a machine with two hardware adapters, so all three columns are filled. Setup: one laptop with an NVIDIA GeForce RTX 5060 Laptop GPU (Blackwell,10de:2d59, driver 621.24) and an Intel UHD Graphics (Raptor Lake Xe-LP,8086:a788, driver 32.0.101.7088), Windows 11 26300, Rust 1.98.1. The PR was merged ontomain70564ae.cargo test --workspace --all-features --locked --no-fail-fast -- --test-threads=1with the D3D12 debug layer on (VICTORY_D3D12_DEBUG=1, and a local, uncommitted change that also turns the debug layer on in victory-shader's testHost): 475 passed, 5 failed, 8 ignored (the fuzzer is the new ignored one). The 5 failures are the onesmain70564aehas by itself on NVIDIA (the view-heap cap and the structured-view stride, already reported in #1744); this PR adds none.cargo clippy --workspace --all-targets --locked -- -D warnings, with and without--all-features: cleancargo test --locked -p victory-shader --lib fuzz_tests -- --ignored --nocapture --test-threads=1withVICTORY_FUZZ_OUTset and default settings (160 inputs) finished in 1583 s in a debug build. 243 opcodes compared on the RTX 5060 Laptop, the Intel UHD and WARP: 28 differ, 107 refused by the translator, 0 lost a device.I also ran the earlier head,
c3372c1, onffe310e: 234 compared, 31 differ, 4 lost. The difference between the two runs shows what themainupdate changed. Thev_min/max_f32,v_min3/max3_f32andv_med3_f32differences are gone. So are the 4 WARP device losses onv_cmp_f/tru_f32/f16. Everything below still differs on70564ae. For each opcode the table names the odd device out, counted over the rows the report shows:v_cmp_lt/eq/le/gt/lg/ge/nge/nlg/ngt/nle/neq/nlt_f16)v_cmp_le_f16(0x0001, 0x8001)is 1 on Intel, 0 on the RTX and WARPv_cmp_o_f32,v_cmp_u_f32v_cmp_o_f32(NaN, π)is 1 on Intel. This looks like thefcmp ord/unofold that med3 had, and these two compares don't use the bit testv_cvt_flr_i32_f32(7),v_cvt_rpi_i32_f32(14)70564ae. A NaN input gives0on Intel and0x7fffffffor0x80000000on the RTX and WARP. I haven't checked which one RDNA2 givesv_mac_f32,v_mad_f32,v_fract_f32(1–2 rows each)v_cubesc_f32,v_cubetc_f320x80000001) that Intel and WARP flush to-0v_sin_f16(34),v_log_f32(3)0x0003/0x0006/0x0006), precisionv_sin_f32(57),v_cos_f32,v_fmac_f32,v_fma_f32,v_cvt_f32_u32I stopped the
VICTORY_FUZZ_MODS=1pass before it finished. I can attach either report (about 38 KB of synthetic inputs and results) if that helps.No game data used. AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T03:31:33Z.
Automated triage for the maintainers.
Merge candidate. This adds an
#[ignore]d test,emit/fuzz_tests.rs, that runs each lowered VOP3/VOP3P opcode as a one-thread compute shader on every hardware adapter and on WARP and reports where they disagree, plus a short README note. It is test-only, uses only the existingwindowsfeatures andHost, holdsONE_AT_A_TIME, and writes a file only whenVICTORY_FUZZ_OUTis set. Since the last review it has three changes. It mergesmainand fills in the newview_marksfields.agreenow takes a result's type from the first type token in the opcode name, which is right forv_cvt_*andv_dot2_f32_f16alike.hardware_adaptersnow also requiresDedicatedVideoMemory > 0, ashost.rs'shardware_adapterdoes.Thanks for taking up the adapter nit; that point is resolved.
CI: passing (
check).Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by alexdeliu on 2026-11-25T05:00:34Z.
Merged
main(940d32f) in as170a6c8;03593cbfollows it.03593cbaddsview_marks(cd94d35) and takes up the triage nit:hardware_adaptersnow requires dedicated video memory as well as no software flag, likehost.rs'shardware_adapterfrom #1911/#1925. On the RX 9070 + gfx1036 machine, both CI clippy runs are clean andcargo test --workspace --lockedpasses, except the 2 PSV0 testsmainitself fails with the SDK'sdxil.dll1.7. A full fuzz of the newmainis running; I'll post it if anything changed from the 17 known disagreements.Imported from Marvisak/VIctory. Originally posted by alexdeliu on 2026-11-25T05:23:50Z.
The full fuzz of
940d32fon the RX 9070, gfx1036 and WARP (200 inputs per opcode) shows the same 17 disagreements as before. There are now 251 opcodes compared, up from 243 (8 more are lowered), and 0 lost devices.c147a18fixes a fuzzer classification bug: an op likev_dot2_f32_f16had its f32 result treated as f16 for NaN matching. The result type is now the first type in the name. It changes no finding here.upstream-sync referenced this pull request2026-11-25 07:03:15 +00:00
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T01:25:46Z.
Code review and triple-adapter (NVIDIA RTX 5090 + AMD Radeon iGPU + WARP) verification at head
c147a1894e56merged ontomain(63bcca43c6a0;emit/lower.rsuntouched):main(crates/victory-shader/src/emit/fuzz_tests.rs:716):victory-shaderfails to compile onmain(63bcca43):error: cannot construct 'emit::host::Host' with struct literal syntax due to private fieldsHostnow has a privatewarp: boolfield (emit/host.rs:17-20, 194-197); changingOk(Host { device })atfuzz_tests.rs:716toOk(Host::from_device(device))fixes compilation andclippycleanly with 0 warnings.agree()edge notes (fuzz_tests.rs:376-391):let float = name.contains("_f") || ...matches integer-destination conversions likev_cvt_i32_f32/v_cvt_u32_f32, which would let integer results> 0x7F80_0000(e.g.i32::MAX) pass asis_f32_nan; checking the destination type (first type suffix) avoids false matches.approximatef16path) compare onlya & 0xFFFF/b & 0xFFFFwithout verifying the preserved upper halfa >> 16 == b >> 16(unlike line 380's NaN branch), and0x7BFFvs0x7C00(+inf) are 1 bit apart.Host::from_device(device)):cargo xtask policy:192 files ok;cargo clippy --locked -p victory-shader --tests -- -D warnings: 0 warningsVICTORY_FUZZ_OPS=v_add_f32,v_rcp_f32,v_pk_add_f16,v_bfe_u32 VICTORY_FUZZ_CASES=32 VICTORY_FUZZ_MODS=1 cargo test --locked -p victory-shader --lib fuzz_tests -- --ignored --nocapture(withdxil.dll10.0.26100.0):Passed across NVIDIA GeForce RTX 5090 + AMD Radeon Graphics + WARP (
18 opcodes compared, 32 inputs each; 0 differ; 0 refused by the translator; 0 lost a device, 51.07s).Updating line 716 to
Host::from_device(device)will make this build cleanly onmain.Imported from Marvisak/VIctory. Originally posted by ColorMeBoom on 2026-11-26T19:12:14Z.
RDNA1 run on current main — RX 5700 XT (Navi 10), driver 32.0.21045.29003, Windows 11 26200; main
63bcca4with this PR merged locally.Build note: on current main
fuzz_tests.rs:716no longer compiles (Hosthas a privatewarpfield);Ok(Host::from_device(device))fixes it.251 opcodes × 160 inputs: 4 differ, 99 refused, 0 device losses. All four are transcendental:
v_log_f32(1/160):log2(1 − 2⁻²⁴), RX 5700 XT0xb3b8aa3cis right, WARP0xb3e00000is ~21 % off (FIND-5).v_cos_f32(4/160): near 0.5/1 revolution the RX 5700 XT gives the correctly rounded ±1.0, WARP is 7 ULP off.v_sin_f16(12/160): on the rows checked the RX 5700 XT is right and WARP is ~10 f16 ULP off.v_sin_f32(54/160): mixed. On small inputs the RX 5700 XT is ~6–7 ULP low (sin(2π·2⁻¹²⁶):0x01c90fd5, exact0x01c90fdb); on others WARP flushes to 0 or is percent-level off.None of the findings in the PR description (i64 shared-dword compares, f16 rounding, denormals) show up on RDNA1 at current main.
AI use: Claude Code (Claude Opus 5.5).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.