rdna2spirv: write out a carry-out subtract of a register from itself (AMD Windows driver crash) #739

Closed
github-bot wants to merge 1 commit from gh-pr/739/head into gh-pr/739/base
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 13:13 UTC · original
abnalstlll-byte:restore/old-10058-sub-co-same-operand → main · +216 −11 · 3 files · 1 commits · closed without merging

### Summary
Restores and updates work from draft PR #324 (old-pr/10058 / item OLD-10058).
Original commit by @⁠wail-arch (183d63f55).

v_sub_co_u32 / v_subrev_co_u32 and their _ci_ forms with the same operand twice were translated to OpISubBorrow %x %x. AMD's Windows driver dies with an access violation (0xC0000005 in amdvlk64.dll, 32.0.21037.1004 and 32.0.21045.29003, gfx1036) creating a native wave64 compute pipeline in which that borrow predicates the value operand of an OpGroupNonUniformShuffle.

x - x is 0 with no borrow, so these forms now emit D = 0 - carry in and borrow out = carry in, with no OpISubBorrow. Values are unchanged; other operand pairs are translated as before.

Verification

  • python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_sub_co_same_operand.py docs/design.md -> Clean (no game data)
  • python -m unittest discover -s tests/semantic -p test_sub_co_same_operand.py -> 6/6 PASS in 2.07s
  • Clean rebase onto latest ubi/main (21625bca8).

AI-assisted verification and rebase by Antigravity (Autonomous Direct Mode).

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 13:13 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/739) `abnalstlll-byte:restore/old-10058-sub-co-same-operand` → `main` · +216 −11 · 3 files · 1 commits · closed without merging ### Summary Restores and updates work from draft PR #324 (`old-pr/10058` / item `OLD-10058`). Original commit by @⁠wail-arch (`183d63f55`). `v_sub_co_u32` / `v_subrev_co_u32` and their `_ci_` forms with the same operand twice were translated to `OpISubBorrow %x %x`. AMD's Windows driver dies with an access violation (`0xC0000005` in `amdvlk64.dll`, 32.0.21037.1004 and 32.0.21045.29003, gfx1036) creating a native wave64 compute pipeline in which that borrow predicates the value operand of an `OpGroupNonUniformShuffle`. `x - x` is 0 with no borrow, so these forms now emit `D = 0 - carry in` and `borrow out = carry in`, with no `OpISubBorrow`. Values are unchanged; other operand pairs are translated as before. ### Verification - `python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_sub_co_same_operand.py docs/design.md` -> Clean (no game data) - `python -m unittest discover -s tests/semantic -p test_sub_co_same_operand.py` -> 6/6 PASS in 2.07s - Clean rebase onto latest `ubi/main` (`21625bca8`). AI-assisted verification and rebase by Antigravity (Autonomous Direct Mode).
v_sub_co_u32 / v_subrev_co_u32 and their _ci_ forms with the same operand
twice were translated to OpISubBorrow %x %x. AMD's Windows driver dies with
an access violation (0xC0000005 in amdvlk64.dll, 32.0.21037.1004 and
32.0.21045.29003, gfx1036) creating a native wave64 compute pipeline in which
that borrow predicates the value operand of an OpGroupNonUniformShuffle.

x - x is 0 with no borrow, so these forms now emit D = 0 - carry in and
borrow out = carry in, with no OpISubBorrow. Values are unchanged; other
operand pairs are translated as before.

Found with crosslane_fuzz.py --seed 880317 --wave 64 --w64-native
--no-maskdata --dpp --ext --programs 400 on a Ryzen 9 9950X3D iGPU:
programs 1 and 181 were harness errors (exit 3221225477) and now match
(399 of 400 match; the other differs only in a hypothesis op, as before).

- docs/design.md: contract row "Carry-out subtract of a register from itself"
- tests/semantic/test_sub_co_same_operand.py: values and borrow mask in
  wave32 and native wave64, the emitted form with --wave64-emulate

Not counted over the corpus, and two different registers holding equal
values still reach OpISubBorrow.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:18:51 +00:00
github-bot closed this pull request 2026-11-26 09:18:52 +00:00
Author
Owner

@⁠GeorgiyDemo on GitHub · 2026-11-24 13:26 UTC · original

Tested b7de4d80 on Apple M5 Pro, macOS 26.7.3 (25G342), Python 3.15.2, against main d42773d07:

  • tests/semantic/test_sub_co_same_operand.py: 6 tests OK at this head.
  • The same file against main's translator fails 24 times, so the carry-out subtract of a register from itself is covered by the new cases.

No GPU leg and no way to reproduce the reported crash here: AMD's Windows driver is not available on this machine, and no runtime/test/shaders fixture uses v_sub_co_u32/v_subrev_co_u32 with the same operand twice. AI-assisted; synthetic fixtures only, no game data.

**@⁠GeorgiyDemo** on GitHub · 2026-11-24 13:26 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/739#issuecomment-7132832224) Tested `b7de4d80` on Apple M5 Pro, macOS 26.7.3 (25G342), Python 3.15.2, against `main` `d42773d07`: - `tests/semantic/test_sub_co_same_operand.py`: 6 tests OK at this head. - The same file against `main`'s translator fails 24 times, so the carry-out subtract of a register from itself is covered by the new cases. No GPU leg and no way to reproduce the reported crash here: AMD's Windows driver is not available on this machine, and no `runtime/test/shaders` fixture uses `v_sub_co_u32`/`v_subrev_co_u32` with the same operand twice. AI-assisted; synthetic fixtures only, no game data.
Author
Owner

@⁠snain0511 on GitHub · 2026-11-24 14:28 UTC · original

Tested b7de4d80 on AMD Windows hardware, including the driver build named in the description.

Setup: Windows 11 10.0.26200.9974, AMD 26.11.2. Ryzen 5 7600X iGPU (gfx1036) on driver version 32.0.21045.29003, one of the two this PR reports crashing; RX 9070 (GFX1201) on 32.0.32029.2010. vk_compute_test built from main d0da7dade (MSVC 19.44), llvm-mc 21.1.8.

CPU: tests/semantic/test_sub_co_same_operand.py: 6/6 OK at this head. With tools/rdna2spirv.py swapped back to the base 21625bca8, the same file fails (24 failures), so the test does detect the old translation.

GPU: I wrote a local wave64 compute shader (not committed) with the pattern the description gives: v_sub_co_u32 v8, vcc, v2, v2, then v_cndmask_b32 v9, v2, 0, vcc, and v9 as the data of ds_bpermute_b32. In the base translator's SPIR-V the borrow of OpISubBorrow %x %x reaches the value operand of OpGroupNonUniformShuffle through VCC and an OpSelect (2 OpISubBorrow); with this PR there are none. Both pass spirv-val. vk_compute_test ... 1 dump --require-wave64 (subgroup 64):

GPU, driver base 21625bca8 this PR
7600X iGPU, 32.0.21045.29003 pipeline created, exit 0, 36 316 253 0 (expected) exit 0, 36 316 253 0
RX 9070, 32.0.32029.2010 exit 0, 36 316 253 0 exit 0, 36 316 253 0

So this minimal form of the pattern does not crash amdvlk64.dll 32.0.21045.29003 on gfx1036 here, and the PR gives the same correct values. That doesn't rule out the crash: the shader that hit it may need more around the shuffle than this one has. If you can say which fixture or shape crashed (counts or a hand-written repro, no game shader), I'll run it on this iGPU, without and with the PR. No game files used.

AI-assisted: yes

**@⁠snain0511** on GitHub · 2026-11-24 14:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/739#issuecomment-7134445796) Tested `b7de4d80` on AMD Windows hardware, including the driver build named in the description. **Setup:** Windows 11 10.0.26200.9974, AMD 26.11.2. Ryzen 5 7600X iGPU (gfx1036) on driver version **32.0.21045.29003**, one of the two this PR reports crashing; RX 9070 (GFX1201) on 32.0.32029.2010. `vk_compute_test` built from `main` `d0da7dade` (MSVC 19.44), llvm-mc 21.1.8. **CPU:** `tests/semantic/test_sub_co_same_operand.py`: 6/6 OK at this head. With `tools/rdna2spirv.py` swapped back to the base `21625bca8`, the same file fails (24 failures), so the test does detect the old translation. **GPU:** I wrote a local wave64 compute shader (not committed) with the pattern the description gives: `v_sub_co_u32 v8, vcc, v2, v2`, then `v_cndmask_b32 v9, v2, 0, vcc`, and `v9` as the data of `ds_bpermute_b32`. In the base translator's SPIR-V the borrow of `OpISubBorrow %x %x` reaches the value operand of `OpGroupNonUniformShuffle` through VCC and an `OpSelect` (2 `OpISubBorrow`); with this PR there are none. Both pass spirv-val. `vk_compute_test ... 1 dump --require-wave64` (subgroup 64): | GPU, driver | base `21625bca8` | this PR | |---|---|---| | 7600X iGPU, 32.0.21045.29003 | pipeline created, exit 0, `36 316 253 0` (expected) | exit 0, `36 316 253 0` | | RX 9070, 32.0.32029.2010 | exit 0, `36 316 253 0` | exit 0, `36 316 253 0` | So this minimal form of the pattern does **not** crash `amdvlk64.dll` 32.0.21045.29003 on gfx1036 here, and the PR gives the same correct values. That doesn't rule out the crash: the shader that hit it may need more around the shuffle than this one has. If you can say which fixture or shape crashed (counts or a hand-written repro, no game shader), I'll run it on this iGPU, without and with the PR. No game files used. AI-assisted: yes
Author
Owner

@⁠Sangonapou on GitHub · 2026-11-24 14:54 UTC · original

Tested b7de4d80 on NVIDIA GeForce RTX 3080 Ti Laptop (Ampere, subgroup 32..32, mesh shaders), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300), native Windows: pass, regression check (NVIDIA side; the AMD driver case is covered above)

Runtime built at this head with scripts\build_runtime.ps1 (MSVC 19.51, VS Build Tools 2026, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0). No game files.

  • Full run_gpu_tests.py: 257 shaders, 257 translated, 257 pass spirv-val; native 197/248 passed, 49 skipped; LEONIDA_W64_EMULATE=1 229/248 passed, 17 skipped. The only failures are cs_imgload_tfe and cs_imgload_d16_tfe, which fail identically on main 2d73c242 on this card (#31 / #336).
  • CPU: tests/semantic/test_sub_co_same_operand.py 6 OK.
**@⁠Sangonapou** on GitHub · 2026-11-24 14:54 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/739#issuecomment-7135135790) Tested b7de4d80 on NVIDIA GeForce RTX 3080 Ti Laptop (Ampere, subgroup 32..32, mesh shaders), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300), native Windows: pass, regression check (NVIDIA side; the AMD driver case is covered above) Runtime built at this head with `scripts\build_runtime.ps1` (MSVC 19.51, VS Build Tools 2026, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0). No game files. - Full `run_gpu_tests.py`: 257 shaders, 257 translated, 257 pass spirv-val; native 197/248 passed, 49 skipped; `LEONIDA_W64_EMULATE=1` 229/248 passed, 17 skipped. The only failures are `cs_imgload_tfe` and `cs_imgload_d16_tfe`, which fail identically on `main` `2d73c242` on this card (#31 / #336). - CPU: `tests/semantic/test_sub_co_same_operand.py` 6 OK.
Author
Owner

@⁠thesubtleties on GitHub · 2026-11-24 17:12 UTC · original

For whoever merges: #324, #739 and #930 change exactly the same lines in tools/ and tests/ (heads 183d63f55, b7de4d802, 474dbe2be). #324 conflicts with main in docs/design.md; #739 and #930 merge cleanly, so one of them is enough. On main 98a977b4 the shared test file has 24 failures without the change and passes with it. I could not check the AMD Windows driver crash (Linux here). No game files. AI-assisted (Claude Code).

**@⁠thesubtleties** on GitHub · 2026-11-24 17:12 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/739#issuecomment-7138855104) For whoever merges: #324, #739 and #930 change exactly the same lines in `tools/` and `tests/` (heads `183d63f55`, `b7de4d802`, `474dbe2be`). #324 conflicts with `main` in `docs/design.md`; #739 and #930 merge cleanly, so one of them is enough. On `main` `98a977b4` the shared test file has 24 failures without the change and passes with it. I could not check the AMD Windows driver crash (Linux here). No game files. AI-assisted (Claude Code).
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-24 22:09 UTC · original

Thanks for carrying this forward, and thanks to everyone who tested it. I'm closing this as a duplicate of #930.

  • Merged onto main, #739, #930 and #1093 are the same patch (git patch-id --stable matches) and give the same tree.
  • When patches are identical, the earliest valid claim in #14 decides. #930's claim (SHADER-SUB-CO-SAME, 15:02 UTC) is the only one posted before its pull request; #14 has no claiming: line for this item from this account. This PR was opened first, at 13:13 UTC, but without a claim.
  • For future restorations, please post claiming: <item> in #14 before opening the pull request.
  • The test reports here (macOS, gfx1036 on 32.0.21045.29003 and an RX 9070, an RTX 3080 Ti) apply to #930 as well, because the change is the same. The open question from snain0511 about the exact shape that crashes the driver can move there.

AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-24 22:09 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/739#issuecomment-7145871122) Thanks for carrying this forward, and thanks to everyone who tested it. I'm closing this as a duplicate of #930. - Merged onto `main`, #739, #930 and #1093 are the same patch (`git patch-id --stable` matches) and give the same tree. - When patches are identical, the earliest valid claim in #14 decides. #930's claim (`SHADER-SUB-CO-SAME`, 15:02 UTC) is the only one posted before its pull request; #14 has no `claiming:` line for this item from this account. This PR was opened first, at 13:13 UTC, but without a claim. - For future restorations, please post `claiming: <item>` in #14 before opening the pull request. - The test reports here (macOS, gfx1036 on 32.0.21045.29003 and an RX 9070, an RTX 3080 Ti) apply to #930 as well, because the change is the same. The open question from `snain0511` about the exact shape that crashes the driver can move there. AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.