rdna2spirv: apply src0 float modifiers after bound_ctrl zero selection (SHADER-DPP-NEG-BOUND-CTRL) #1778

Manually merged
github merged 3 commits from gh-pr/1778/head into gh-pr/1778/base 2026-11-26 10:04:42 +00:00
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-25 11:56 UTC · original
abnalstlll-byte:feat/shader-dpp-neg-bound-ctrl → main · +93 −2 · 3 files · 3 commits · merged 2026-11-25 19:19 UTC

Claimed in the coordination issue as: SHADER-DPP-NEG-BOUND-CTRL (claim)

What and why

Implements the hardware measurement by @⁠mcpeacebir-lang on AMD RDNA3 (RX 7800 XT, HW-DPP-NEG-INVALID-LANE, addressing @⁠OreoFR's finding in Issue #1608):

"Result: on RDNA3 the hardware applies src0's neg after the bound_ctrl zero. An invalid source lane reads -0, not the +0 Gen.dpp_insn gives it on main. abs gives +0, as expected."

Previously, Gen.dpp_insn (tools/rdna2spirv.py:7353) evaluated src_val = self.src_u(src) before the shuffle and bound check under the assumption that "neg/abs are lane-uniform, so before or after the shuffle is the same". Then at line 7523, src0 = OpSelect %uint %src_ok %shuffled %zero selected %zero (0x00000000 / +0.0f) for invalid lanes (bound_ctrl:1 or DPP8 fi:0), which wiped out the float negation on invalid lanes and caused them to read +0.0f instead of -0.0f.

This fixes the ordering:

  1. Strips neg and abs from raw_src before evaluating src_val = self.src_u(raw_src) so the raw register bits are shuffled across lanes.
  2. Selects src0 = OpSelect %uint %src_ok %shuffled %zero.
  3. Calls src0 = self.modify(src0, src) after the zero selection, applying FAbs / OpFNegate to the selected result. An invalid lane reading 0.0f with neg becomes -0.0f (0x80000000), with abs becomes +0.0f (0x00000000), and with -|src0| becomes -0.0f.
  4. Documents the confirmed hardware behavior in docs/design.md.
  5. Adds semantic test fixture tests/semantic/test_dpp_bound_ctrl_modifiers.py verifying wave execution and SPIR-V instruction structure.

Tested

  • python -m unittest tests/semantic/test_dpp_bound_ctrl_modifiers.py: 2/2 tests pass (0.03s).
  • python -m unittest discover -s tests/semantic -p "*dpp*.py": 19/19 tests pass.
  • python -I tests/test_text_write_line_endings.py: 3/3 pass (clean line endings).
  • python -I scripts/check_no_game_data.py: clean (0 violations, no game data).

AI-assisted (Claude Code)

**@⁠abnalstlll-byte** on GitHub · 2026-11-25 11:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1778) `abnalstlll-byte:feat/shader-dpp-neg-bound-ctrl` → `main` · +93 −2 · 3 files · 3 commits · merged 2026-11-25 19:19 UTC Claimed in the coordination issue as: SHADER-DPP-NEG-BOUND-CTRL ([claim](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608)) ### What and why Implements the hardware measurement by @⁠mcpeacebir-lang on AMD RDNA3 (RX 7800 XT, `HW-DPP-NEG-INVALID-LANE`, addressing @⁠OreoFR's finding in Issue #1608): > "Result: on RDNA3 the hardware applies src0's `neg` after the bound_ctrl zero. An invalid source lane reads -0, not the +0 `Gen.dpp_insn` gives it on `main`. `abs` gives +0, as expected." Previously, `Gen.dpp_insn` (`tools/rdna2spirv.py:7353`) evaluated `src_val = self.src_u(src)` before the shuffle and bound check under the assumption that *"neg/abs are lane-uniform, so before or after the shuffle is the same"*. Then at line 7523, `src0 = OpSelect %uint %src_ok %shuffled %zero` selected `%zero` (`0x00000000` / `+0.0f`) for invalid lanes (`bound_ctrl:1` or DPP8 `fi:0`), which wiped out the float negation on invalid lanes and caused them to read `+0.0f` instead of `-0.0f`. This fixes the ordering: 1. Strips `neg` and `abs` from `raw_src` before evaluating `src_val = self.src_u(raw_src)` so the raw register bits are shuffled across lanes. 2. Selects `src0 = OpSelect %uint %src_ok %shuffled %zero`. 3. Calls `src0 = self.modify(src0, src)` after the zero selection, applying `FAbs` / `OpFNegate` to the selected result. An invalid lane reading `0.0f` with `neg` becomes `-0.0f` (`0x80000000`), with `abs` becomes `+0.0f` (`0x00000000`), and with `-|src0|` becomes `-0.0f`. 4. Documents the confirmed hardware behavior in `docs/design.md`. 5. Adds semantic test fixture `tests/semantic/test_dpp_bound_ctrl_modifiers.py` verifying wave execution and SPIR-V instruction structure. ### Tested - `python -m unittest tests/semantic/test_dpp_bound_ctrl_modifiers.py`: 2/2 tests pass (0.03s). - `python -m unittest discover -s tests/semantic -p "*dpp*.py"`: 19/19 tests pass. - `python -I tests/test_text_write_line_endings.py`: 3/3 pass (clean line endings). - `python -I scripts/check_no_game_data.py`: clean (0 violations, no game data). AI-assisted (Claude Code)
In Gen.dpp_insn, apply src0 input float modifiers (neg/abs) after the bound_ctrl
zero selection rather than before the lane shuffle. On RDNA3 hardware (measured
by @mcpeacebir-lang on an RX 7800 XT in HW-DPP-NEG-INVALID-LANE), reading an invalid
lane under bound_ctrl:1 with -src0 produces -0.0f (0x80000000) and with |src0| produces
+0.0f (0x00000000).

Adds semantic test tests/semantic/test_dpp_bound_ctrl_modifiers.py and updates
the DPP contract row in docs/design.md.

AI-assisted (Claude Code)
AI-assisted (Claude Code)
AI-assisted (Claude Code, Claude Opus 5.5)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:04:41 +00:00
github manually merged commit 31e8ba5fbe into gh-pr/1778/base 2026-11-26 10:04:42 +00:00
Author
Owner

@⁠GeorgiyDemo on GitHub · 2026-11-25 12:13 UTC · original

Tested fb3552fdd on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against main 0d80bc5df (translator-only PR; binaries from the build at 66d4f5aa3):

  • tests/semantic/test_dpp_bound_ctrl_modifiers.py: OK at this head; copied onto main it fails 2 — the neg-after-bound_ctrl result is the new expectation.
  • GPU regression, --filter cs_dpp on MoltenVK 1.4.2: 9/10 PASS, 1 skipped (cs_dpp_w64: no 64-wide compute subgroup on this device); this includes cs_dpp_bound, cs_dpp_mask, cs_dpp_ops, cs_dpp_fi.
  • Not run: the hardware measurement itself (RDNA3); the semantic fixture is the evidence for the rule.

AI-assisted; synthetic fixtures only, no game data.

**@⁠GeorgiyDemo** on GitHub · 2026-11-25 12:13 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1778#issuecomment-7162085286) Tested `fb3552fdd` on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against `main` `0d80bc5df` (translator-only PR; binaries from the build at `66d4f5aa3`): - `tests/semantic/test_dpp_bound_ctrl_modifiers.py`: **OK** at this head; copied onto `main` it fails **2** — the `neg`-after-`bound_ctrl` result is the new expectation. - GPU regression, `--filter cs_dpp` on **MoltenVK 1.4.2**: **9/10 PASS, 1 skipped** (`cs_dpp_w64`: no 64-wide compute subgroup on this device); this includes `cs_dpp_bound`, `cs_dpp_mask`, `cs_dpp_ops`, `cs_dpp_fi`. - Not run: the hardware measurement itself (RDNA3); the semantic fixture is the evidence for the rule. AI-assisted; synthetic fixtures only, no game data.
Author
Owner

@⁠ShotTechOp on GitHub · 2026-11-25 12:25 UTC · original · approved these changes

Independent Windows 11 / Python 3.12.10 review of fb3552fd applied onto origin/main (0d80bc5d) — CPU-only, synthetic inputs, no game files.

Checks run

  • Clean apply onto origin/main (0d80bc5d): clean.
  • python -m unittest discover -s tests/semantic -p test_dpp_bound_ctrl_modifiers.py -v: 2/2 OK.
  • Negative control (reverted tools/rdna2spirv.py to origin/main with the PR's test): 2/2 failures (out_raw[0] is 0 instead of 0x80000000, and OpBitcast %float does not follow OpSelect).
  • python -m compileall -q tools/rdna2spirv.py tests/semantic/test_dpp_bound_ctrl_modifiers.py: exit 0.
  • python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_dpp_bound_ctrl_modifiers.py docs/design.md: exit 0.
  • git diff --check origin/main: clean.

Code audit

  • Stripping neg/abs before self.src_u(raw_src) and applying self.modify(src0, src) immediately after OpSelect %uint {src_ok} {shuffled} {zero} cleanly moves modifier application after bound_ctrl:1 zero selection while leaving valid-lane values unchanged.
  • Non-blocking note: self.modify applies 32-bit float FAbs/OpFNegate (matching src_u's prior behaviour); if DPP is ever used on f16 or raw sign-bit-move ops (src_u_sign_mods), forwarding the modifiers onto the ssa operand for _insn to apply per op could be a clean follow-up.

LGTM. AI-assisted (Antigravity).

**@⁠ShotTechOp** on GitHub · 2026-11-25 12:25 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1778#pullrequestreview-6057551557) · **approved these changes** Independent Windows 11 / Python 3.12.10 review of `fb3552fd` applied onto `origin/main` (`0d80bc5d`) — CPU-only, synthetic inputs, no game files. ### Checks run - Clean apply onto `origin/main` (`0d80bc5d`): clean. - `python -m unittest discover -s tests/semantic -p test_dpp_bound_ctrl_modifiers.py -v`: **2/2 OK**. - Negative control (reverted `tools/rdna2spirv.py` to `origin/main` with the PR's test): **2/2 failures** (`out_raw[0]` is `0` instead of `0x80000000`, and `OpBitcast %float` does not follow `OpSelect`). - `python -m compileall -q tools/rdna2spirv.py tests/semantic/test_dpp_bound_ctrl_modifiers.py`: exit 0. - `python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_dpp_bound_ctrl_modifiers.py docs/design.md`: exit 0. - `git diff --check origin/main`: clean. ### Code audit - Stripping `neg`/`abs` before `self.src_u(raw_src)` and applying `self.modify(src0, src)` immediately after `OpSelect %uint {src_ok} {shuffled} {zero}` cleanly moves modifier application after `bound_ctrl:1` zero selection while leaving valid-lane values unchanged. - Non-blocking note: `self.modify` applies 32-bit float `FAbs`/`OpFNegate` (matching `src_u`'s prior behaviour); if DPP is ever used on f16 or raw sign-bit-move ops (`src_u_sign_mods`), forwarding the modifiers onto the `ssa` operand for `_insn` to apply per op could be a clean follow-up. LGTM. AI-assisted (Antigravity).
Author
Owner

@⁠potatoe0100 on GitHub · 2026-11-25 13:50 UTC · original

Tested fb3552fdd merged onto main 98c2f7777 (clean), native Windows 11 Pro 26H2 (build 26300), NVIDIA GeForce RTX 4060, driver 621.14, VS 2022 (MSVC 19.44) RelWithDebInfo + Ninja, llvm-mc 21.1.8.

  • run_gpu_tests.py: 209/263 passed, 53 skipped, identical to main (no fixture covers an invalid DPP lane with neg, so this shows no regression rather than the fix).
  • Full ctest -j 6: all pass apart from xs_proxy_mock, which failed while another build was running on this PC. This PR changes only Python, so that test binary is the same as main's, and the xmem tests fail the same way on main under that load.

AI-assisted (Claude)

**@⁠potatoe0100** on GitHub · 2026-11-25 13:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1778#issuecomment-7164371728) Tested `fb3552fdd` merged onto `main` `98c2f7777` (clean), native Windows 11 Pro 26H2 (build 26300), NVIDIA GeForce RTX 4060, driver 621.14, VS 2022 (MSVC 19.44) RelWithDebInfo + Ninja, llvm-mc 21.1.8. - `run_gpu_tests.py`: 209/263 passed, 53 skipped, identical to `main` (no fixture covers an invalid DPP lane with `neg`, so this shows no regression rather than the fix). - Full `ctest -j 6`: all pass apart from `xs_proxy_mock`, which failed while another build was running on this PC. This PR changes only Python, so that test binary is the same as `main`'s, and the `xmem` tests fail the same way on `main` under that load. AI-assisted (Claude)
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-25 16:03 UTC · original

Thanks for the review! Fixed: escaped the pipes in \|src0|\ in \docs/design.md\ so \ est_docs_design_rows.py\ passes cleanly (5/5 tests OK), and updated the measurement note to specify 'measured on RDNA3 (gfx1101)'.

**@⁠abnalstlll-byte** on GitHub · 2026-11-25 16:03 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1778#issuecomment-7167548185) Thanks for the review! Fixed: escaped the pipes in \\|src0\|\ in \docs/design.md\ so \ est_docs_design_rows.py\ passes cleanly (5/5 tests OK), and updated the measurement note to specify 'measured on RDNA3 (gfx1101)'.
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-25 16:03 UTC · original

Thanks for the review! Fixed: escaped the pipes in \|src0|\ in \docs/design.md\ so \ est_docs_design_rows.py\ passes cleanly (5/5 tests OK), and updated the measurement note to specify 'measured on RDNA3 (gfx1101)'.

**@⁠abnalstlll-byte** on GitHub · 2026-11-25 16:03 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1778#issuecomment-7167552034) Thanks for the review! Fixed: escaped the pipes in \\|src0\|\ in \docs/design.md\ so \ est_docs_design_rows.py\ passes cleanly (5/5 tests OK), and updated the measurement note to specify 'measured on RDNA3 (gfx1101)'.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 16:28 UTC · original

Thanks, @⁠abnalstlll-byte. The fix and its test look right: the test fails on main and passes here. One thing before merge:

  • Your comment says the pipes are escaped, but the branch is still at fb3552fdd, and the DPP row in docs/design.md still has |src0|. test_docs_design_rows.py still fails. Could you push the commit?

Also please note "RDNA2 not measured" next to the RDNA3 (gfx1101) note, and name the model in the AI note.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-25 16:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1778#issuecomment-7168040539) Thanks, @⁠abnalstlll-byte. The fix and its test look right: the test fails on `main` and passes here. One thing before merge: - Your comment says the pipes are escaped, but the branch is still at `fb3552fdd`, and the DPP row in `docs/design.md` still has `|src0|`. `test_docs_design_rows.py` still fails. Could you push the commit? Also please note "RDNA2 not measured" next to the RDNA3 (gfx1101) note, and name the model in the AI note. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-25 17:44 UTC · original

Pushed commit \31e8ba5fb:

  • Escaped pipes in \|src0\|\ in \docs/design.md\ resolving \ est_docs_design_rows.py\ failure (5/5 tests pass).
  • Updated the DPP contract row to note \RDNA2 not measured\ alongside \measured on RDNA3 (gfx1101) RX 7800 XT.
  • Verified with \ ests/test_docs_design_rows.py\ (5/5 OK), \ ests/test_docs_links.py\ (16/16 OK), and \ est_dpp_bound_ctrl_modifiers.py\ (2/2 OK).

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠abnalstlll-byte** on GitHub · 2026-11-25 17:44 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1778#issuecomment-7169936708) Pushed commit \31e8ba5fb\: - Escaped pipes in \\\|src0\\|\ in \docs/design.md\ resolving \ est_docs_design_rows.py\ failure (5/5 tests pass). - Updated the DPP contract row to note \RDNA2 not measured\ alongside \measured on RDNA3 (gfx1101) RX 7800 XT\. - Verified with \ ests/test_docs_design_rows.py\ (5/5 OK), \ ests/test_docs_links.py\ (16/16 OK), and \ est_dpp_bound_ctrl_modifiers.py\ (2/2 OK). AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠QemmHD on GitHub · 2026-11-25 18:41 UTC · original

Heads-up from a test run on an RTX 4070 SUPER: the code part looks fine, but merged onto current main this PR fails tests/test_docs_design_rows: a docs/design.md table row has more cells than the table header. Fixing that row should let it pass the consistency set.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠QemmHD** on GitHub · 2026-11-25 18:41 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1778#issuecomment-7171252632) Heads-up from a test run on an RTX 4070 SUPER: the code part looks fine, but merged onto current main this PR fails `tests/test_docs_design_rows`: a `docs/design.md` table row has more cells than the table header. Fixing that row should let it pass the consistency set. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 19:19 UTC · original

Merged, thanks! The fix, the test and the contract row are verified at 31e8ba5fb: the new test fails on main (2 failures) and passes here, DPP tests are 19/19, and the docs/design.md row now escapes |src0| and says "RDNA2 not measured".

  • Checked on main e380a69a6 + 31e8ba5fb: the semantic suite passes (491 files, 6,312 tests, 0 files failed); the 15 docs and writer tests pass; check_no_game_data.py is clean on the 3 changed files.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-25 19:19 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1778#issuecomment-7172140695) Merged, thanks! The fix, the test and the contract row are verified at `31e8ba5fb`: the new test fails on `main` (2 failures) and passes here, DPP tests are 19/19, and the `docs/design.md` row now escapes `|src0|` and says "RDNA2 not measured". - **Checked on `main` `e380a69a6` + `31e8ba5fb`:** the semantic suite passes (491 files, 6,312 tests, 0 files failed); the 15 docs and writer tests pass; `check_no_game_data.py` is clean on the 3 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.