Recompiler: the split-wave64 mask analyses leave out exchanges a program needs (root cause of #505's out-of-step halves) #3758
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 throny on 2026-12-03T02:45:23Z.
What's wrong. On 32-lane GPUs a split 64-lane wave runs as two halves that exchange their masks at set points. Two analyses leave out exchanges they find unneeded: the half-local mask analysis (
gpu/recomp/x64_masks.rs) and the lazy planner (gpu/dxil/kernel.rs,mask_exchange::plan_of). In some programs they leave out one that is needed. The halves fall out of step, the next exchange gives up after its spin limit, and the wave reads zeros from then on. On #505 that showed as a dark, dotted picture and 31-40 ms GPU calls. Found by theaustinayers, with data from KDenKC and us.Now. #3748 keeps every exchange by default.
XCL_X64_PRECISE_MASKS=1turns the analyses back on and brings the problem back. Open PRs that leave out more exchanges (#1111, #1193) build on the same analyses.What's needed. The pattern the analyses get wrong. A first step: with
XCL_X64_PRECISE_MASKS=1and a longer spin limit (theaustinayers' localXCL_X_SPIN_LIMIT), log which program and which exchange site a half gives up at, then reduce that program to a test that fails on the GPU. KDenKC's list on #505 names seven compute programs with 31.4-31.9 ms calls.AI use: Claude Code (Claude Opus 5.5) wrote this at throny's request.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-03T10:00:20Z.
Twelve small synthetic programs reproduce this deterministically on an RTX 3090 (driver 621.47, Windows 11 22631). They come from the #3716 wave64 fuzzer, are compute programs in the direct split form, and contain no data from any application. With the analyses on (the default on
main), all 12 give wrong words in every run so far. WithXCL_X64_ALL_MASKS=1(= #3748's default) all 12 are right.XCL_X64_ALL_MASKS=1main5ad98adb+ #3716d2293dcb+ a test-only probe + a local change that passes group-shared indices instead of pointers to the split helpers7b19e27d+ #3716d2293dcb+ the same probeSeeds: 155, 525, 824, 1869, 1000823, 1001176, 1001212, 1001676, 1001998, 2000677, 3000171, 3000294. Four controls (2, 10, 11, 188) are right either way. On
main5ad98adb+ #3716 with the helpers as they are, turning off only the lazy planner (a local probe) also made all 12 right. The DXIL of the default form gives the reference words in a CPU interpreter that runs the two halves in a fixed interleaving. So the wrong words come from how the GPU runs that DXIL, not from the translation's logic. I first read that as the halves getting out of step; a first reduction (below, when confirmed) points instead to the lower half's own word of one compare being read as 0 on the 3090, with the exchange still paired.To run them: branch
probe/direct-split-nv(main5ad98adb+ #3716 + an ignored probe):It prints one
SUMMARYline;G6=n/12counts these programs that match the RDNA2 reference. SetXCL_X64_ALL_MASKS=1to compare. A 3070 Laptop GPU (621.40) gaveG6=1/12in the default form (on #3779), so it is not only this card. I am now separating which of the two analyses the failure needs, and will post the reduced program here.AI use: Claude Code (Claude Opus 5.5) ran the fuzz programs on the 3090 and in the CPU interpreter and wrote this; checked and posted by me.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-03T10:55:24Z.
Follow-up with the reduced program, and a split between the two analyses. This is about one program on one GPU. In it, no exchange is left out and none gives up. The analyses keep one compare's mask as a half-local pair. The RTX 3090 then reads the lower half's own word of that pair as 0.
Which analysis. We ran 17 cases on one test exe, the reduced program, the 12 seeds and the 4 controls, with one switch at a time. The tree is #3707
7b19e27d+ #3716d2293dcb+ test-only probes; the GPU is an RTX 3090, driver 621.47.plan_of(.., lazy = false), local probe)whole_livecleared, so every ballot is exchanged where it is made; plan unchanged; local probe)plan_of(skip = false), local probe)XCL_X64_ALL_MASKS=1The controls 2, 10, 11 and 188 are right in every form. Turning off either analysis alone is enough. Turning off the local skips is not.
Reduced program. Seed 1000823 shrinks to 120 instructions: 96 threads, 2 groups,
s0=0xFFFFFFFA, memory zeroed. It gives 128 wrong words:v1in both groups.v1.The part that matters:
The whole program (120 instructions)
DXIL at that site.
Default form (the pair stays half-local; the halves only exchange EXEC, at the branch; value names shortened):
select(upper, recv, ballot), and there is noselect(upper, 0, ballot).and(select(upper, recv, ballot), exec_lo). It is the same value as the default form's%290in the lower half.select(upper, 0, ballot)at this site; the default has one.Not out of step (measured on the CPU). A small interpreter of the emitted DXIL runs the lanes of a wave together and joins them at post-dominators. It interleaves the waves at random and runs the spin loop as written. On the default DXIL it gives the reference words, both exchanges pair up, and no wait reaches its limit.
To match the 3090, we zeroed each of the 296 values of
main, one at a time, in the lower halves and then in both halves.v10 != v4, its ballot,select(upper, 0, ballot),exec_lo, and theirand.v1 = 0. The lone half with no partner did not enter.So, for this issue: in this program the analyses move the exchange from the compare to the EXEC branch, which is correct in the interpreter. The failure needs the half-local pair
select(upper, 0, ballot)that they leave in place of the exchange. It is close to #3779's shape (select(upper, 0, X), then a lane-bit test). But reading the word from the first lane before the bit test does not fix these 12 programs: the branch reads 0 too. The #505 programs may still be a real left-out exchange; this result does not show that either way.Stack.
7b19e27d(on main078358a0) + #3716d2293dcb+ local test-only probes. They switchXCL_PROBE_PLAN_MODE=nolazy|noskip(passeslazy/skip= false toplan_of) andXCL_PROBE_NO_HALFLOCAL(clearsLw::whole_liveafter the plan). None of this is in a PR.5ad98adb+ #3716d2293dcb+ the probe (driver 616.56), then rerun on the tree above (621.47).AI use: Claude Code (Claude Opus 5.5) ran the probes, the reduction and the interpreter and wrote this; checked and posted by me.