fix: preserve wave64 first-lane reads on 32-lane hosts #317

Open
github-bot wants to merge 4 commits from github-bot/gh-317 into main AGit
Owner

@⁠mauroalvare on GitHub · 2026-11-26 02:37 UTC · original
mauroalvare:codex/victory-wave64-firstlane → main · +139 −1 · 3 files · 4 commits · open

Vice-Tay

Vice-Tay now selects its cross-half exchange for lane-varying v_readfirstlane_b32 sources on 32-lane hosts. It uses the existing uniformity analysis and retains the descriptor waterfall cases.

The GPU test stores every lane's result with the first active console lane in either half. All tested EXEC masks returned the expected lane.

Earlier Neptune description

Change

Neptune could translate a compute shader with v_readfirstlane_b32 on a 32-lane device using a first-lane operation per host wave. The DXIL passed validation and the PSO ran. In a 64-thread group with every console lane active, lane 32 read the value from lane 32 instead of lane 0.

When the normal lowering lacks a cross-half exchange, a first-lane read from a potentially varying VGPR now requests the existing paired form through emit_any. The paired form places both halves of the console wave in one host wave. The routing uses the existing wave-uniformity analysis and honors the existing descriptor waterfall handling. This change covers compute workgroups made up of complete console waves, the group shape supported by the paired form.

Verification

Base c4c93bdc413191a9dc909998d2d53080a3f0c880. Fix 89df1b296c80da11a4d60fe6c0c2e0ac518285da.

The synthetic shader puts each flat thread ID in its source VGPR, masks EXEC, reads the first active lane, then restores EXEC and stores a result for every thread. The tests run the same emitter used by the Neptune runtime behind tools/lancer_victory.ps1, validate the emitted DXIL with the Windows SDK validator (1.8.2502.11), create a D3D12 compute PSO, dispatch, and compare the readback.

On the RTX 5070 Ti (driver 621.40, 32-lane waves), the base returned 32 at lane 32 where the expected value was 0. The fix selected the paired 32-lane form and matched all 960 output dwords for groups of 64 and 128 threads with five EXEC masks, including an empty mask. The Python RDNA 2 interpreter independently agreed on every result. A second fixture verifies direct lowering for a uniform VGPR source. The new GPU repro ran on hardware. Local WARP reports a 4-lane wave.

From third_party/victory:

cargo test --locked --offline -j 2 -p victory-shader --lib readfirstlane_ -- --nocapture --test-threads=1
Base with tests: 1 passed, 1 failed, 244 filtered out.
Fix: 2 passed, 0 failed, 244 filtered out.

cargo test --locked --offline -p victory-shader -- --nocapture --test-threads=1
244 passed, 0 failed, 2 ignored.

cargo test --locked --offline -p victory-loader --test load_probe
2 passed, 0 failed.

cargo xtask policy
asset policy: 200 files ok

cargo check --locked --offline -j 2 -p victory
Passed, with two warnings in the victory-gpu crate.

The full shader suite also reports four console-compiler comparisons that skip locally and two adapter-specific skips in existing wave-sum tests.

From the repository root, with ANYXBOXX_REQUIRE_RUNTIME=1, the SDK's DXC, and the C++/Rust/TomBox binaries already built in this worktree from the same base:

python -m pytest -rs
1665 passed, 0 skipped (87.89 s, Python 3.13.15).

python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools
All checks passed!

Oracle and test data

The fixtures generate their shader words and data in the test source. Section 12.8 of AMD's RDNA 2 ISA selects the lowest EXEC bit, with lane zero for empty EXEC. The earlier VIctory report recorded the per-half symptom on another emitter line. This PR validates Neptune's paired form on Windows, including two console waves in one workgroup with a varying EXEC mask. AMD RDNA 2 ISA · Prior VIctory report

  • One reviewable behavior with a synthetic regression that fails on the base and passes with the fix.
  • Exact commands, outcomes, and test data recorded above.
  • README consistency checked by the full pytest suite.

AI assistance from OpenAI Codex for investigation, implementation, and validation.

Rebase verification

Rebased on 58d2f53 after #387. The paired lowering preserves the current NVIDIA wave-uniformity analysis.

cargo test --locked --offline -j 5 -p victory-shader -- --nocapture --test-threads=1 reported 259 passed, 0 failed, and 2 ignored. The first-lane test ran on the RTX 5070 Ti for both group sizes. With the test applied to the base alone, cargo test --locked --offline -j 5 -p victory-shader readfirstlane_ -- --nocapture --test-threads=1 reported 1 passed and 1 failed. The varying-source case returned 32 for lane 32 in a 64-thread group with all lanes active, where it should return 0.

The size check in CI found that lower.rs exceeded the 512 KiB limit. The first-lane and indexed-lane helpers now live in lane_read.rs. After the move, cargo xtask policy passed for all 215 files and the full shader suite again passed 259 tests, with 2 ignored.

**@⁠mauroalvare** on GitHub · 2026-11-26 02:37 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/317) `mauroalvare:codex/victory-wave64-firstlane` → `main` · +139 −1 · 3 files · 4 commits · open ## Vice-Tay Vice-Tay now selects its cross-half exchange for lane-varying `v_readfirstlane_b32` sources on 32-lane hosts. It uses the existing uniformity analysis and retains the descriptor waterfall cases. The GPU test stores every lane's result with the first active console lane in either half. All tested EXEC masks returned the expected lane. <details> <summary>Earlier Neptune description</summary> ## Change Neptune could translate a compute shader with `v_readfirstlane_b32` on a 32-lane device using a first-lane operation per host wave. The DXIL passed validation and the PSO ran. In a 64-thread group with every console lane active, lane 32 read the value from lane 32 instead of lane 0. When the normal lowering lacks a cross-half exchange, a first-lane read from a potentially varying VGPR now requests the existing paired form through `emit_any`. The paired form places both halves of the console wave in one host wave. The routing uses the existing wave-uniformity analysis and honors the existing descriptor waterfall handling. This change covers compute workgroups made up of complete console waves, the group shape supported by the paired form. ## Verification Base `c4c93bdc413191a9dc909998d2d53080a3f0c880`. Fix `89df1b296c80da11a4d60fe6c0c2e0ac518285da`. The synthetic shader puts each flat thread ID in its source VGPR, masks EXEC, reads the first active lane, then restores EXEC and stores a result for every thread. The tests run the same emitter used by the Neptune runtime behind `tools/lancer_victory.ps1`, validate the emitted DXIL with the Windows SDK validator (1.8.2502.11), create a D3D12 compute PSO, dispatch, and compare the readback. On the RTX 5070 Ti (driver 621.40, 32-lane waves), the base returned 32 at lane 32 where the expected value was 0. The fix selected the paired 32-lane form and matched all 960 output dwords for groups of 64 and 128 threads with five EXEC masks, including an empty mask. The Python RDNA 2 interpreter independently agreed on every result. A second fixture verifies direct lowering for a uniform VGPR source. The new GPU repro ran on hardware. Local WARP reports a 4-lane wave. From `third_party/victory`: ```text cargo test --locked --offline -j 2 -p victory-shader --lib readfirstlane_ -- --nocapture --test-threads=1 Base with tests: 1 passed, 1 failed, 244 filtered out. Fix: 2 passed, 0 failed, 244 filtered out. cargo test --locked --offline -p victory-shader -- --nocapture --test-threads=1 244 passed, 0 failed, 2 ignored. cargo test --locked --offline -p victory-loader --test load_probe 2 passed, 0 failed. cargo xtask policy asset policy: 200 files ok cargo check --locked --offline -j 2 -p victory Passed, with two warnings in the victory-gpu crate. ``` The full shader suite also reports four console-compiler comparisons that skip locally and two adapter-specific skips in existing wave-sum tests. From the repository root, with `ANYXBOXX_REQUIRE_RUNTIME=1`, the SDK's DXC, and the C++/Rust/TomBox binaries already built in this worktree from the same base: ```text python -m pytest -rs 1665 passed, 0 skipped (87.89 s, Python 3.13.15). python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools All checks passed! ``` ## Oracle and test data The fixtures generate their shader words and data in the test source. Section 12.8 of AMD's RDNA 2 ISA selects the lowest EXEC bit, with lane zero for empty EXEC. The earlier VIctory report recorded the per-half symptom on another emitter line. This PR validates Neptune's paired form on Windows, including two console waves in one workgroup with a varying EXEC mask. [AMD RDNA 2 ISA](https://docs.amd.com/api/khub/documents/Et~wpu9g~Ffl7d9q0QZ~Og/content) · [Prior VIctory report](https://github.com/Marvisak/VIctory/issues/1132#issuecomment-7137435978) - [x] One reviewable behavior with a synthetic regression that fails on the base and passes with the fix. - [x] Exact commands, outcomes, and test data recorded above. - [x] README consistency checked by the full pytest suite. AI assistance from OpenAI Codex for investigation, implementation, and validation. ## Rebase verification Rebased on `58d2f53` after #387. The paired lowering preserves the current NVIDIA wave-uniformity analysis. `cargo test --locked --offline -j 5 -p victory-shader -- --nocapture --test-threads=1` reported 259 passed, 0 failed, and 2 ignored. The first-lane test ran on the RTX 5070 Ti for both group sizes. With the test applied to the base alone, `cargo test --locked --offline -j 5 -p victory-shader readfirstlane_ -- --nocapture --test-threads=1` reported 1 passed and 1 failed. The varying-source case returned 32 for lane 32 in a 64-thread group with all lanes active, where it should return 0. The size check in CI found that `lower.rs` exceeded the 512 KiB limit. The first-lane and indexed-lane helpers now live in `lane_read.rs`. After the move, `cargo xtask policy` passed for all 215 files and the full shader suite again passed 259 tests, with 2 ignored. </details>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:42:52 +00:00
Author
Owner

@⁠LooperSalty on GitHub · 2026-11-26 16:48 UTC · original

This PR conflicts with main in third_party/victory/crates/victory-shader/src/emit/lower.rs and wave64_tests.rs (main moved with the clamp/Wave32 work in #377 and the shader changes in #387-era merges). Please rebase on main, check the first-lane read fix still applies and its test still fails without it, re-run the victory-shader tests and force-push. CI has not run on this PR yet, so it also needs a maintainer approval once it is rebased.

🤖 Generated with Claude Code

**@⁠LooperSalty** on GitHub · 2026-11-26 16:48 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/317#issuecomment-7198123831) This PR conflicts with main in `third_party/victory/crates/victory-shader/src/emit/lower.rs` and `wave64_tests.rs` (main moved with the clamp/Wave32 work in #377 and the shader changes in #387-era merges). Please rebase on main, check the first-lane read fix still applies and its test still fails without it, re-run the victory-shader tests and force-push. CI has not run on this PR yet, so it also needs a maintainer approval once it is rebased. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-bot force-pushed github-bot/gh-317 from 89df1b296c to 8a181250fb 2026-11-26 18:03:43 +00:00 Compare
github-bot force-pushed github-bot/gh-317 from 8a181250fb to 736509e3b4 2026-11-26 18:10:52 +00:00 Compare
Author
Owner

@⁠mauroalvare on GitHub · 2026-11-26 18:25 UTC · original

Rebased and pushed over the shader work in #387. The regression still returned 32 instead of 0 at lane 32 on the base. With the fix, both workgroup sizes passed on the RTX 5070 Ti, and the full victory-shader suite passed 259 tests with two ignored.

I moved the lane-read helpers into their own module after the branch exceeded the 512 KiB source-file limit. The asset-policy check now passes.

The latest CI run passed.

**@⁠mauroalvare** on GitHub · 2026-11-26 18:25 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/317#issuecomment-7200443507) Rebased and pushed over the shader work in #387. The regression still returned 32 instead of 0 at lane 32 on the base. With the fix, both workgroup sizes passed on the RTX 5070 Ti, and the full `victory-shader` suite passed 259 tests with two ignored. I moved the lane-read helpers into their own module after the branch exceeded the 512 KiB source-file limit. The asset-policy check now passes. [The latest CI run passed](https://github.com/LooperSalty/AnyXboxX/actions/runs/45874846583).
github-bot force-pushed github-bot/gh-317 from 41aa5ce05a to a135307034 2026-11-26 19:51:05 +00:00 Compare
github-bot force-pushed github-bot/gh-317 from a135307034 to 5bcae88c8b 2026-11-27 00:37:21 +00:00 Compare
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/317/head:github-bot/gh-317'
git switch 'github-bot/gh-317'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-317'
git switch 'github-bot/gh-317'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-317'
git switch 'github-bot/gh-317'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-317'
git switch 'main'
git merge --squash 'github-bot/gh-317'
git switch 'main'
git merge --ff-only 'github-bot/gh-317'
git switch 'main'
git merge 'github-bot/gh-317'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.