Preserve divergent-loop scalar results across 32-lane waves #299

Open
github-bot wants to merge 1 commit from github-bot/gh-299 into main AGit
Owner

@⁠loyodea on GitHub · 2026-11-26 19:28 UTC · original
loyodea:victory-divergent-loop-translation → main · +125 −53 · 3 files · 1 commits · open

Related to #259.

On an eligible 32-lane host, scalar values read after a divergent console wave64 loop could come from different final iterations in the two halves. Route eligible single-console-wave compute groups through the existing synchronized split console flow when a divergent loop leaves a scalar value live after exit. If that lowering is refused, propagate the refusal so the translator cannot silently return the incorrect per-half results for the selected cases.

This addresses the two scalar-count cases. #276 and #260 address fixture selection and adapter capability handling.

Validation

  • On Windows with an RX 9060 XT forced to WaveSize(32), the original scalar results differed by half (32 and 64, then 8 and 16). Production translation with this patch returned 64 and 16 respectively in every lane. Both focused fixtures passed independent reruns with DXIL validation.
  • The full victory-shader library suite returned 277 passed and six ignored. With stock lowering restored, both focused regressions failed the explicit wave-size assertion.
  • Four-lane WARP still reproduces all four original failures. Physical NVIDIA validation and in-game behavior are unverified. The fixtures are synthetic.

Codex contributed the implementation, independent review, and verification.

**@⁠loyodea** on GitHub · 2026-11-26 19:28 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/299) `loyodea:victory-divergent-loop-translation` → `main` · +125 −53 · 3 files · 1 commits · open Related to #259. On an eligible 32-lane host, scalar values read after a divergent console wave64 loop could come from different final iterations in the two halves. Route eligible single-console-wave compute groups through the existing synchronized split console flow when a divergent loop leaves a scalar value live after exit. If that lowering is refused, propagate the refusal so the translator cannot silently return the incorrect per-half results for the selected cases. This addresses the two scalar-count cases. #276 and #260 address fixture selection and adapter capability handling. **Validation** - On Windows with an RX 9060 XT forced to `WaveSize(32)`, the original scalar results differed by half (`32` and `64`, then `8` and `16`). Production translation with this patch returned `64` and `16` respectively in every lane. Both focused fixtures passed independent reruns with DXIL validation. - The full `victory-shader` library suite returned 277 passed and six ignored. With stock lowering restored, both focused regressions failed the explicit wave-size assertion. - Four-lane WARP still reproduces all four original failures. Physical NVIDIA validation and in-game behavior are unverified. The fixtures are synthetic. Codex contributed the implementation, independent review, and verification.
Route eligible wave64 groups with scalar state live after a divergent loop through the existing split console flow on 32-lane hosts. Test production DXIL with exact scalar readback from both halves. Related to #259.

Co-authored-by: Codex <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:49:10 +00:00
Author
Owner

@⁠fladit123 on GitHub · 2026-11-26 20:33 UTC · original · approved these changes

Independent physical NVIDIA validation of PR #299.

Both targeted regression tests pass on an RTX 4060 8 GB.

Environment:

  • NVIDIA GeForce RTX 4060
  • Driver 610.88
  • Windows 11
  • Intel Core i5-12400F
  • 32 GB RAM
  • Host target: lanes_min: 32, lanes_max: 32

Revisions:

  • Baseline: 4f62c2a5e27e7beebf3e8d68f77898e43dc7b77c
  • Candidate: be1f933e87d3d2f5b6a6afe17db1f296e2d58615
Test Baseline Candidate
scalar_counted_in_a_divergent_loop_read_after_it FAIL: 32/64 PASS: 64 in every lane
scalar_counted_in_nested_divergent_loops FAIL: 8/16 PASS: 16 in every lane

I also performed two negative controls using the candidate's updated fixtures with only lower.rs restored from the baseline.

The first control failed both explicit DXIL wave-size assertions (None instead of Some(32)).

For the second control, I replaced only that assertion with diagnostic output, allowing execution to proceed through GPU dispatch and readback. Both original incorrect scalar results were reproduced.

This isolates the effect of the production lowering change from the updated test fixtures.

All four negative-control executions failed as expected. Both unmodified candidate tests passed.

The physical NVIDIA validation therefore supports this correction for the two tested cases.

Full-suite, gameplay and a-publier compatibility remain unverified.

AI-assisted source review and experimental design using OpenAI ChatGPT. All tests were executed locally on physical NVIDIA hardware.

**@⁠fladit123** on GitHub · 2026-11-26 20:33 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/299#pullrequestreview-6080212839) · **approved these changes** Independent physical NVIDIA validation of PR #299. **Both targeted regression tests pass on an RTX 4060 8 GB.** Environment: - NVIDIA GeForce RTX 4060 - Driver 610.88 - Windows 11 - Intel Core i5-12400F - 32 GB RAM - Host target: `lanes_min: 32, lanes_max: 32` Revisions: - Baseline: `4f62c2a5e27e7beebf3e8d68f77898e43dc7b77c` - Candidate: `be1f933e87d3d2f5b6a6afe17db1f296e2d58615` | Test | Baseline | Candidate | |---|---|---| | scalar_counted_in_a_divergent_loop_read_after_it | FAIL: 32/64 | PASS: 64 in every lane | | scalar_counted_in_nested_divergent_loops | FAIL: 8/16 | PASS: 16 in every lane | I also performed two negative controls using the candidate's updated fixtures with only `lower.rs` restored from the baseline. The first control failed both explicit DXIL wave-size assertions (`None` instead of `Some(32)`). For the second control, I replaced only that assertion with diagnostic output, allowing execution to proceed through GPU dispatch and readback. Both original incorrect scalar results were reproduced. This isolates the effect of the production lowering change from the updated test fixtures. All four negative-control executions failed as expected. Both unmodified candidate tests passed. The physical NVIDIA validation therefore supports this correction for the two tested cases. Full-suite, gameplay and `a-publier` compatibility remain unverified. AI-assisted source review and experimental design using OpenAI ChatGPT. All tests were executed locally on physical NVIDIA hardware.
Author
Owner

@⁠ANDREANIADS on GitHub · 2026-11-26 21:16 UTC · original

Confirmed on an RTX 3070 (621.40): both scalar fixtures at be1f933e returned the expected count in all 64 lanes. I also tested an incremental patch that routes the two remaining mask fixtures through the normal emitter and adds a 5 + 23 bit regression. All five fixtures passed on hardware. The before/after results and build differences are in the #259 report.

The ZIP contains patches/pr299-mask-tests.patch, which applies directly to this PR head, plus the exact test logs.
VIctory-correcao-RTX3070.zip

**@⁠ANDREANIADS** on GitHub · 2026-11-26 21:16 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/299#issuecomment-7203557790) Confirmed on an RTX 3070 (621.40): both scalar fixtures at `be1f933e` returned the expected count in all 64 lanes. I also tested an incremental patch that routes the two remaining mask fixtures through the normal emitter and adds a 5 + 23 bit regression. All five fixtures passed on hardware. The before/after results and build differences are in [the #259 report](https://git.gtahub.st/github/Belobug--VIctory-Belobug-AMD/issues/259). The ZIP contains `patches/pr299-mask-tests.patch`, which applies directly to this PR head, plus the exact test logs. [VIctory-correcao-RTX3070.zip](https://github.com/user-attachments/files/35484299/VIctory-correcao-RTX3070.zip)
Author
Owner

@⁠gut0to on GitHub · 2026-11-27 15:02 UTC · original · reviewed

AI-assisted static review; I traced the new split-wave eligibility check and the existing fixtures. I did not run the test suite.

**@⁠gut0to** on GitHub · 2026-11-27 15:02 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/299#pullrequestreview-6090061383) · **reviewed** AI-assisted static review; I traced the new split-wave eligibility check and the existing fixtures. I did not run the test suite.
@ -12261,0 +12288,4 @@
fn split_loop_needs_scalars(&self) -> bool {
// An address-based dispatch can exit some threads before the first
// barrier. Resource waterfall loops are also lane-local.
if !matches!(self.s.threads, Some(threads) if threads.iter().product::<u32>() > 32)
Author
Owner

@⁠gut0to on GitHub · 2026-11-27 15:02 UTC · original

AI-assisted static review: the new eligibility boundary is threads > 32, but the existing divergent-loop fixtures use 64 threads. Could the fixture builder cover both 32 and 33 threads? The 33-thread case exercises the first partially populated upper host wave, while the 32-thread control verifies the single-wave boundary.

**@⁠gut0to** on GitHub · 2026-11-27 15:02 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/299#discussion_r4720916325) AI-assisted static review: the new eligibility boundary is `threads > 32`, but the existing divergent-loop fixtures use 64 threads. Could the fixture builder cover both 32 and 33 threads? The 33-thread case exercises the first partially populated upper host wave, while the 32-thread control verifies the single-wave boundary.
This pull request can be merged automatically.
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/299/head:github-bot/gh-299'
git switch 'github-bot/gh-299'

Merge

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