W64-APPEND-CONSUME-BARRIER-REGRESSION: guard one-wave branch barriers #2803
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2803"
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 ubiquitarianism/leonida. Originally posted by thiefyzheng on 2026-12-01T00:15:22Z.
Claimed in the coordination issue as: W64-APPEND-CONSUME-BARRIER-REGRESSION (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7296006442)
What and why
Adds a mutation-sensitive regression test for
ds_append/ds_consumethrough the Wave64 optimizer. In a 128-thread shader only wave 0 enters the SCC branch; the wave-wide LDS counter operation requires an isolated mini-scheduler and real workgroup barriers. The test checks the structured-hybrid plan, mini-scheduler, emittedOpControlBarriers, and the append/consume atomic operation.Previously, restoring the source to its pre-classifier form left all 31 PR tests green (finding: https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7288312704). This shape fails when either classifier entry is removed instead of merely restating the classifier membership.
Tested
python3 -I tests/semantic/test_wave64_emulate_opt.py— 36 tests, OK.ds_appendalone andds_consumealone from_ALWAYS_BARRIER_OPS(and clearing the metadata cache) each makes its new subtest fail atrdna2spirv.py:unexpected OpControlBarrier in sync-free multi-wave block. Restoring the entries gives the green result above.python3 -m compileall -q tests/semantic/test_wave64_emulate_opt.py,scripts/check_no_game_data.pyon the changed file, andgit diff --check: clean.python3 -I scripts/run_semantic_tests.py tests/semantic— 553 files, 6,721 tests, 0 files failed in 386 s with 8 jobs. No hardware shader corpus/GPU comparison performed.GPUs tested: n/a (synthetic CPU translation only)
AI-assisted: yes (Kimi K3.1 Pro lead, GLM 5.3 Flash review)
Checklist
mainand merges cleanly.Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-01T00:20:07Z.
Verified by OreoFR on macOS 27.2.1, Apple M5, Python 3.12, head
8aada4fc2, mainb7a1be296. CPU only, synthetic translation.MEASURED
tests/semantic/test_wave64_emulate_opt.pygives 36 passed, 40 subtests passed, both on main + this test and on main + the PR (merge-tree)."ds_append"in_ALWAYS_BARRIER_OPS(tools/wave64_emulate_opt.py:137): 1 failed, 35 passed. The failure istest_append_consume_in_one_wave_branch_keeps_workgroup_barriers (op='ds_append'), withunexpected OpControlBarrier in sync-free multi-wave block."ds_consume": 1 failed, 35 passed. Same test, subtestop='ds_consume', same message.READ IN CODE
_ALWAYS_BARRIER_OPSis used atwave64_emulate_opt.py:316(op in _ALWAYS_BARRIER_OPS), which is the path the mutation changes.AI-assisted: Claude Code
Imported from ubiquitarianism/leonida. Originally posted by thiefyzheng on 2026-12-01T00:25:17Z.
Additional local verification on the same head
8aada4fc2d012a22081383911a36c18f77b58eb1: fullpython3 -I scripts/run_semantic_tests.py tests/semanticcompleted with 553 files, 6,721 tests, 0 files failed in 386 s using 8 jobs. Still no GPU or hardware-corpus run; this is the no-game-data synthetic suite.Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-01T01:16:29Z.
Verified on Windows, and the test does what its comment claims: it catches a mutation that the other 35 tests in the file do not.
The PR only adds a test, so the check that matters is not "do the tests pass" - they pass on the base too, which is what
scripts/red_green.pycorrectly reported asverdict: no red. The check is whether the new test catches the change it was written for. So I made the change it names, intools/wave64_emulate_opt.py:141only:Result, at this head,
maind920d850dplus the PR:So the comment's sentence - "Removing either op from
_ALWAYS_BARRIER_OPSlet every existing test pass even though this shape reaches the sync-free-block assertion" - is exactly right, and this is the test that stops it. Both subtests fail independently, which is what thefor op in (...)loop is for.What I could not verify: that the shape reaches the real assertion in a real translation - the test asserts
spv.count("OpControlBarrier") >= 3and the plan's steps, not that a later stage rejects it. That is enough for the claim as written ("keeps workgroup barriers"), and it is not the same as proving the sync-free-block path fires.One note on my first attempt, since it is a trap: I removed the ops by matching the text, and that also hit a second set (
"ds_consume", "ds_append", "ds_ordered_count",), which made the "other tests" arm fail and would have made me report the opposite conclusion. The precise cut is the line in_ALWAYS_BARRIER_OPSand nothing else.AI-assisted: yes - DeepSeek v4.1 (flash).
Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T05:54:17Z.
Review: COMMENTED
The guard is real, and I checked it the right way: with
ds_appendords_consumeremoved from_ALWAYS_BARRIER_OPS(tools/wave64_emulate_opt.py:137-143), in a fresh process, exactly this test fails atrdna2spirv.py:22752(unexpected OpControlBarrier in sync-free multi-wave block), while the other 35 tests in the file andtest_ds_append.py/test_absent_lane_ub.pystay green. So it is the missing guard, not a restatement. 36/36 with the entries restored;check_no_game_dataandgit diff --checkclean.The fixture is hand-built (ten synthetic instructions, 128 threads, wave 0 takes the branch and wave 1 skips), not a clipped game shader, and the assertions are the right ones for the regression: plan
structured_hybrid, amini_schedulerstep, emittedOpControlBarriers, and the append/consume atomic. No full instruction list, so no over-pinning.One thing to be aware of rather than change:
OpControlBarrier >= 3is the only hard threshold. If a future plan legitimately emits fewer barriers for this shape the test will fail even though the translation is correct — the file's own SPIR-V interpreter could check barrier uniformity instead, or the count could be tied to the plan step. The plan-mode and step strings match the neighbouring tests (:1423,:1532-1535), so that part follows house style. No blockers from this review.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-01T07:30:38Z.
Verified by MoonEyes (another person than the author) on head
8aada4fc2merged withmain9372a4d4f: Windows 11, Python 3.14.tests/semantic/test_wave64_emulate_opt.py36 OK. By mutation, withds_appendandds_consumeout of_ALWAYS_BARRIER_OPS, exactly this test fails (both subtests), as KelboLive found.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-01T08:17:49Z.
Merging. Head
8aada4fc2merges cleanly withmain1d73465e8and does not force a rebase of #2566. CI green on this head and on main. fiestorra and KelboLive checked it on this head by mutation; I did the same on main + PR (Windows, Python 3.14): 36 tests OK, and removing ds_append and ds_consume from the barrier list fails only this test. MoonEyes asked for this merge. A test only. Merged by MoonEyes.AI-assisted (Claude Code).