rdna2spirv: quad_any's docstring says partial quads are exact (DOC-QUAD-ANY-PARTIAL) #2799

Merged
aznohonza merged 3 commits from upstream-pr/2799 into main 2026-12-01 13:51:26 +00:00
aznohonza commented 2026-11-30 23:10:13 +00:00 (Migrated from github.com)

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_any docstring 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 with OpGroupNonUniformBallot, and tests/semantic/test_absent_lane_ub.py::test_quad_any_partial_quad_in_vs_and_cs covers partial VS and CS quads (it asserts the module uses ballot, not QuadSwap or 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.py header 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.py and scripts/check_no_game_data.py on the changed files.

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: wording only, no new rule)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5575461170 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2799). Originally posted by [aznohonza](https://github.com/aznohonza) on 2026-11-30T23:10:13Z. --- Claimed in the coordination issue as: [DOC-QUAD-ANY-PARTIAL](https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7292346799) ### What and why The `quad_any` docstring 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 with `OpGroupNonUniformBallot`, and `tests/semantic/test_absent_lane_ub.py::test_quad_any_partial_quad_in_vs_and_cs` covers partial VS and CS quads (it asserts the module uses ballot, not `QuadSwap` or 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.py` header 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.py` and `scripts/check_no_game_data.py` on the changed files. GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: wording only, no new rule)
OreoFR commented 2026-11-30 23:13:26 +00:00 (Migrated from github.com)

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, main 9dffbe721. CPU only.

READ IN CODE

  • The new docstring matches the code. quad_any has three branches: emulated (exchange buffer), ps (OpGroupNonUniformQuadSwap; fragment quads are always complete), and every other stage, which uses OpGroupNonUniformBallot and 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.
  • The diff only touches the docstring (3+/2−), so translator output can't change.

MEASURED

  • python -I tests/semantic/test_absent_lane_ub.py: 18 tests OK on main 9dffbe721. That file includes test_quad_any_partial_quad_in_vs_and_cs (line 341), the test your description cites.

AI-assisted: Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7294860280 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2799#issuecomment-7294860280). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-30T23:13:26Z. --- Verified by OreoFR on macOS 27.2.1, Apple M5, Python 3.12, head `3587499f4`, main `9dffbe721`. CPU only. **READ IN CODE** - The new docstring matches the code. `quad_any` has three branches: emulated (exchange buffer), `ps` (`OpGroupNonUniformQuadSwap`; fragment quads are always complete), and every other stage, which uses `OpGroupNonUniformBallot` and 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. - The diff only touches the docstring (3+/2−), so translator output can't change. **MEASURED** - `python -I tests/semantic/test_absent_lane_ub.py`: 18 tests OK on main `9dffbe721`. That file includes `test_quad_any_partial_quad_in_vs_and_cs` (line 341), the test your description cites. AI-assisted: Claude Code
aegish-zagi commented 2026-12-01 04:51:10 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aegish-zagi on 2026-12-01T04:51:10Z.


Verification — VERIFY-2799

Verdict: PASS

  • PR: #2799 | head sha: 3587499f4f01375d114887caaaca9069fff0748b | merge state vs main: clean merge with current main 5dd6d444f in a scratch worktree (merge commit eb268b04d), no conflicts. Diff: docstring only in tools/rdna2spirv.py (+3/−2), no code change.
  • Tests run: python -m unittest discover -s tests/semantic -p test_absent_lane_ub.py
    • On PR (merged with main): 18 tests, OK
    • On plain main: 18 tests, OK — identical, as expected for a documentation-only change.
  • Audit (READ IN CODE): the new docstring text matches the implementation it describes. In Gen.quad_any, the non-fragment branch (CS/VS/GS/MS) sets uses_ballot and emits OpGroupNonUniformBallot, 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 with v != 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 in tests/semantic/test_absent_lane_ub.py and passes. No game data.
  • Platform: Linux, Python 3.12.3, no GPU.

AI-assisted: yes (Muse Wonder, Muse by Meta)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7301168093 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2799#issuecomment-7301168093). Originally posted by [aegish-zagi](https://github.com/aegish-zagi) on 2026-12-01T04:51:10Z. --- ## Verification — VERIFY-2799 **Verdict: PASS** - PR: #2799 | head sha: `3587499f4f01375d114887caaaca9069fff0748b` | merge state vs main: clean merge with current main `5dd6d444f` in a scratch worktree (merge commit `eb268b04d`), no conflicts. Diff: docstring only in `tools/rdna2spirv.py` (+3/−2), no code change. - Tests run: `python -m unittest discover -s tests/semantic -p test_absent_lane_ub.py` - On PR (merged with main): **18 tests, OK** - On plain main: **18 tests, OK** — identical, as expected for a documentation-only change. - Audit (READ IN CODE): the new docstring text matches the implementation it describes. In `Gen.quad_any`, the non-fragment branch (CS/VS/GS/MS) sets `uses_ballot` and emits `OpGroupNonUniformBallot`, 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 with `v != 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 in `tests/semantic/test_absent_lane_ub.py` and passes. No game data. - Platform: Linux, Python 3.12.3, no GPU. AI-assisted: yes (Muse Wonder, Muse by Meta)
KelboLive commented 2026-12-01 05:58:40 +00:00 (Migrated from github.com)

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 what docs/design.md:551 and :575 already say. test_absent_lane_ub.py (18/18), test_translate.py -k wqm (13/13) and test_salu_wqm32.py (10/10) pass, and test_quad_any_partial_quad_in_vs_and_cs does 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-7174 still says "vertex, geometry and mesh shaders shuffle". That is stale from before 9e085fa6c replaced 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.
  • The parenthetical is narrower than the code and than your own test: :7206 says "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.
  • "is exact too" lost the qualifier the old sentence had: the ballot reason holds only without emulation — the if self.emulate branch above reads %x_buf, not Ballot.

Minor, outside the diff but about the same rule: tests/semantic/test_salu_wqm32.py:7-8 still claims the vertex path uses OpGroupNonUniformShuffle for quad_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:551 already records this.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6125921451 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2799#pullrequestreview-6125921451). Originally posted by [KelboLive](https://github.com/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 what `docs/design.md:551` and `:575` already say. `test_absent_lane_ub.py` (18/18), `test_translate.py -k wqm` (13/13) and `test_salu_wqm32.py` (10/10) pass, and `test_quad_any_partial_quad_in_vs_and_cs` does 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-7174` still says "vertex, geometry and mesh shaders **shuffle**". That is stale from before `9e085fa6c` replaced 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. - The parenthetical is narrower than the code and than your own test: `:7206` says "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. - "is exact too" lost the qualifier the old sentence had: the ballot reason holds only **without emulation** — the `if self.emulate` branch above reads `%x_buf`, not `Ballot`. Minor, outside the diff but about the same rule: `tests/semantic/test_salu_wqm32.py:7-8` still claims the vertex path uses `OpGroupNonUniformShuffle` for `quad_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:551` already records this.
aznohonza commented 2026-12-01 07:04:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aznohonza on 2026-12-01T07:04:48Z.


Addressed in d696c8650:

  • the stale shuffle clause is gone: the fragment stage uses the 2x2 quad, every other stage ballots;
  • both the docstring and the inline comment now say a partial quad has fewer than 4 of its lanes running, with your case (2 active lanes of a 32-lane subgroup) as the example, not an odd group size;
  • the exactness claim is back inside "without emulation"; the emulated path is stated separately as the exchange-buffer read;
  • tests/semantic/test_salu_wqm32.py's header now says OpGroupNonUniformBallot for quad_any and OpGroupNonUniformQuadSwap only for the fragment stage.

docs/design.md:551 already 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, and scripts/check_no_game_data.py on the changed files. Comment-only, no output change.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7303620808 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2799#issuecomment-7303620808). Originally posted by [aznohonza](https://github.com/aznohonza) on 2026-12-01T07:04:48Z. --- Addressed in d696c8650: - the stale shuffle clause is gone: the fragment stage uses the 2x2 quad, every other stage ballots; - both the docstring and the inline comment now say a partial quad has fewer than 4 of its lanes running, with your case (2 active lanes of a 32-lane subgroup) as the example, not an odd group size; - the exactness claim is back inside "without emulation"; the emulated path is stated separately as the exchange-buffer read; - `tests/semantic/test_salu_wqm32.py`'s header now says `OpGroupNonUniformBallot` for `quad_any` and `OpGroupNonUniformQuadSwap` only for the fragment stage. `docs/design.md:551` already 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`, and `scripts/check_no_game_data.py` on the changed files. Comment-only, no output change.
MoonEyes commented 2026-12-01 08:07:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-01T08:07:11Z.


Verified by MoonEyes (another person than the author) on head d696c8650 merged with main 501b3e6c5: Windows 11, Python 3.14. The diff changes a docstring and comments in tools/rdna2spirv.py and one line of a test's docstring, no code: tests/semantic/test_salu_wqm32.py 10 OK on both sides, so there is no red. I read quad_any next to it: the fragment stage uses QuadSwap and the others ballot, as the new text says.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7304898231 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2799#issuecomment-7304898231). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-01T08:07:11Z. --- Verified by MoonEyes (another person than the author) on head `d696c8650` merged with `main` `501b3e6c5`: Windows 11, Python 3.14. The diff changes a docstring and comments in `tools/rdna2spirv.py` and one line of a test's docstring, no code: `tests/semantic/test_salu_wqm32.py` 10 OK on both sides, so there is no red. I read `quad_any` next to it: the fragment stage uses `QuadSwap` and the others ballot, as the new text says. AI-assisted (Claude Code).
aznohonza commented 2026-12-01 08:36:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aznohonza on 2026-12-01T08:36:08Z.


Thanks — tests/semantic/test_salu_wqm32.py is 10 tests OK here too, and the change is comments and one test docstring only. Nothing further from our side.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7305535782 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2799#issuecomment-7305535782). Originally posted by [aznohonza](https://github.com/aznohonza) on 2026-12-01T08:36:08Z. --- Thanks — `tests/semantic/test_salu_wqm32.py` is 10 tests OK here too, and the change is comments and one test docstring only. Nothing further from our side. AI-assisted.
MoonEyes commented 2026-12-01 13:51:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-01T13:51:23Z.


Merging. Head d696c8650 merges cleanly with main 9f27ba2e1 and 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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7313290093 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2799#issuecomment-7313290093). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-01T13:51:23Z. --- Merging. Head `d696c8650` merges cleanly with `main` `9f27ba2e1` and 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).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!2799
No description provided.