rdna2spirv: quad_any's docstring says partial quads are exact (DOC-QUAD-ANY-PARTIAL) #2799
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2799"
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 aznohonza on 2026-11-30T23:10:13Z.
Claimed in the coordination issue as: DOC-QUAD-ANY-PARTIAL
What and why
The
quad_anydocstring said an absent invocation in a partial quad gives an undefined value natively. That is stale: the non-fragment branch already answers partial quads exactly by reading each lane's activity withOpGroupNonUniformBallot, andtests/semantic/test_absent_lane_ub.py::test_quad_any_partial_quad_in_vs_and_cscovers partial VS and CS quads (it asserts the module uses ballot, notQuadSwapor an unguarded shuffle). This changes comments only; no translation output changes.After review, three more stale lines in the same docstring/comment and one in a test header: the docstring no longer says the vertex, geometry and mesh shaders shuffle (they ballot); a partial quad is described as fewer than 4 of the quad's lanes running (a partial wave such as 2 active lanes of a 32-lane subgroup, not only a size that is not a multiple of 4); the exactness claim is limited to the non-emulated path; and the
tests/semantic/test_salu_wqm32.pyheader now says the vertex path uses ballot, not a shuffle.Tested
CPU only, no game files or GPU:
python -I tests/semantic/test_absent_lane_ub.py— 18 tests pass.python -I tests/semantic/test_salu_wqm32.py— 10 tests pass.python -m compileall -q tools/rdna2spirv.pyandscripts/check_no_game_data.pyon the changed files.GPUs tested: n/a
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: wording only, no new rule)Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-30T23:13:26Z.
Verified by OreoFR on macOS 27.2.1, Apple M5, Python 3.12, head
3587499f4, main9dffbe721. CPU only.READ IN CODE
quad_anyhas three branches: emulated (exchange buffer),ps(OpGroupNonUniformQuadSwap; fragment quads are always complete), and every other stage, which usesOpGroupNonUniformBallotand takes this lane's 4-bit quad nibble. With ballot, an absent lane is simply 0, so partial quads are exact, as the new text says. The old line ("undefined value natively") described the code before the ballot branch.MEASURED
python -I tests/semantic/test_absent_lane_ub.py: 18 tests OK on main9dffbe721. That file includestest_quad_any_partial_quad_in_vs_and_cs(line 341), the test your description cites.AI-assisted: Claude Code
Imported from ubiquitarianism/leonida. Originally posted by aegish-zagi on 2026-12-01T04:51:10Z.
Verification — VERIFY-2799
Verdict: PASS
3587499f4f01375d114887caaaca9069fff0748b| merge state vs main: clean merge with current main5dd6d444fin a scratch worktree (merge commiteb268b04d), no conflicts. Diff: docstring only intools/rdna2spirv.py(+3/−2), no code change.python -m unittest discover -s tests/semantic -p test_absent_lane_ub.pyGen.quad_any, the non-fragment branch (CS/VS/GS/MS) setsuses_ballotand emitsOpGroupNonUniformBallot, then extracts this lane's 4-bit quad nibble from the ballot word; the in-code comment at that branch states ballot bit l is set iff lane l is running withv != 0, so the result is exact on partial subgroups — which is precisely what the corrected docstring now says, replacing the stale 'undefined value natively' claim. The covering test named in the PR (test_quad_any_partial_quad_in_vs_and_cs) exists intests/semantic/test_absent_lane_ub.pyand passes. No game data.AI-assisted: yes (Muse Wonder, Muse by Meta)
Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T05:58:40Z.
Review: COMMENTED
The new sentence matches the code: the non-fragment branch ballots
v != 0(tools/rdna2spirv.py:7211), ORs the selected word and masks the quad nibble (:7223-7225), so absent lanes contribute 0 and the result is exact for the running lanes — which is also whatdocs/design.md:551and:575already say.test_absent_lane_ub.py(18/18),test_translate.py -k wqm(13/13) andtest_salu_wqm32.py(10/10) pass, andtest_quad_any_partial_quad_in_vs_and_csdoes exercise a partial quad (VS with lanes 5 and 6 of 32, CS with a two-lane workgroup, both in the strict interpreter).But the change leaves the docstring contradicting itself two lines above:
:7173-7174still says "vertex, geometry and mesh shaders shuffle". That is stale from before9e085fa6creplaced the shuffle path with ballot for CS/VS/GS/MS, and it now reads as two different mechanisms in one paragraph. Fix that clause here ("the fragment stage uses the 2x2 quad; the other stages ballot"), or the next editor will follow the wrong one.:7206says "subgroup size or thread count not a multiple of 4", while the new text says "a group whose size is not a multiple of 4" — your VS case is 2 active lanes of a 32-lane subgroup, i.e. a partial wave, not an odd group size.if self.emulatebranch above reads%x_buf, notBallot.Minor, outside the diff but about the same rule:
tests/semantic/test_salu_wqm32.py:7-8still claims the vertex path usesOpGroupNonUniformShuffleforquad_any, while the test itself asserts QuadSwap for PS and Ballot at:312-313— its header is stale. No contract-table change is needed;docs/design.md:551already records this.Imported from ubiquitarianism/leonida. Originally posted by aznohonza on 2026-12-01T07:04:48Z.
Addressed in
d696c8650:tests/semantic/test_salu_wqm32.py's header now saysOpGroupNonUniformBallotforquad_anyandOpGroupNonUniformQuadSwaponly for the fragment stage.docs/design.md:551already describes the code, so no contract row changes. Checks:python -I tests/semantic/test_absent_lane_ub.py(18 pass),python -I tests/semantic/test_salu_wqm32.py(10 pass),python -m compileall -q tools/rdna2spirv.py, andscripts/check_no_game_data.pyon the changed files. Comment-only, no output change.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-01T08:07:11Z.
Verified by MoonEyes (another person than the author) on head
d696c8650merged withmain501b3e6c5: Windows 11, Python 3.14. The diff changes a docstring and comments intools/rdna2spirv.pyand one line of a test's docstring, no code:tests/semantic/test_salu_wqm32.py10 OK on both sides, so there is no red. I readquad_anynext to it: the fragment stage usesQuadSwapand the others ballot, as the new text says.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by aznohonza on 2026-12-01T08:36:08Z.
Thanks —
tests/semantic/test_salu_wqm32.pyis 10 tests OK here too, and the change is comments and one test docstring only. Nothing further from our side.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-01T13:51:23Z.
Merging. Head
d696c8650merges cleanly withmain9f27ba2e1and does not force a rebase of #2566. CI green on this head and on main. Comments and a docstring only, no code: the test passes on both sides; I read quad_any against the new text. Merged by MoonEyes.AI-assisted (Claude Code).