Direct-split compute: a lane-bit test gives a wrong result on NVIDIA (RTX 3090, drivers 616.56 and 621.47), right on WARP; plain-HLSL repro #3779
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 ivall/xcl. Originally posted by CharlyRien on 2026-12-03T08:10:55Z.
A small wave32 compute shader gives a wrong result on an RTX 3090 with two drivers (616.56 and 621.47), and the right one on WARP. XCL's direct split form, which runs a wave64 console program as two 32-lane halves, emits DXIL of this shape, and 58 programs from the #3716 fuzzer fail on this GPU because of it. This is group 5 of my #3716 review. The repro is plain HLSL compiled by DXC and needs nothing from XCL. Its input comes from the fuzzer and holds no data from any application.
It looks like the same family as #3772 (a lane reading its own bit of a mask word gets it wrong on NVIDIA, right on WARP), but in compute and with a different shape.
Measured
-O3-Od-O1)-O1)Both drivers give the same 31 wrong words, so a driver update does not fix it here. Results from other GPUs and drivers are welcome (see "How to check another GPU").
The shader
cs_6_6,[WaveSize(32)],[numthreads(64,1,1)], one group: two waves of 32 that share groupshared memory and barriers, the way the direct split form runs one wave64. Each wave takes a "lane" base 0 or 32 from a groupshared counter.In it,
bit = ((upper ? 0 : e) >> l31) & 1withe = 0x3FFFFFFF & ~lo, andlois 0 in every thread. Lane 0 must therefore take bit 0 = 1 and getv17 = v4.-Od):v17of lanes 0..29 = that lane'sv4, lanes 30..63 =0xFFFFFFFF;s37=v4of lane 0 =0x9b3e8bcd;s46=0x3FFFFFFF.-O3:v17=0xFFFFFFFFin every lane, ands37=0xFFFFFFFF.s46is right: the same thread storesecorrectly, then reads its bit 0 as 0.What the failure needs (one-flag variants of the shader, measured on the 3090):
-DTHEN=0: remove the firstif (t != 0)block, which never runs-DTHEN=2: make that block a plainv2 = bit ? v6 : v2-DXCH2=0: remove theWaveReadLaneAt+ groupshared exchange + barriers in the secondifv17right-DUHALF=1: takeupperfrom the wave-uniform base instead ofbase + WaveGetLaneIndex()In the DXC output both
ifblocks test a bit of a mask with the same shape,(select(upper, 0, X) & (1 << lane)) != 0:X = %40in the first,X = %61 = %40 ^ 0x3FFFFFFFin the second. The wrong result is what the second block would give with%40instead of%61. That is my reading of the DXIL; I have not seen the driver's ISA.repro.hlsl
Bindings: three root UAVs (
u0input,u1output,u2unused),Dispatch(1,1,1). In both buffers, dwords 0..127 are "scalars" (s37,s46,s47= dwords 37, 46, 47), then lanelhas 256 dwords from128 + 256*l(vN= dwordN). The input setsv2 v3 v4 v6 v7 v17per lane ands37 s46 s47; everything else is 0. The input words, both DXC disassemblies and the translator's own DXIL container are on the branch below.How to check another GPU
Branch
probe/direct-split-nv(6612772a, on #3716 atd2293dcb, itself onmain5ad98adb):It prints one
SUMMARYline (GPU, driver, wave sizes, the HLSL repro at-O3/-Od, and how many of the 58 + 12 fuzz programs pass).On the XCL side
WaveReadLaneFirstjust before the bit test inlanebit(dxil/lanes.rs) makes all 58 programs pass on the 3090 (8,000-seed fuzz run). It also turns one other seed wrong on the 3090, deterministically. That form only reads words that are already uniform, so the 3090 seems to miscompile it too. A narrower variant, applied only where one half of the mask is a constant (the shape here), is written but not run yet.G6in the summary line). They are a different case: they pass withXCL_DXIL_NO_OPTand crash WARP. Not understood yet; not part of this report.Setup
d3d10warp.dll1.0.23 with the Agility SDK 1.621.0, the same DXIL.AI use: Claude Code (Claude Opus 5.5) shrank the program, wrote the repro and the probe, ran the 3090 and WARP checks and wrote this; checked and posted by me.
Imported from ivall/xcl. Originally posted by Raul-Paiva on 2026-12-03T09:26:07Z.
Ran your probe on an RTX 3070 Laptop GPU (driver 621.40 / 32.0.16.2140, Win10 19045, DXC 1.8.2502.11),
probe/direct-split-nv6612772a:0xffffffffinstead of0x9b3e8bcd 0xa5bad59b 0x73b7d5f0 0x80000000.-Gison the O3 compile: still MISMATCH, with the same 31 words, and -Od still matches. So on this card it's not DXC's fast math.Mismatch("memory dword 0", 3606620596, 0, 240).Separately, the fast-math part of #3716 (items 3 and 4:
0 - x→ −0 andinf - inf→ 0) is in #3778, which compiles the translated HLSL with-Gis.Imported from ivall/xcl. Originally posted by Gevroska on 2026-12-03T11:15:06Z.
I reproduced the 31 wrong words on my RTX 3080 with SDK DXC
1.9.2602.17. I ran each variant three times and compared all 131 output words after the GPU fence completed.-O3-O3 -Gis-O3-Od-O3 -DTHEN=0-OdIn every failing run,
v17on lanes 0–29 and scalars37read0xffffffff. Restricting the groupshared stores to one writer preserved the failure, so concurrent writers aren’t required to reproduce it on this card. Removing the dead branch with-DTHEN=0made the optimized case pass. The-O3and-O3 -GisDXIL containers were byte-identical with this compiler. My WARP device skipped before dispatch because it lacked wave32 support.AI disclosure: OpenAI Codex GPT-6.2 Sol ran the GPU comparison. GPT-6 Sol (Daybreak) checked all 18 readbacks, and a separate GPT-6.2 Sol reviewer verified the evidence. GPT-6.2 Astra drafted this comment.
I reviewed and approved this comment before posting.
Imported from ivall/xcl. Originally posted by stijn-boer on 2026-12-03T11:37:06Z.
Ran
probe/direct-split-nvat6612772aon an AMD Radeon RX 9060 XT (driver32.0.32029.2010, Windows 10 build19044.6332, DXC1.9.2609.5). The original run and both reruns produced the same summary:-O3and-Od— Both matched with zero wrong words in both reruns. I used the stock probe flags.CreateComputePipelineStatewith0x887A0005(DXGI_ERROR_DEVICE_REMOVED) in both reruns. The first failure was seed155, immediately afterUnknown pointer operation encountered during ParseAddress. Seed1000823returned the same device error, so there was no output comparison for it. The logs do not establish which operation caused the removal.AI use
Codex (GPT-6) prepared the test builds, ran the tests, reviewed the diff, and drafted this report.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-03T12:51:25Z.
@stijn-boer thanks for the AMD run. About the G6
DXGI_ERROR_DEVICE_REMOVEDatCreateComputePipelineState("Unknown pointer operation encountered during ParseAddress"):6612772ais #3716d2293dcbonmain5ad98adb. That base has #3655 but not #3707.xcl.spin.wait(i32 addrspace(3)*, i32 addrspace(3)*, ...)andxcl.barrier.arrive), called twice each. I read that in the DXIL I dumped on the 3090 for seeds 155 and 1000823.So I think the AMD driver's compiler rejects the same thing, and that
mainwith #3707 does not hit it. I have no AMD card to check, so that is a guess, not a measurement. The G5 programs pass on your card, which fits: I expect they have no exchange, so they have no such helper. I have not checked their DXIL.If you can rerun G6 on a tree with #3707, that would settle it.
On NVIDIA, G6 now has a workaround: on the RTX 3090, reading each word of the half-local mask pair with
WaveReadLaneFirstafter itsselectfixes all 12 G6 programs, plus seed 358, with no new failure over the 8,000 seeds. Measured on #3707 + #3716d2293dcbwith a local switch. A PR follows.AI use: Claude Code (Claude Opus 5.5) read the DXIL and the PRs and wrote this; checked and posted by me.
Imported from ivall/xcl. Originally posted by stijn-boer on 2026-12-03T13:02:12Z.
@CharlyRien I reran the unchanged
probe/direct-split-nvat6612772a59e601afb77c4f43490e19221c2acf83on currentmaina815de932c4dc8da3b383ca44f4b094aa406fec9, the upstream #3707 merge. The clean local probe merge was7ca751b9bff41bad89ee8ee888ab26ad96732bc8. I used the stock flags and added no other PRs.G6 changed from 0/12 to 12/12 on AMD. All three sequential runs printed the same line:
155and1000823. There were no G6 device-removal errors orUnknown pointer operation encountered during ParseAddressmessages in these runs.-O3and-Odreturned zero wrong words each time.Setup: RX 9060 XT, driver 32.0.32029.2010, Windows 10 build 19044.6332, DXC/DXIL 1.9.2609.5, and Agility SDK 1.620.2. Command:
cargo test -p xcl --lib direct_split_driver_probe -- --ignored --nocapture --test-threads=1. Each invocation reported 1 passed, 0 failed, 0 ignored, and 0 skips.This confirms the failure is gone on current main with #3707. Compared with the older probe base, the result is consistent with the helper-inlining explanation. The two bases include other changes as well, so this run does not isolate the compiler mechanism.
AI use: OpenAI Codex (GPT-6, exact variant unavailable) prepared the probe merge, ran it, and drafted this report.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-03T13:12:32Z.
@stijn-boer thanks, that settles the AMD side: G6 runs and matches on
maina815de93with #3707, so the device removal came from the older base, as you say without isolating the mechanism.That leaves G6 on NVIDIA. I tested a workaround on the RTX 3090 (
WaveReadLaneFirstof each word of the half-local mask pair, after itsselect). I am preparing it as a PR ona815de93and will link it here. Your run also shows thatmainalready gives the right G6 results on RDNA4 without it.AI use: Claude Code (Claude Opus 5.5) wrote this; checked and posted by me.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-03T15:04:43Z.
The NVIDIA workaround for G6 is now #3792 (draft): in the split wave64 form, each word of a half-local mask pair is read once more with
WaveReadLaneFirstwhere the pair is made. On the RTX 3090 (driver 621.47), onmaina815de93+ #3716de05c50e, over the 8,000 fuzz seeds: 203 programs differ from the reference without it, 193 with it (10 fixed, 0 new). On AMD, @stijn-boer's run above already matched on all 12 G6 programs withmain(#3707), so this is for NVIDIA only so far.AI use: Claude Code (Claude Opus 5.5) ran the fuzz and wrote this; checked and posted by me.