Shader tests: run the VALU GPU tests one at a time (cargo test hangs now and then) #433
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!433
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/433/head"
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?
@r4tedx on GitHub · 2026-11-24 03:18 UTC · original
r4tedx:tests/serialise-valu-gpu-tests→main· +5 −0 · 1 files · 1 commits · merged 2026-11-24 08:15 UTCWhat
cargo testnow and then never finishes. The sevenemit::valu_teststhat run on the hardware adapter and on WARP start together on the test threads, none of their dispatches completes, and the test binary keeps one core busy until it is killed (the waits spin on the fence). Any other GPU test running at that moment is stuck with them.run_cases, which all seven go through, now takes a process-wide lock, so they use the GPU one at a time. The lock is poison-tolerant, so one failing test does not fail the others. Five lines, tests only.This is not #181's crash, which #244 fixes by serialising WARP operations. A hang was seen on #244 too and put down as probably separate; the numbers below agree. The two changes compose: #244 covers every WARP user, this one keeps these seven tests from overlapping on the hardware adapter as well.
Not verified
I do not know the cause inside the driver or the D3D12 runtime, only that the hang needs these tests to overlap. The tester above traced where it stops: in every hang all seven tests had created their pipeline and were inside their first dispatch, stopped at different calls (
CreateCommandQueue,Close, afterSignal, after the fence wait), so it looks like the device stalling when several threads use it at once (D3D12 gives every test the same device for an adapter), not one call deadlocking. Replacing the fence polling with an event did not help there (6 of 120 hung).It is not universal. A second machine with an NVIDIA card and a Radeon iGPU (RTX 5080) reproduces it more often than mine and confirms the fix: the whole
victory-shaderlib suite hung in 8 of 60 runs onmainand 0 of 60 with this PR; with the seven tests on the RTX 5080 alone, 6 of 40 against 0 of 40. (#244 alone hung in 3 of 60 there, as it did here.) Elsewhere it is rare or absent. A run on a machine with one hardware adapter (RTX 3060, no iGPU) saw no hang onmainin 30 runs, so there the fix is unconfirmed and only shown harmless. A reviewer on an RTX 5070 machine did see it once without this change: a fullcargo test --workspacein which six of these tests sat for more than 10 minutes, and then 5 of 5 standalone runs passed, with and without the lock. My machine has a second adapter (a Radeon iGPU), which the seven tests do not use.Tested
Windows 11, NVIDIA RTX 5070 with an AMD Radeon iGPU, debug,
d2a4bae. The workspace build of thevictory-shadertest binary, run in a loop withvalu_testsas the filter and a 45 s limit per run (a good run takes about 3 s):maind2a4bae7f95b87Split by backend with a local switch (not in the PR), 40 runs each:
valu_testsfiltermainSo the hang does not need WARP, and with the seven tests one at a time they do not overlap on WARP either.
The same split on a machine with one hardware adapter (RTX 3060), 40 runs each:
valu_testsfiltermainSo the WARP-only crash and its removal are confirmed on a second machine. The hardware-adapter hang has been seen on three machines: mine, the RTX 5080 machine above (which has its own before-and-after counts), and once on the reviewer's RTX 5070. Not on the RTX 3060. A second adapter is not needed: a machine whose only adapter is an RTX 5060 Ti hangs too (2 of 90
valu_testsruns and 3 of 52 whole-lib runs onmain, 0 of 120 with this PR), more often under CPU load.--skip valu_tests: 0 of 14 hung (on a branch with more GPU tests thanmain), so nothing else in the suite does this here.cargo test --workspace: 264 passed, 0 failed, 4 ignored. The seven tests take under 7 s one at a time.AI-assisted; no game assets were used.
🤖 Generated with Claude Code
@DaviTostes on GitHub · 2026-11-24 03:38 UTC · original
Verified
1106f43on Arch Linux x86_64 with the Windows MSVC release test build under Wine 11.22:victory-shader: 62 passed, 7 failed — the same 7 asmain(d2a4bae) with--test-threads=1:bfe_signed_and_unsigned_match_rdna2,v_fract_f16/f32_never_returns_one,v_med3_f16/f32_matches_rdna2_with_nan,v_sin_and_v_cos_f16/f32_reduce_large_turns, all panicking with “neither hardware nor WARP SM 6.6 device available”. So this run cannot exercise the serialisation at all: the VALU GPU tests skip here instead of running concurrently.The change itself is test-only and does not affect the library suite. A machine with an SM 6.6 device should confirm that the previously intermittent hang is gone.
@fromthemoonx on GitHub · 2026-11-24 03:42 UTC · original
Tested
1106f43natively on a machine with an SM 6.6 device, so the seven VALU tests actually run here on the hardware adapter and on WARP.Environment: Windows 11 Pro build 26300, AMD Ryzen 7 5700X, 16 GB, NVIDIA GeForce RTX 3060 12 GB (driver 610.88), no iGPU (one hardware adapter), Rust 1.98.1
x86_64-pc-windows-msvc, debug.Loop, same method as the description (test binary with the
valu_testsfilter, 45 s limit per run):maind2a4baemain, wholevictory-shaderbinaryvictory-shaderbinarySo I could not reproduce the hang on
mainon this machine, and I can't confirm the fix from these numbers. They do show it changes nothing here. Possibly relevant: your machine has a second (AMD) adapter and this one doesn't. Once, on my very firstcargo test --workspaceonmain(while the workspace was still building), thevictory-shaderlib binary exited withSTATUS_ACCESS_VIOLATION. Five later workspace runs and every loop above were clean, so I have nothing reproducible there.Cost: the seven tests one at a time take 5.5–6.4 s against 2.45–2.70 s in parallel (5 runs each), which matches "under 7 s".
Other checks on this PR:
cargo test --locked --workspace: 264 passed, 0 failed, 4 ignoredcargo clippy --locked -p victory-shader --all-targets: no warnings;cargo fmt --check,git diff --check: cleancargo xtask policy: 151 files okNot tested: a machine with two adapters; no game data used.
AI-assisted (Claude Code) ran the checks and drafted this comment.
valu_testspass on hardware #473@r4tedx on GitHub · 2026-11-24 03:53 UTC · original
Thank you, that is the check this needed, and it limits what I can claim: on a machine with one hardware adapter the hang does not happen on
mainin 30 runs, so the fix is unconfirmed there and only shown harmless.Your point about the second adapter made me split the test by backend here (RTX 5070 plus a Radeon iGPU; the seven tests use only the default adapter, the RTX 5070, and WARP). A local switch, not in the PR, makes
run_casesuse one backend; 40 runs each, 45 s limit:valu_testsfiltermaind2a4baeSo on this machine:
I have put your result and this table into the description.
No game data used. AI-assisted.
valu_testspass on hardware #473@fromthemoonx on GitHub · 2026-11-24 04:17 UTC · original
Ran your split here (RTX 3060, single adapter, same environment as above), with the same kind of local switch in
run_cases(not pushed), 40 runs each, 45 s limit:valu_testsfiltermaind2a4bae1106f430xC0000005)So on this machine:
main, and this PR removes it. With both backends the hardware pass seems to stagger the threads enough that they never overlap on WARP here, which is whymainlooked clean before.No game data used. AI-assisted (Claude Code).
@r4tedx on GitHub · 2026-11-24 04:18 UTC · original
Thank you for running the split. That gives the PR one thing it can claim on more than my machine, and one it cannot:
mainonce the hardware pass no longer staggers them, and one at a time they do not;I have added your table to the description and said so there.
No game data used. AI-assisted.
@r4tedx on GitHub · 2026-11-24 05:54 UTC · original
@mercuryVM thank you for the review, and for the data point: six of these tests stuck for more than 10 minutes in a full
cargo test --workspaceon an RTX 5070 machine is the first sighting of the hang outside mine. The description said it had only been seen here; I have corrected that and linked your review. It now reads: seen on two machines (once on yours), not on the RTX 3060, and still only one before-and-after count (3 of 30 against 0 of 60, mine).AI-assisted (Claude Code).
@Lyrnc on GitHub · 2026-11-24 06:14 UTC · original
A second machine with your layout (one NVIDIA card plus a Radeon iGPU): the hang reproduces on
mainhere, including with the hardware adapter alone, and this PR removes it.Machine. RTX 5080 (driver 610.88), the default adapter, plus the AMD Radeon iGPU of a Ryzen 7 9800X3D (driver 32.0.21042.62). Windows 11 Pro 26200, Rust 1.98.1, debug.
cargo test -p victory-shader --lib --no-runper tree, then the test binary run directly with-q, default test threads, 60 s limit per run. A run that hit the limit is "hung" (one core busy, no further output); "crashed" means it exited with0xC0000005. No game data.Whole
victory-shaderlib suite (69 tests):maind2a4bae1106f437f95b87Your split (
valu_testsfilter, a local switch inrun_casesthat keeps one backend, not pushed):mainThat is the case you had seen only on your machine (1 of 40 there, 0 of 40 on fromthemoonx's single-adapter RTX 3060). Here it is 6 of 40, with the seven tests on the RTX 5080 alone, and none with this PR. Both machines with a hang have a Radeon iGPU next to the NVIDIA card, which fits your guess about the second adapter. I can't take the iGPU out to test that directly.
So on a second machine: the WARP-only crashes are #181's (fixed for every WARP user by #244), and the hang does not need WARP. #244 alone still hung 3 times in 60 here; this PR alone, and the two together, never did.
AI use: Claude Code (Claude Opus 5.5) ran the loops and drafted this comment; the counts come from the runs above.
@r4tedx on GitHub · 2026-11-24 06:16 UTC · original
@Lyrnc thank you, that is the confirmation this PR was missing: the hang on the hardware adapter alone, on a second machine, with a before-and-after count (6 of 40 against 0 of 40, and 8 of 60 against 0 of 60 for the whole lib suite). Your rate on
mainis higher than mine (3 of 30), and your #244-alone result (3 of 60) matches what I saw here.The description now cites your numbers and says the hang has been seen on three machines, repeatedly on the two that have a Radeon iGPU next to the NVIDIA card. I have left the second-adapter idea as untested, since neither of us can remove the iGPU; if anyone has a discrete NVIDIA card in a system with the iGPU disabled in firmware, the 40-run
valu_testsloop onmainwould settle it.Nothing changed in the code; head is still
1106f43. The title was not used in these tests. AI-assisted (Claude Code).@lameloball2813-ui on GitHub · 2026-11-24 07:33 UTC · original
Another data point: RTX 5060 Ti, the only adapter in the machine (no iGPU), Windows 11, NVIDIA driver 32.0.16.1088, debug build of
d2a4bae. So a second adapter isn't needed for the hang.Test binary run in a loop, 45–60 s limit per run (a good run takes about 3 s):
mainvalu_testsmainvictory-shaderlib7f95b871106f43valu_testsThe #244 runs hung more often while other builds and tests were loading the CPU, so load seems to make it likelier.
Where it stops. In a local build I wrote a line to a file before and after each step of
run_casesandHost::dispatch(flushed each time, so a hang keeps it). In every hang, all seven tests had created their pipeline on the hardware adapter and were inside their firstdispatch. Within one hang they stop at different calls:CreateCommandQueue,Close, right afterSignal, and after the fence wait. So it doesn't look like one call deadlocking. It looks like the whole device stalling when several threads use it at once (D3D12 gives every test the same device for the same adapter).The fence polling isn't the cause. I replaced both
while fence.GetCompletedValue() < 1 { yield_now() }loops inemit/host.rswithSetEventOnCompletion(1, null): still 6 hung in 120 runs. A 20 s timeout I put inside the polling loop also never fired, so in those threadsGetCompletedValue/GetDeviceRemovedReasonthemselves never return.So running the seven tests one at a time is the fix here too. The runtime in
victory-gpualready waits with an event and doesn't share devices across threads this way, so this looks confined to the test harness.@r4tedx on GitHub · 2026-11-24 07:40 UTC · original
@lameloball2813-ui thank you, this settles two things the description had open, and both are now in it with a link to your comment.
main(2 of 90 and 3 of 52) and not with the lock (0 of 120) rules it out.GetCompletedValueitself not returning. That reads as the shared device stalling under several threads, as you say, not as one call deadlocking, and it explains why swapping the fence polling for an event did not help. The load sensitivity fits too: #244 alone hung more here and on another machine as well.So the fix stays what it is, one test at a time, and the cause stays in the test harness's use of one device from seven threads. I agree the runtime is a different case, though I have not checked that claim against
victory-gpumyself.Head unchanged (
1106f43). The title was not used in these tests. AI-assisted (Claude Code).