indirect: warp_budget test accepts either group order (fixes #1100, #1118) #1134

Closed
github-bot wants to merge 1 commit from github-bot/gh-1134 into main AGit
Owner

@⁠DominicBrett on GitHub · 2026-11-25 21:17 UTC · original
fix/warp-budget-group-order → main · +15 −2 · 1 files · 1 commits · closed without merging

Fixes #1100 and #1118: indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields fails intermittently, and on some machines nearly every time.

Cause

The cause is the test, not the shader. The test sends 128 records, which the clamp runs as two groups of 64. Each group adds up its own records' cost in lane order, then charges that sum to the one budget word with a compare-and-swap. Every real draw costs 2^26, so the group that charges first takes the whole 2^27 budget with its first two real draws, and every draw in the other group runs empty.

D3D12 gives no order between thread groups, and WARP (which this test always uses, whatever GPU is installed) runs groups on CPU threads. Either group can win. The test hard-coded the first group winning (assert!(i == 1 || i == 2)), so it fails whenever the second group charges first (records 64 and 65 kept).

This also answers the question in #1118: the GPU's wave width isn't involved. The harness runs on WARP, and the clamp's numthreads(64) plus groupshared walk is the same on every adapter. That explains why it "passed twice, then failed three times" on the same machine.

Fix (test only, shader unchanged)

The test now accepts either [1, 2] or [64, 65] as the kept pair. It still requires:

  • exactly one group wins, keeping its first two real draws in lane order, and nothing from the other group;
  • every other draw zeroed, and the budget saturated at exactly BUDGET (no wraparound);
  • every pass-through field and the source buffer unchanged.

Evidence

Windows 11 26200, RTX 4070 SUPER (driver 617.42), Rust 1.98.1 MSVC, on 085ee7c. The test binary was run 100 times, with a temporary eprintln! of the kept record indices (removed before committing):

runs pass fail kept [1, 2] kept [64, 65]
before (085ee7c) 100 7 93 7 93
after (this PR) 100 100 0 8 92

Every failure before the fix is a run where the second group won. After the fix, both orders still occur and both pass.

The test still catches a real bug: with the shader's fit check broken on purpose (fit = 1u;, so nothing is ever cut by the budget), the updated test fails: kept [1, 2, 3, …, 127].

Other checks:

  • cargo test -p victory-gpu: 183 passed, 0 failed, 5 ignored.
  • cargo clippy -p victory-gpu --all-targets: same 11 existing warnings before and after, none in the changed lines.
  • rustfmt --check: the changed hunk is clean (the file has existing rustfmt diffs elsewhere, left alone).

🤖 Generated with Claude Code

**@⁠DominicBrett** on GitHub · 2026-11-25 21:17 UTC · [original](https://github.com/fxceless/victory-fork/pull/1134) `fix/warp-budget-group-order` → `main` · +15 −2 · 1 files · 1 commits · closed without merging Fixes #1100 and #1118: `indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields` fails intermittently, and on some machines nearly every time. ## Cause The cause is the test, not the shader. The test sends 128 records, which the clamp runs as **two groups of 64**. Each group adds up its own records' cost in lane order, then charges that sum to the one budget word with a compare-and-swap. Every real draw costs 2^26, so the group that charges first takes the whole 2^27 budget with its first two real draws, and every draw in the other group runs empty. D3D12 gives **no order between thread groups**, and WARP (which this test always uses, whatever GPU is installed) runs groups on CPU threads. Either group can win. The test hard-coded the first group winning (`assert!(i == 1 || i == 2)`), so it fails whenever the second group charges first (records 64 and 65 kept). This also answers the question in #1118: the GPU's wave width isn't involved. The harness runs on WARP, and the clamp's `numthreads(64)` plus groupshared walk is the same on every adapter. That explains why it "passed twice, then failed three times" on the same machine. ## Fix (test only, shader unchanged) The test now accepts **either** `[1, 2]` or `[64, 65]` as the kept pair. It still requires: - exactly one group wins, keeping its first two real draws in lane order, and nothing from the other group; - every other draw zeroed, and the budget saturated at exactly `BUDGET` (no wraparound); - every pass-through field and the source buffer unchanged. ## Evidence Windows 11 26200, RTX 4070 SUPER (driver 617.42), Rust 1.98.1 MSVC, on `085ee7c`. The test binary was run 100 times, with a temporary `eprintln!` of the kept record indices (removed before committing): | | runs | pass | fail | kept `[1, 2]` | kept `[64, 65]` | |---|---|---|---|---|---| | before (`085ee7c`) | 100 | 7 | **93** | 7 | 93 | | after (this PR) | 100 | **100** | 0 | 8 | 92 | Every failure before the fix is a run where the second group won. After the fix, both orders still occur and both pass. **The test still catches a real bug:** with the shader's fit check broken on purpose (`fit = 1u;`, so nothing is ever cut by the budget), the updated test fails: `kept [1, 2, 3, …, 127]`. **Other checks:** - `cargo test -p victory-gpu`: 183 passed, 0 failed, 5 ignored. - `cargo clippy -p victory-gpu --all-targets`: same 11 existing warnings before and after, none in the changed lines. - `rustfmt --check`: the changed hunk is clean (the file has existing rustfmt diffs elsewhere, left alone). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The test dispatches 128 records as two groups of 64 that race for one
budget word. D3D12 gives no order between groups, and WARP runs them on
CPU threads, so either group can charge first and take the whole budget.
The test assumed the first group always wins (records 1, 2 kept), which
made it fail intermittently, and on some machines nearly always.

It now accepts records 1, 2 or 64, 65 as the kept pair, and still
requires exactly one group to win, its first two real draws in lane
order, and every other draw zeroed. The shader is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:58:09 +00:00
github-bot closed this pull request 2026-11-26 11:20:41 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.