Shader tests: a cross-device VALU fuzzer (hardware adapters vs WARP) #1614
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1614
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@alexdeliu on GitHub · 2026-11-24 19:47 UTC · original
alexdeliu:valu-fuzz→main· +724 −0 · 3 files · 8 commits · openAn 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
The fuzzer also runs every VOP3P opcode the translator lowers (v_pk_*, v_fma_mix*), comparing each f16 half on its own and the high half of v_fma_mixhi_f16, with any NaN matching any NaN. On main, v_pk_add_f16, v_pk_fma_f16 and v_fma_mix{lo,hi}_f16 differ on AMD (f16 rounded toward zero by legacyF32ToF16); with #422 the RX 9070, a gfx1036 iGPU and WARP agree on all of them. Co-Authored-By: Claude Opus 5.5 <[email protected]>@alexdeliu on GitHub · 2026-11-24 20:33 UTC · original
@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.@tumbubu on GitHub · 2026-11-24 21:51 UTC · original
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.
@tumbubu on GitHub · 2026-11-24 22:30 UTC · original
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.
@DeerSilver on GitHub · 2026-11-24 23:06 UTC · original
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).
@Marvisak on GitHub · 2026-11-25 03:31 UTC · original · edited 2026-11-25 06:22 UTC
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
@alexdeliu on GitHub · 2026-11-25 05:00 UTC · original
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.@alexdeliu on GitHub · 2026-11-25 05:23 UTC · original
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.@fuzeofficlal on GitHub · 2026-11-26 01:25 UTC · original
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.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.