Skip to content

rdna2spirv: write out a carry-out subtract of a register from itself (AMD Windows driver crash) (SHADER-SUB-CO-SAME) - #930

Merged
aslan2142 merged 1 commit into
ProjectLeonida:mainfrom
fin-github:shader/sub-co-same-operand
Nov 24, 2026
Merged

aslan2142 merged 1 commit into
ProjectLeonida:mainfrom
fin-github:shader/sub-co-same-operand

Conversation

@fin-github

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: SHADER-SUB-CO-SAME (#14 (comment))

Supersedes draft #324, carried over from the original repository. This is the same commit rebased onto current main, with the original author (Wail) kept and git cherry-pick -x recording where it came from. The change and its explanation are theirs; see #324 for the original description.

Rebase note: one conflict in docs/design.md, where main had rewritten the neighbouring push-constant row. I kept main's row and inserted the new carry-out row before it.

Tested

  • tests/semantic/test_sub_co_same_operand.py: 6 tests pass.
  • Full translator suite python -I scripts/run_semantic_tests.py tests/semantic: 466 files, 6114 tests, 0 failed.
  • Not yet confirmed on hardware. The crash repro (crosslane_fuzz.py --seed 880317 --wave 64 --w64-native on AMD's proprietary Windows driver 25.30, Ryzen 5 7600X iGPU, gfx1036) needs llvm-mc with the AMDGPU target, which isn't installed on this machine yet. I'll post the before/after result here.
  • python -I scripts/check_no_game_data.py on the changed files: clean.

Windows 11 (10.0.26200), Python 3.14.4. No game files, nothing online.

AI-assisted (Claude Code): rebasing, conflict resolution and test runs.

…(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>

@SweatierKey SweatierKey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent verification on origin/main@a28927849:

  • tests/semantic/test_sub_co_same_operand.py (LEONIDA_REQUIRE_SPIRV_TOOLS=1): 6/6 PASS (wave32, native wave64, --wave64-emulate; with and without clamp; verifies no OpISubBorrow is emitted for same-register operands and distinct equal-value registers still use OpISubBorrow).
  • tests/semantic/test_carry_exec_mask.py (LEONIDA_REQUIRE_SPIRV_TOOLS=1): 9/9 PASS.
  • spirv-as --target-env vulkan1.3 + spirv-val --target-env vulkan1.3: 24/24 PASS across all 4 ops (v_sub_co_u32, v_subrev_co_u32, v_sub_co_ci_u32, v_subrev_co_ci_u32) × {clamp=False, True} × {wave32, wave64-native, wave64-emulate}.
  • tests/test_docs_links.py: 16/16 PASS; scripts/check_no_game_data.py: clean.

Clean workaround for the amdvlk64.dll pipeline-creation AV while preserving exact borrow/clamp/EXEC semantics.

AI-assisted: yes

@aslan2142

Copy link
Copy Markdown
Collaborator

Merged. Checked locally on main 4a50cafc7 + 474dbe2be:

One open point, moved here from #739: snain0511's minimal repro does not crash the driver on the base translator either, so the exact shape that crashes amdvlk64.dll is still not reproduced. If you have it, a note here would help.

AI-assisted (Claude Code, Claude Fable 5.2).

milk4sale added a commit to milk4sale/leonida that referenced this pull request Nov 24, 2026
Brings the branch up to date with main 68d1331. No conflicts; the merged tree was tested before the push (every standalone
test file under tests/ passes except tests/test_ci_registration.py, which fails on main alone since ProjectLeonida#930).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
milk4sale added a commit to milk4sale/leonida that referenced this pull request Nov 24, 2026
Brings the branch up to date with main 68d1331. No conflicts; the merged tree was tested before the push (every standalone
test file under tests/ passes except tests/test_ci_registration.py, which fails on main alone since ProjectLeonida#930).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
milk4sale added a commit to milk4sale/leonida that referenced this pull request Nov 24, 2026
Brings the branch up to date with main 68d1331. No conflicts; the merged tree was tested before the push (every standalone
test file under tests/ passes except tests/test_ci_registration.py, which fails on main alone since ProjectLeonida#930).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
milk4sale added a commit to milk4sale/leonida that referenced this pull request Nov 24, 2026
Brings the branch up to date with main 68d1331. No conflicts; the merged tree was tested before the push (every standalone
test file under tests/ passes except tests/test_ci_registration.py, which fails on main alone since ProjectLeonida#930).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
milk4sale added a commit to milk4sale/leonida that referenced this pull request Nov 24, 2026
Brings the branch up to date with main 68d1331. No conflicts; the merged tree was tested before the push (every standalone
test file under tests/ passes except tests/test_ci_registration.py, which fails on main alone since ProjectLeonida#930).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
milk4sale added a commit to milk4sale/leonida that referenced this pull request Nov 24, 2026
Brings the branch up to date with main 68d1331. No conflicts; the merged tree was tested before the push (every standalone
test file under tests/ passes except tests/test_ci_registration.py, which fails on main alone since ProjectLeonida#930).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
milk4sale added a commit to milk4sale/leonida that referenced this pull request Nov 24, 2026
Brings the branch up to date with main 68d1331. No conflicts; the merged tree was tested before the push (every standalone
test file under tests/ passes except tests/test_ci_registration.py, which fails on main alone since ProjectLeonida#930).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
milk4sale added a commit to milk4sale/leonida that referenced this pull request Nov 24, 2026
Brings the branch up to date with main 68d1331. No conflicts; the merged tree was tested before the push (every standalone
test file under tests/ passes except tests/test_ci_registration.py, which fails on main alone since ProjectLeonida#930).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
milk4sale added a commit to milk4sale/leonida that referenced this pull request Nov 24, 2026
Brings the branch up to date with main 68d1331. No conflicts; the merged tree was tested before the push (every standalone
test file under tests/ passes except tests/test_ci_registration.py, which fails on main alone since ProjectLeonida#930).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
milk4sale added a commit to milk4sale/leonida that referenced this pull request Nov 24, 2026
Brings the branch up to date with main 68d1331. No conflicts; the merged tree was tested before the push (every standalone
test file under tests/ passes except tests/test_ci_registration.py, which fails on main alone since ProjectLeonida#930).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
milk4sale added a commit to milk4sale/leonida that referenced this pull request Nov 24, 2026
Brings the branch up to date with main 68d1331. No conflicts; the merged tree was tested before the push (every standalone
test file under tests/ passes except tests/test_ci_registration.py, which fails on main alone since ProjectLeonida#930).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
milk4sale added a commit to milk4sale/leonida that referenced this pull request Nov 24, 2026
Brings the branch up to date with main 68d1331. No conflicts; the merged tree was tested before the push (every standalone
test file under tests/ passes except tests/test_ci_registration.py, which fails on main alone since ProjectLeonida#930).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
milk4sale added a commit to milk4sale/leonida that referenced this pull request Nov 24, 2026
Brings the branch up to date with main 68d1331. No conflicts; the merged tree was tested before the push (every standalone
test file under tests/ passes except tests/test_ci_registration.py, which fails on main alone since ProjectLeonida#930).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
milk4sale added a commit to milk4sale/leonida that referenced this pull request Nov 24, 2026
Brings the branch up to date with main 68d1331. No conflicts; the merged tree was tested before the push (every standalone
test file under tests/ passes except tests/test_ci_registration.py, which fails on main alone since ProjectLeonida#930).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
milk4sale added a commit to milk4sale/leonida that referenced this pull request Nov 24, 2026
Brings the branch up to date with main 68d1331. No conflicts; the merged tree was tested before the push (every standalone
test file under tests/ passes except tests/test_ci_registration.py, which fails on main alone since ProjectLeonida#930).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
milk4sale added a commit to milk4sale/leonida that referenced this pull request Nov 24, 2026
Brings the branch up to date with main 68d1331. No conflicts; the merged tree was tested before the push (every standalone
test file under tests/ passes except tests/test_ci_registration.py, which fails on main alone since ProjectLeonida#930).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
aslan2142 pushed a commit that referenced this pull request Nov 24, 2026
…from a class of its module (TEST-CI-REG-LOCAL-MIXIN)

tests/test_ci_registration.py fails on main since 540d511 (the merge of #930) and passes on its parent:
test_every_selected_file_exposes_a_test_to_its_runner reports tests/semantic/test_sub_co_same_operand.py as a file
the semantic job collects nothing from. `python -m unittest discover -s tests/semantic -p
test_sub_co_same_operand.py` runs 6 tests there. Its three TestCase classes have no test method of their own: they
take them from a mixin class defined in the same file, one TestCase per wave size. defines_a_test looked at a
TestCase's own body and at a base imported from another module, not at a base defined in the module.

It now also counts the test* methods of the classes of the module a TestCase derives from, directly or through
other classes of the module, and an imported base reached that way. unittest's loader lists a class's tests with
dir(), so these are the tests it runs.

The new test writes eight small modules, runs unittest discover on them once and holds the scan to what the runner
collected: a mixin above the TestCase, two classes up, beside a TestCase base without tests, an imported mixin
named directly and through a local class (a test each), and a base without tests, a mixin no TestCase derives
from and a mixin without a TestCase (none). With main's defines_a_test put back, four of the five cases with a
test fail, and so does the repository check.

Over the repository at 51a6074: the scan lists the same 997 test files; of the 473 the semantic job selects,
main's scan found a test in 472 and this one in 473, and test_sub_co_same_operand.py is the only file the two
disagree on (none of the pytest job's 36). unittest's loader collects tests from all 473 (6191 tests, no import
failure), so main's scan disagreed with the runner on that one file and this one on none.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.

4 participants