Skip to content

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

Closed
abnalstlll-byte wants to merge 1 commit into
ProjectLeonida:mainfrom
abnalstlll-byte:restore/old-10058-sub-co-same-operand
Closed

abnalstlll-byte wants to merge 1 commit into
ProjectLeonida:mainfrom
abnalstlll-byte:restore/old-10058-sub-co-same-operand

Conversation

@abnalstlll-byte

Copy link
Copy Markdown
Contributor

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).

…(AMD Windows driver crash)

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 <noreply@anthropic.com>
@GeorgiyDemo

Copy link
Copy Markdown
Contributor

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.

@snain0511

Copy link
Copy Markdown
Contributor

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

@Sangonapou

Copy link
Copy Markdown
Contributor

Tested b7de4d8 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.

@thesubtleties

Copy link
Copy Markdown
Contributor

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).

@aslan2142

Copy link
Copy Markdown
Collaborator

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants