Translated mesh programs: some waves get wrong register values on an RTX 5090 (128-lane groups that vote) #458
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 brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T08:53:25Z.
A translated mesh program decides a guest scalar branch by a vote in group memory (
tb_page_ballot), and guards what the branch skips withif (tb_skip < T) { ... }. On an RTX 5090 (driver 620.70.10) the first lanes of a 128-lane group can have wrong values in registers such a block sets, although no lane skips it.Self-contained shader, plain Vulkan
No D3D12, vkd3d-proton or Wine: a small runner and SPIR-V from DXC and dxil-spirv. Every lane must report 6.
The 3 forms with the branches as selects, with the first block as selects, or with the vote not used are right as mesh too. The reduced shader below has no barrier after the skip, so live values across barriers are not needed. Only 3 of 98 forms fail and small edits hide it, so we do not know the exact trigger.
Translated programs
Every export of every lane against the same program as compute, three groups, all vertex counts up to the program's limit:
Programs 2 to 4 ran with their bindless resources replaced by stubs, and as sized descriptors.
Other things that do not fix program 1: reading the value again (912 lanes wrong), an extra barrier, an atomic vote, atomic reads, a first-lane read of the decision. It is wrong with DXC 1.8.2505.1 and 1.9, -O0 included.
The change
In mesh programs that vote, a guarded block is not a block: each register write selects on the skip, and each memory access keeps a one-statement branch whose value is selected.
In a game
With only program 1's one block always run (a hand-made shader, not this change), in ProjectScarlett on an RTX 5090, the crash whose fault program counter ends in
0x70(our largest class of device losses) happened in 0 of 10 runs, against 5 of 10 with the original (one-sided Fisher p = 0.016; interleaved runs,mainat28717263plus #436, #389, #390 and diagnostics). Runs of the changed arm still lost the device later in other ways. The change itself has not been run in a game.What this does and does not show
Reduced shader (plain Vulkan, lanes 0..31 wrong on the 5090)
The larger one it comes from, for D3D12
Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T09:06:02Z.
Some prior art, so nobody starts from zero. None is an exact match, and no public report I found has this combination (mesh shader, workgroup vote, guarded block, wrong first subgroup on NVIDIA). These look related:
if, used in a later guarded statement, hidden by tiny edits) is modular/modular#7178. Whether the graphics path got the fix isn't stated.ByteAddressMask), so this isn't excluded yet.Two things in the issue above are weaker than they read. The trigger (the merge at the skip) is inferred: most small edits hide the fault, so a passing edit says little, and there's one known NVIDIA bug elsewhere that miscompiles selects too. And "reading the value again doesn't fix it" holds for the full export set, not for the smaller test.
Next tests, no driver change needed: inline or don't-inline that helper, compile with optimisation disabled, and a control that keeps the branches but changes as much code. Not tested: other NVIDIA cards, or the newer 620.73.04 driver.
Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T09:11:01Z.
A control, which answers part of the doubt above. 64 edits (reordering, different constants, extra statements) were applied to the two shrunk shaders, each in four versions: with the branch, with the branches as selects, with the first block as selects, and with the vote taken but not used.
So the same edits are wrong with the branch and right without it, which is much stronger evidence for the branch being necessary than single edits hiding the fault. The two shrunk shaders are also right on an AMD iGPU (RADV), as mesh and compute.
It doesn't explain why, and it doesn't rule out that a different shape (without the branch) fails. The related inlining question (above) is untested. A sweep of 41 counts of live values in a D3D12 mesh case, translated with and without our change, gave no wrong result either way, so that case is not a regression test.
Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T09:27:12Z.
A correction to the first comment above: the
ByteAddressMaskhelper call doesn't explain the failures seen in D3D12. vkd3d-proton doesn't emit it by default (read in its source; a dump of one program's compute form has one function and no calls; its mesh form on the 5090 isn't dumped yet). The call is in the reduced plain-Vulkan shaders only, so it can be a cause there. Whether those and the D3D12 programs fail for the same reason is inferred.Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T11:13:01Z.
A correction: my control above was not the right one, and the branch is not established as the trigger. I ran the test that could disprove it, with the criterion set beforehand: the same 64 edits of the two reduced shaders, each also with changes that keep the skip branches. 45 of 64 are wrong unchanged.
So two changes that keep the branch hide it as often as removing it, and selects are no evidence that the branch causes it. Small changes (the xor) mostly don't. Please don't build on "the skip's merge" from this issue.
What also holds, on five reduced modules in plain Vulkan (compute forms are all right): the mesh fault stays with the
ByteAddressMaskhelper inlined, marked Inline or DontInline, or absent (0 calls), withVK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT(inlined or not), and withMaximallyReconvergesKHRandSubgroupUniformControlFlowKHR. A subgroup barrier after the merges made 2 of 5 right. So the helper call isn't needed for it, and neither the optimiser-disable bit nor these modes avoid it.Still true: it's right on RADV, and for three translated programs the output with #459's change is right where the old one is wrong. That those programs fail for the same reason as the reduced ones is inferred. #459 is held as a draft.
Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T12:04:40Z.
Progress, with the controls this time. On an RTX 5090 (620.70.10), in plain Vulkan and through D3D12:
index + zeroorindex ^ zero(a zero the compiler can't know) 45 of 45, none made wrong. In three translated title programs, the sameindex ^ zerois right in every export and size where the original, and the thread id, are wrong.So what matters looks like what the compiler knows about the index in a full 128-lane group. I'd read it as a candidate workaround of one line, not as a cause, until a random sample of programs is run. It's the third idea that fitted the data I had, and two didn't survive, so please wait for that.
Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T13:16:33Z.
The test I said to wait for: 150 voting mesh programs picked at random (fixed seed, 30 per size class), none of them used for tuning, run as mesh against their compute form. 148 could run (2 use an unsupported resource kind); 147 of those did. Every vertex count sample, counts, indices and vertex words compared; textures and heap views stubbed.
^an unknown zero (root constant)^(SV_GroupID.x >> 16)Neither hidden form made a right program wrong. (One more program couldn't run in any form; its root was refused.)
What matters, by controls on 64 edits of the reduced shaders (45 wrong): hiding the zero from a folding compiler matters (
group.x & 0andSubgroupSize >> 8fix 0 of 45;group.x >> 1645 of 45); hiding the low bits doesn't (1 of 45), hiding the partlane >> 5sees does (45 of 45); hiding it in that single use is enough in the reduced shaders, and hiding it in every other use isn't. So the compiler acts on "these 32 lanes share one value" for the vote word's index. Agroup.x >> 16costs one xor and needs no resource: a D3D12 dispatch dimension is at most 65,535, so it is 0 in every legal dispatch.Not explained: why only exactly 128 threads, and why only mesh. It's a workaround, and I'll post it as a PR when the final form and both cards' full checks are done. #459 is superseded.
If someone has another NVIDIA card (or a different driver, e.g. 620.73.04), the synthetic shader in the first post is enough to say whether it's the same.
Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T13:20:51Z.
Two corrections and the PR.
Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-29T21:58:14Z.
The workaround, #473 (hiding the lane number of voting mesh programs), is on
main, and your population test showed it takes the RTX 5090 from 48 wrong programs to none with no regressions on AMD. The cause looks like the driver's handling of exactly 128-thread mesh groups, not ours. Closing as worked around. Reopen if you'd rather keep it open to track the driver side, or if a voting mesh program goes wrong again.