Preserve divergent-loop scalar results across Wave32 halves on a-publier #366
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Belobug--VIctory-Belobug-AMD!366
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-366"
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?
@fladit123 on GitHub · 2026-11-26 22:24 UTC · original
fladit123:fix/wave64-divergent-loop-scalars→a-publier· +573 −0 · 3 files · 1 commits · draftProblem
Related to #352.
On
a-publier@cd8dfc06, divergent EXEC-controlled loops can lose wave-level scalar semantics when lowered into independent per-lane control flow.The two synthetic regressions adapted from #299 returned individual lane iteration counts rather than the console wave's final scalar values.
Implementation
Reuse the existing wave-wide branch lowering for eligible compute groups containing one complete console Wave64 on a Wave32-only host.
The correction:
VICTORY_GROUP_SYNC=0.Physical NVIDIA validation
Environment: RTX 4060 8 GB, driver 610.88, Windows 11, Rust 1.98.1.
Final focused validation: 12 GPU tests and 3 CPU-only controls passed.
The fixtures perform CPU emission checks independently of hardware availability, select GPU execution according to actual D3D12 capabilities, and report capability skips explicitly.
Pipeline creation, dispatch and readback failures remain test failures on eligible hardware.
Additional validation
The earlier bounded library comparison reported:
This comparison predates the final fixture-only portability improvements. Production code remained byte-for-byte unchanged.
PR #345 passed a static patch applicability check against the final worktree. Combined runtime behavior has not been tested.
Scope and limitations
This is a deliberately narrow correctness fix for eligible single-console-wave compute groups on hosts with a maximum wave size of 32.
Native Wave64 execution, the separate native Wave32 scalar regression in #352, and more general control-flow forms remain outside scope.
Physical AMD validation and gameplay performance are unverified.
Independent testing and review are welcome.
Attribution
AI disclosure: OpenAI ChatGPT assisted with source review, experimental design and independent patch review. OpenAI Codex assisted with implementation and local validation. All GPU results were obtained on physical hardware using synthetic fixtures.
@MamaLeVrai on GitHub · 2026-11-26 22:56 UTC · original
Ran on an RX 6950 XT (RDNA 2, max wave 64, driver 32.0.21045.29003), Windows 11 build 26300, Rust 1.98.1, release, at
ac445ea:pr299_andscalar_loop_control_: 11 passed. On this card, though, the GPU part of the twopr299_fixtures reportsGPU SKIP: the synchronized route requires a physical adapter with max wave 32. Only their CPU part (production emission and DXIL validation for max wave 32) ran here, so nothing here exercises the new route on a card.471e11bmerged on top: the threescalar_counted_*tests still fail on this card, each lane reading its own count.scalar_counted_in_a_divergent_loop_read_after_itreads[1, 2, ..., 64]where the console gives 64 everywhere. That is expected, since the PR is limited to max-wave-32 hosts, but it confirms that RDNA hosts (which run these programs as wave64) keep the per-lane count.So for RDNA 2/3 the 64-lane route is still open. I can run a version of it on this card when there is one.
AI-assisted (Claude Code); no game data.
@fladit123 on GitHub · 2026-11-26 22:57 UTC · original
Thanks, @MamaLeVrai! These results are consistent with the intended scope of #366.
I have also been investigating the native-wave path independently on
a-publier@4eb6cfdf.On the physical RTX 4060, the experimental native Wave32 correction now passes both the simple and nested scalar-loop regressions using the existing wave-wide branch mechanism.
The bounded library comparison reported 303 passes and two expected failures on the baseline, versus 305 passes and zero failures on the candidate, with identical filters and capability skips.
I am investigating whether the same native-wave mechanism can safely cover RDNA hosts without introducing cross-wave LDS synchronization.
Your offer to validate the native Wave64 path on RDNA2 would be very helpful. No AMD correctness claim is being made yet.
@adrianmjim on GitHub · 2026-11-26 23:00 UTC · original
RDNA3 data for
ac445ea: RX 7900 XT, max wave 64, Windows 11 26300,--test-threads=1. #352's probe commit471e11bis on top for both trees.victory-shader --liba-publier(cd8dfc0) + probesscalar_counted_*probespr299_*,scalar_loop_control_*) pass here. On this card the GPU part of thepr299_fixtures skips, as on the RX 6950 XT, because the route is for max-wave-32 adapters. So only the CPU emission and validation part ran.cargo test --locked -p victory-shader --lib pr299_ scalar_loop_control_ -- ...fails withunexpected argument 'scalar_loop_control_', since cargo takes one name filter before--. Putting both after it works:cargo test --locked -p victory-shader --lib -- pr299_ scalar_loop_control_ --nocapture --test-threads=1.Glad to run the native wave64 version on this card when there is one.
@fladit123 on GitHub · 2026-11-26 23:02 UTC · original
Thanks, @adrianmjim! The RDNA3 comparison is very helpful, and thanks for catching the Cargo filter syntax.
The native Wave32 follow-up has now completed its local validation on the physical RTX 4060:
The follow-up is available here:
https://github.com/fladit123/VIctory-Belobug-AMD/tree/fix/native-wave32-divergent-loop-scalars
It currently targets max-wave-32 hosts only.
Since both corrections reuse the same scalar-loop selection logic, would you prefer a separate native-wave follow-up or an extension of #366 once the AMD path is ready?
I would also appreciate independent RDNA2/RDNA3 testing when the native Wave64 candidate becomes available.
AI-assisted investigation and implementation using OpenAI ChatGPT.
@adrianmjim on GitHub · 2026-11-26 23:05 UTC · original
@fladit123 the maintainer's preference matters more than mine here. Since #366 is still a draft and both corrections share the scalar-loop selection, I'd extend #366: one review of that selection logic, and the route that applies to each host stays visible in one place. Keeping each route in its own commit inside the PR would still let either be reverted alone. Yes to the native wave64 candidate: I'll run it on the RX 7900 XT (RDNA3, native wave64) with the three
scalar_counted_*probes andvictory-shader --lib, before and after, when it's up.@MamaLeVrai on GitHub · 2026-11-26 23:12 UTC · original
Following up on my comment above: a small extension makes the same route work on 64-lane hosts. It is one commit on top of
ac445ea:github.com/MamaLeVrai/VIctory-Belobug-AMD@52a3bc4(branchMamaLeVrai:scalar-loops-whole-wave), offered for you to take into this PR if you want it.Change (
emit/mod.rs, 5 lines): the route also runs whenhost_max_wave() >= 64, and there it does not requiregroup_sync(). On such a host the 64-thread group is a single host wave. The emitted program declaresWaveSize(64)(the new tests assert PSV0(64, 64)), so the votes at the latches are wave-wide and need no group synchronization.Tests (
wave64_tests.rs):whole_wave_divergent_scalar_loopandwhole_wave_nested_divergent_scalar_loopstake yourpr299_shapes throughemit_scalar_loop(.., 64)and run them on the card when it has 64-lane waves (they skip otherwise).On an RX 6950 XT (RDNA 2, driver 32.0.21045.29003):
whole_wave_divergent_scalar_loop[1, 2, ..., 64]whole_wave_nested_divergent_scalar_loops[1, 2, 3, 4, 1, ...]cargo test --release -p victory-shader --lib, twice: everything passes apart from #352's three probe tests (merged in for this check), which calllower::lowerdirectly and so never reachemit()'s route. Your 11 tests and the two new ones pass.Not covered: the wave32 console case (
scalar_counted_in_a_wave32_divergent_loop_read_after_it), and RDNA 3. @adrianmjim, your RX 7900 XT would be the card to check the second on.AI-assisted (Claude Code); no game data.
@LTraina0 on GitHub · 2026-11-26 23:22 UTC · original
We reproduced both divergent-loop regressions on a GeForce RTX 4060 Laptop GPU (8 GB, Windows 11, NVIDIA driver 621.40) while testing for the Brazilian project
VIctory-RTX4060-Laptop-BR. We ran the same two synthetic fixtures from this PR on both revisions and read the results back from the GPU.cd8dfc06ac445ea90DXIL validation passed in all four runs. The GPU readback caught the incorrect values on the baseline and confirmed the fix for both fixtures on this Wave32 GPU.
OpenAI Codex assisted with running the tests and writing this report.
@adrianmjim on GitHub · 2026-11-26 23:37 UTC · original
@MamaLeVrai RDNA3 result for
52a3bc4(your 64-lane extension onac445ea): RX 7900 XT, max wave 64, Windows 11 26300,--test-threads=1, #352's probes471e11bon top.whole_wave_divergent_scalar_loopandwhole_wave_nested_divergent_scalar_loopspass. On this card they run on the hardware, not skipped, since it has 64-lane waves. Both assert PSV0(64, 64)and 64 (resp. 16) on all 64 lanes.pr299_*andscalar_loop_control_*all pass. As before, thepr299_GPU parts skip here (the synchronized route is for max-wave-32 adapters).victory-shader --lib: 315 passed, 3 failed, 4 ignored. The 3 are #352'sscalar_counted_*probes. They calllower::lowerdirectly and so never reachemit()'s route, as you said. They still read per-lane counts and declare no wave size.So the whole-wave route gives the console's values on RDNA 3 too, which makes two RDNA generations with yours. The wave32 console case (
scalar_counted_in_a_wave32_divergent_loop_read_after_it) is still the open one.@MamaLeVrai on GitHub · 2026-11-27 00:12 UTC · original
One more commit on the same branch, covering the case the 64-lane one left out, console wave32 programs:
github.com/MamaLeVrai/VIctory-Belobug-AMD@2aa9847(on top of52a3bc4).emit(): thenative.wave64condition is dropped, so console wave32 programs with a 64-thread group, no LDS, no spill and no waterfall also take thescalar_loop_latches+structure_wideroute. The group-synchronization refusal now applies only to wave64 on a 32-lane host. Once a branch is taken wave-wide, the lowering declaresWaveSize(32)for a wave32 program on either host. Each console wave is then one host wave, and its latch vote is its own.wave32_divergent_scalar_loop, the DIVERGENT_COUNT_W32 shape from #352, emitted for a 32-lane and a 64-lane host and both run on the card.On the RX 6950 XT:
52a3bc4(0, u32::MAX),(0, u32::MAX)[1, 2, ..., 64]2aa9847(32, 32),(32, 32)Full
cargo test --release -p victory-shader --lib, twice: 316 passed, 0 failed, 4 ignored.Caveats: this assumes each
WaveSize(32)host wave holds 32 consecutive threads. That holds for a[64,1,1]group, the only shape tested, and the existing wave32 lane code assumes it too. I kept the wave64 gate (64-thread group, no LDS) although wave32 does not need the group vote. It has not been run on a 32-lane-only card.AI-assisted (Claude Code); no game data.
@fladit123 on GitHub · 2026-11-27 00:15 UTC · original
Thanks, @MamaLeVrai, @adrianmjim and @LTraina0, for the independent implementations and hardware validation!
The native-wave investigation I was running in parallel has also completed.
On my physical RTX 4060:
One portability concern with the proposed Wave32 extension is that a maximum wave width of 64 does not necessarily imply support for WaveSize(32). My experimental path requires the actual min/max wave range, WaveOps and SM 6.6, and restricts the native route to a linear 64-thread group.
However, it is currently an explicit uncached entry point rather than a default runtime change. Integrating these capabilities into normal translation would also require reviewing their propagation and cache fingerprinting.
I would prefer to consolidate our work rather than submit competing implementations. Your commits provide valuable physical AMD validation, while the experimental branch provides capability exclusion, mixed scalar/vector and consecutive-loop controls.
Would you be comfortable with incorporating your commits with their original authorship and then refining the capability checks and test portability?
Thanks again for collaborating on this.
AI-assisted investigation using OpenAI ChatGPT and Codex.
@adrianmjim on GitHub · 2026-11-27 00:17 UTC · original
RDNA3 result for
2aa9847(wave32 on top of52a3bc4): RX 7900 XT, the driver reports waves of 32 to 64, Windows 11 26300,--test-threads=1, #352's probes on top.wave32_divergent_scalar_looppasses on the hardware. PSV0 is(32, 32)for both the 32-lane and the 64-lane emission. Readback is 32 on lanes 0–31 and 64 on lanes 32–63, both times, i.e. the console's values. That matters on this card: RDNA3 runs a compute program with noWaveSizeas wave64. #352's wave32 probe shows that, with each lane reading its own count. So the declaredWaveSize(32)is honoured here.whole_wave_*andwave32_*ones. Fullvictory-shader --lib: 316 passed, 3 failed, 4 ignored. The 3 are #352's probes, which calllower::lowerdirectly and never reachemit()'s route.On @fladit123's portability point, it's a real case: WellyngtonSantos's RX 580 on #204 reports waves of 64 to 64 (GCN), so
WaveSize(32)is outside its range. Gating the wave32 route on the adapter's actualWaveLaneCountMin <= 32, rather than onhost_max_wave() >= 64, would keep such a card on the current path. Here min is 32, so the route applies and works.@TinkerBell-90 on GitHub · 2026-11-27 01:58 UTC · original
The two
pr299_GPU parts skip on AMD cards only because of the test's condition. They need an adapter that runs 32-lane waves, not one whose waves are at most 32 lanes. RDNA runs aWaveSize(32)program in waves of 32 (@adrianmjim showed RDNA 3 honours it above), so an AMD card can run the 32-lane emission, which is the route this PR adds. With this change tocheck_scalar_loop(test only):On an RX 9070 XT (RDNA 4, waves of 32 to 64), Linux, Wine 10 + vkd3d-proton 3.1, Mesa 26.0.8 RADV, at
ac445ea:pr299_divergent_scalar_looppr299_nested_divergent_scalar_loopsemit/mod.rsas oncd8dfc0The second row is the RTX 4060 baseline from the description and from @LTraina0. With the change, all 11
pr299_andscalar_loop_control_tests pass on this card, the twopr299_GPU parts included. A card that only runs 64-lane waves, like the RX 580 on #204, still skips. So the maintainer's AMD cards could check this route on hardware too. Nothing was run in game.AI-assisted.
@adrianmjim on GitHub · 2026-11-27 02:00 UTC · original
Native confirmation of @TinkerBell-90's test change on RDNA3: RX 7900 XT (waves 32 to 64), Windows 11 26300 native D3D12 (no vkd3d),
ac445eawith only that 3-line change incheck_scalar_loop,--test-threads=1.pr299_andscalar_loop_control_tests pass, with 8 GPU runs and 0 skips.pr299_fixtures now run the 32-lane emission (PSV0(32, 32)) on the card.pr299_divergent_scalar_loopreads 64 on all 64 lanes, andpr299_nested_divergent_scalar_loopsreads 16 on all 64.1, 2, ..., 64).So with that condition, the synchronized route this PR adds is checked on AMD hardware natively as well as under Proton. A card with 64-lane waves only (the RX 580 on #204) still skips, as it should.
@k5tvbn7f5r-maker on GitHub · 2026-11-27 11:30 UTC · original
Independent hardware validation on a desktop RTX 5070 (Blackwell, physical wave size 32), NVIDIA 621.40 WDDM, Windows 11 26H2.
I ran the restored #259 scalar fixtures through the production translator and checked all 64 lanes after D3D12 dispatch. The original base
cd8dfc06returned 1/64 correct values for the simple loop and 4/64 for the nested loop. Both returned 64/64 onac445ea9. I independently tested the local integration4b17e2d7against unpatcheda-publier@4eb6cfdfand reproduced the same correction. Two additional fixtures with reversed half-wave workloads also returned 64/64 for both64×1and32×2groups on the integration.The eight author GPU cases passed on both candidate builds.
VICTORY_GROUP_SYNC=0gave the expected translation refusal for the synchronized path. The pre-existing #259 loop-exit mask mismatch persisted. The attached ZIP contains commands, per-lane readbacks, and dispatch and coverage logs.qa-002-pr366-evidence.zip
@fladit123 on GitHub · 2026-11-27 17:28 UTC · original
The consolidated candidate is ready for independent hardware validation:
https://github.com/fladit123/VIctory-Belobug-AMD/tree/integration/native-scalar-wave
Commit:
9b85a81075d100c0d74f46bb7e62af37e95a9800Both of @MamaLeVrai's native-wave commits have been incorporated with their original authorship preserved.
The consolidation retains the original #366 split-wave route and adds:
emit::translateentry point.Local validation on my RTX 4060:
29e7a59passed 21 focused tests.@MamaLeVrai, @adrianmjim and @TinkerBell-90, independent validation of this exact revision on RDNA2, RDNA3 and RDNA4 would be very valuable.
Native Wave64 emission and DXIL validation passed locally under simulated capabilities, but physical AMD execution of this revision remains unverified.
The current #366 branch remains unchanged pending that validation and maintainer feedback.
Thanks to everyone who contributed implementations, regression fixtures and independent hardware results.
AI-assisted investigation, consolidation and review using OpenAI ChatGPT and Codex.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.