GPU test: the budget test does not decide which two records fit #1098
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/fxceless--victory-fork!1098
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1098"
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?
@HoLa-Lee on GitHub · 2026-11-25 19:23 UTC · original
HoLa-Lee:tests/budget-charges-any-two→main· +16 −5 · 1 files · 1 commits · openWhat this fixes
warp_budget_saturates_without_wraparound_and_preserves_draw_fieldsincrates/victory-gpu/src/indirect.rsfails intermittently, for a reason that is not a bug in the clamp:The clamp charges records with an atomic add from parallel lanes, so which records reach the budget first is the GPU's to choose. On the software adapter, this test alone, 15 runs: records 1 and 2 kept theirs 4 times, records 64 and 65 kept theirs 11 times - and
spent == BUDGET_CAPin all 15. The records are grouped 64 at a time, and which group runs first is not fixed.So the assertion was pinning an order the GPU never promised: 13 of 20 runs of this single test failed on this machine before the change (RTX 4080 SUPER +
Microsoft Basic Render DriverWARP).What it asserts now
The facts that are fixed, and the ones the test exists for:
1 << 26fit a budget of1 << 27, and exactly two keep their draws;(0, 0)), and the empty first record charges nothing;spent == BUDGET_CAP- the budget saturates without wrapping (this is the regression the test was written for: the oldInterlockedAddwrapped at 64 lanes);StartIndexLocation,BaseVertexLocation,StartInstanceLocation, the trailing word) is lost.The failure message now names the records that did keep theirs, so a future failure says what happened rather than only that the order was unexpected.
Measured
victory-gpulib,--test-threads=1victory-gpulib, parallelcargo test -p victory-gpu --lib --profile diag --features diagnostics, Rust 1.98.1. Clippy in this tree reports the same pre-existingmanual_is_multiple_ofand dead-code lints before and after; the changed lines add none.Where this came from
This is the failure filed under
FIND-20in the coordination thread (#1633). It had been described as "watch tests are flaky, WARP tests contend for process-level caches", then corrected to "not concurrency, not the shader cache" - both of those were disproven there. What was left was the guess that some runs got a non-WARP adapter. Instrumenting the harness shows the adapter is always WARP (Microsoft Basic Render Driver, vendor0x1414, device0x8c, flags0x2), and the assertion that fires is this one, notspent. The other candidate (inplace::tests::warp_a_title_buffer_in_place_shows_its_bytes_at_its_offset,VirtualFree(MEM_DECOMMIT)refused) passed 20 of 20 runs on its own with the OS state printed, so it is not implicated either.The four
warp_*tests that used to take turns behind a test-only mutex no longer need to: with this fix the suite is green single-threaded and in parallel.@liuycsbxbxn on GitHub · 2026-11-25 22:06 UTC · original
The shape of the fix here is right, and putting
kept_atin the failure message is exactly what a future failure needs.One thing worth recording while both PRs are open: #1110 asserts
kept == [1, 2] || kept == [64, 65]. That fixes the cross-wave order but still assumes the lanes within a wave charge the budget in lane order. Lane order inside a wave is not part of the contract either -- it happens to hold on WARP today, but another adapter (or a future WARP change) can hand the budget to two arbitrary records of the filling wave and that assertion goes red again. The invariant form here -- exactly two records keep their draw, record 0 charges nothing, everything else is zeroed whole,spent == BUDGET_CAP-- is the one that survives that. So if only one of the two can land (they touch the same lines), this is the safer one.Two small things if you touch it again:
assert_eq!(kept_at.len(), 2, ...)before the.contains(&0)check makes the "exactly two" fact its own assertion with its own message, instead of being implied by(kept, zeroed) == (2, N - 2).--test-threads=1row. Worth keeping it in the body rather than only in review.Not something I can run here (no Rust toolchain on this machine, and an Intel iGPU rather than the 4080), so this is reasoning from the clamp and the two diffs, not a measurement.
@HoLa-Lee on GitHub · 2026-11-25 22:25 UTC · original
Thanks - both points are in,
bfbb167.The invariant form is what the test asserts now, and the record names are gone. Your reasoning about lane order inside a group is in the comment verbatim: only the count (exactly two), the empty first record charging nothing, every other record zeroed whole,
spent == BUDGET_CAP, and no word of any record lost. Nothing names a record number, so a future adapter handing the budget to two arbitrary records of the filling group still passes.The two small things:
assert_eq!(kept_at.len(), 2, "… {kept_at:?}")is now its own assertion, before the "record 0 charges nothing" one, andzeroedhas its ownassert_eq!next to it - so a failure says which fact broke rather than which tuple was wrong.spent == BUDGET_CAPin all 15; 20 of 20 runs of the current version pass, and the fullvictory-gpulibrary is 198 passed / 0 failed / 6 ignored in four parallel and four single-threaded runs.On #1110: your reading matches mine - it fixes the cross-group order but still says
kept == [1, 2] || kept == [64, 65], which pins lane order inside a group. They touch the same lines, so if the maintainer prefers #1110 I'll close this one; the intent here was to leave the assertion on the contract and not on today's scheduling, and that is the only difference between the two.@ishan-2025 on GitHub · 2026-11-26 00:04 UTC · original
Checked against current main (
dc4c0fc), since this was opened on an older base.warp_budgettest, 30 runs of the built test binarydc4c0fcas isthe first two real draws fit the budget)dc4c0fc+ this PR's diff (applies cleanly)dc4c0fc+ #1134's diff (applies cleanly)Machine: Windows 11 26200, i9-12900H, RTX 3070 Ti Laptop 8 GB + Iris Xe. The test runs on WARP, so this only adds one more machine where main fails most of the time and the change holds.
Either PR closes #1118. This one states the invariant without naming the pair, as discussed above, so it stays correct if lane order inside a group ever differs.
Test output only, no game data. AI-assisted (Claude Code).
@HoLa-Lee on GitHub · 2026-11-26 00:15 UTC · original
Thank you - that is the most useful shape of evidence for this one: the same binary, 30 runs, on a machine that is not mine, 6/30 on main and 30/30 with the diff. It also settles the question the two PRs were competing over: #1134 (kept == [1, 2] || kept == [64, 65]) and this one (the invariant, no record named) are both green today, so the difference only shows the day an adapter hands the budget to two arbitrary records of the filling group - and then only this one stays green.
Two notes back:
dc4c0fc): rebasing would invalidate the exact sha your 30 runs stand for, and the diff applies cleanly as it is. If a maintainer asks for a rebase I will do it and re-run the 30 there.If the maintainer would rather have #1134, I will close this one without argument - the point was to leave the assertion on the contract, and that is the only thing this PR adds.
@liuycsbxbxn on GitHub · 2026-11-26 13:22 UTC · original
One more data point, from a machine that is neither yours nor ishan-2025's: GitHub's
windows-latestrunner, WARP (Microsoft Basic Render Driver), a clean fork ofmainat9c184b3(before this PR), the test binary built once and then run 20 times.19 of 20 runs failed.
Run: https://github.com/liuycsbxbxn/victory-fork/actions/runs/45712712377 - the count is in the run's notice and step summary. Workflow:
.github/workflows/flake-repro.ymlonliuycsbxbxn/victory-fork; the job exits 0 on purpose so all 20 runs execute, the count is the datum, not the job's colour.That is three machines now: 13/20 on yours, 6/30 on ishan-2025's main, 19/20 on GitHub's runner. That spread is what a test pinning an order the device never promised looks like - the ratio is whatever the adapter's scheduling gives you that day, so the fix is to stop asserting the order rather than to tune the ratio.
Nothing needed from you on this; it is here so the next person searching for this test finds the spread.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.