Relay: the copy-queue fetch never runs beside writes to the copies it reads (RDNA 2 resets, #376) #428
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!428
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-428"
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?
@MamaLeVrai on GitHub · 2026-11-27 01:03 UTC · original
MamaLeVrai:relay-fix→a-publier· +463 −8 · 3 files · 4 commits · openUpdate: the guard is now opt-in,
VICTORY_RELAY_FETCH_GUARD=1(commit4960f8e). In-game measurements on an RX 7900 XT showed a cost (about 0.7 ms more fetch wait per frame, more stalls), and an RX 6600 XT still reset with it. Off by default, the default path is unchanged againsta-publier.What
With
VICTORY_RELAY=2andVICTORY_RELAY_COPY=1, bothscripts\play.ps1defaults, a landed flight's card copies are fetched on a separate HIGH-priority copy queue (relay_card_back,make_relay_fetch). Nothing on the GPU ordered that copy against later submissions that write the same card copies, either through shader UAV writes or through the card sync list'sCopyBufferRegionintoshadow.bufferincard_before. The copy queue read bytes while the drawing queue wrote them.The new
host/fetchguard.rs, wired intohost.rs, does three things:card_beforeuntil its plan is dropped, each submission notes the card copies it writes (declared, looked at, sent up);VICTORY_RELAY_COPY=0;Waiton the fetch's fence (a GPU wait, no CPU stall) before its first list.The frame-rate line counts per frame the fetches on each queue and the drawing-queue waits.
Why
On RDNA 2 the device is lost (
0x887A0007) within minutes under the defaults, andVICTORY_RELAY=0avoids it (#376: RX 6800 XT, RX 6700, RX 6950 XT; #329). This is a real cross-queue overlap that only the relay adds. It is not proven to be the reset's cause.VICTORY_RELAY=0turns off much more: the flights in the air, the relay thread, card steps, and most overlap with the upload-ahead and keep-awake queues. A game run on an RDNA 2 card has to confirm it.Tests
On an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, release:
VICTORY_RELAY=2 VICTORY_RELAY_COPY=1 cargo test --release -p victory-gpu --lib -- --ignored --exact host::upcheck::tests::a_result_caught_in_between_is_put_right:a-publier4eb6cfd:12 of 12 results wrong in title memory, 1 undone on the card, FAILED. WithVICTORY_FETCH_CHECK=1, 12 of 24 pieces are flagged as caught mid-write.0 of 12 results wrong in title memory, 0 undone on the card, ok, with or without the check.a_fetch_never_runs_beside_a_flight_that_writes_its_copy(passes 3 runs in a row), and afetchguardunit test.cargo test --release -p victory-gpu --lib, twice: 397 passed, 0 failed, 35 ignored (base 396 / 0 / 34). Clippy is clean with and without--features diagnostics.Cost and limits
AI-assisted (Claude Code); no game data.
🤖 Generated with Claude Code
@copilot-pull-request-reviewer[bot] on GitHub · 2026-11-27 01:03 UTC · original · reviewed
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
@drbluetongue on GitHub · 2026-11-27 04:35 UTC · original
I tried this and still got crashing, 6600xt.
@MamaLeVrai on GitHub · 2026-11-27 05:11 UTC · original
Thanks @drbluetongue, that's useful: it means the copy-queue overlap fixed here is not the whole cause of the RDNA 2 resets, or not the cause at all. Could you tell me:
VICTORY_RELAY_COPY,VICTORY_CARD_AWAKE, Series S/X;fetches of card copies' pieces per frame (VICTORY_RELAY_COPY=1): ..., and thewhen the host device went:line.If you can also try
-More @{VICTORY_RELAY_COPY='0'}and then-More @{VICTORY_CARD_AWAKE='0'}on the same build, each alone, that would show which of the relay's parts matters on your card. On #376,VICTORY_RELAY=0alone was enough for several RDNA 2 cards.AI-assisted (Claude Code); no game data.
@adrianmjim on GitHub · 2026-11-27 06:48 UTC · original
Tested on RX 7900 XT (RDNA 3), driver 32.0.32029.2010, Windows 11 build 26300, release. Head
6bc90e3vs a-publier4eb6cfd.a_result_caught_in_between_is_put_right, one process per run. 8 runs per side: 5 withVICTORY_RELAY=2 VICTORY_RELAY_COPY=1, 3 with the full play.ps1 env (non-Safe, without DRED):4eb6cfd: FAILED 8 of 8, every time12 of 12 results wrong in title memory, 1 undone on the card. WithVICTORY_FETCH_CHECK=1: ok 8 of 8, pieces checked/suspect/put right[24, 12, 12].6bc90e3: ok 8 of 8, 0 of 12 wrong, 0 undone, with and without the check. With the check:[0, 0, 0].card_stepswithVICTORY_CARD_STEPS=2: ok on both sides, 8 runs each, one process each, same two envs. Newa_fetch_never_runs_beside_a_flight_that_writes_its_copy(head): ok 8 of 8.victory-gpulib, default threads:VICTORY_RELAY=2 VICTORY_RELAY_COPY=1, 6 runs each: head 397 passed every run. Base failed once ondescriptor::host::tests::views_off_their_elements_get_a_copy_of_their_bytes(the random failure in #462); it passes 3 of 3 alone on both sides.fetchguardunit test uses the process-wide guard. Under the relay env it passed in all 6 whole-suite runs and 10 of 10 alone.upcheck.rs, #412 inhost.rs. Both merge cleanly onto4eb6cfdwithout this PR.Not tested: a game run (nothing here on the RDNA 2 reset), cost of the drawing-queue waits, debug build.
@adrianmjim on GitHub · 2026-11-27 11:31 UTC · original
In-game numbers for the "Cost and limits" section, on the same RX 7900 XT (RDNA 3) as my earlier comment.
diagprofile with diagnostics, head6bc90e3against a-publier4eb6cfd.What I ran:
scripts\play.ps1(VICTORY_RELAY=2,VICTORY_RELAY_COPY=1), frame capture on, DRED light.Counters per frame, means of the one-second lines:
VICTORY_CARD_STEPS=2line: 1,347 fills on base, 1,806 with the PR (+34 ± 6 %). Title copies (5 s copies line) go from 7,900 to 7,303 (-7.6 ± 1.9 %). I did not trace why these two move.Frame rate:
So about a fifth of the fetches take the drawing-queue path, and the relay thread waits about 0.7 ms more per frame for fetches. On frame rate I cannot separate the PR from base: the interval excludes a cost above about 13 % on this route and includes zero. The stall time is the open point. Frames vary 3-4 % between passes of one build (sd), so finding a 5 % cost would need about 10 passes per build.
What this cannot show:
diagbuild, a PNG saved every 8th frame, and the process at 31-32 GB private with 0.2-0.4 GB left to commit at worst in every pass.@MamaLeVrai on GitHub · 2026-11-27 11:32 UTC · original
Thanks @adrianmjim, careful work. Taking it with the RX 6600 XT report above: this PR fixes a real overlap (12/12 wrong results in the upcheck test go to 0/12), but it does not stop the RDNA 2 resets. In your runs it costs ~0.7 ms of relay fetch wait per frame and more title-call stalls (+8.4 ± 9.8 s over the window, every PR pass above every base pass), with frames -5 % and not separated from zero.
Given that, I'd suggest the maintainer does not take it as a default yet. Two options:
VICTORY_RELAY_FETCH_GUARD=1) so the correctness fix is there for whoever sees the wrong data, without the cost by default.I'll look at narrowing it before asking for a merge. On RDNA 2, the cause of the resets is still open; my notes are on #376 and #545.
AI-assisted (Claude Code); no game data.
@MamaLeVrai on GitHub · 2026-11-27 11:36 UTC · original
Pushed
4960f8e: the guard is now behindVICTORY_RELAY_FETCH_GUARD=1, off by default, so the default path is the same asa-publierand has none of the cost measured above. On an RX 6950 XT,VICTORY_RELAY=2 VICTORY_RELAY_COPY=1, upcheck'sa_result_caught_in_between_is_put_right:12 of 12 results wrong in title memory, FAILED (as on base);VICTORY_RELAY_FETCH_GUARD=1:0 of 12, ok.cargo test --release -p victory-gpu --lib: 396 passed, 1 failed (awatch::testsflake that #450 fixes), 35 ignored. The new ignored test now names the switch it wants. The frame line's fetch counts are printed only with the guard on.AI-assisted (Claude Code); no game data.
@MamaLeVrai on GitHub · 2026-11-27 11:50 UTC · original
Pushed
e1263e1: the guard (still opt-in,VICTORY_RELAY_FETCH_GUARD=1) now works by byte range instead of whole copy. Each submission records the offsets it writes per copy: its declared ranges, sends widened to 16 bytes, and the whole copy only for copies it merely looks at (a shader may write anywhere there). A fetch goes to the drawing queue, and the drawing queue waits for a fetch, only when a submission in the air writes a byte of a piece being fetched.On an RX 6950 XT:
a_result_caught_in_between_is_put_rightwith the guard:0 of 12 results wrong, ok (with and withoutVICTORY_FETCH_CHECK=1).a_fetch_never_runs_beside_a_flight_that_writes_its_copypasses too;only_a_write_that_overlaps_a_piece_holds_the_fetch_backandranges_meet_only_where_they_share_a_byte;cargo test --release -p victory-gpu --lib, 5 runs: 399 passed, 35 ignored in 4; one had awatch::testsflake (#450).@adrianmjim, if you get the chance, the same passes with
VICTORY_RELAY_FETCH_GUARD=1would show whether the 21 % drawing-queue share, the +0.7 ms and the +34 % card-step fills come down. One limit remains: writes outside the declared ranges are not covered (as before), and the old whole-copy check no longer catches them by accident.AI-assisted (Claude Code); no game data.
@DragonQ on GitHub · 2026-11-27 11:55 UTC · original · edited 2026-11-27 13:41 UTC
Just tried this on my 6800 XT with
scripts\play.ps1 -Exe "..." -More @{VICTORY_RELAY_FETCH_GUARD='1';VICTORY_OUTPUT='1920x1080'}and it crashed after the loading screens before gameplay started.The ONLY fork that seems to not crash for me is https://github.com/kyokyotosh/VIctory-6700XT but that one has lots of graphical issues that the other ones (like Belobug) don't have!
@adrianmjim on GitHub · 2026-11-27 14:14 UTC · original
Same passes as above, now with
e1263e1andVICTORY_RELAY_FETCH_GUARD=1, on the same RX 7900 XT.What I ran:
e1263e1with the switch on and 3 of a-publier4eb6cfd, inside a block of 12 passes (guard 3rd, 6th, 9th; base 2nd, 8th, 10th; the other 6 were two other PRs), 65 minutes, nothing else on the GPU. Same route, settings,diagbuild and 60-235 s window.e1263e1with the switch off.6bc90e3from my earlier comment, measured about two hours earlier against its own three base passes.4eb6cfd, this block6bc90e3, earlier blocke1263e1, this blockThe three numbers:
3f91df5, one of the other PRs in the block, with no guard code, moves them the same way against the same base passes (+40 ± 16 %; title copies -6.3 ± 2.2 %, against -8.5 ± 12.1 % here). So the rise is not specific to the guard, and I no longer read fills as a measure of it.Frames and stalls:
What this cannot show:
diagbuild, a PNG saved every 8th frame, the process peaking at 30.5-31.4 GB private on a 32 GB PC with 0.1-0.3 GB left to commit at worst. The first guard pass made 82 pipelines (that exe's first run); the other five made 0-6.@MamaLeVrai on GitHub · 2026-11-27 15:15 UTC · original
Thanks @adrianmjim, this is clear, and the table is useful. Reading it: the byte range lowers the drawing-queue share by only 1.5 ± 0.7 points, the fetch wait is +0.45 ± 0.39 ms against base, and the frame and stall differences are inside the noise (the stall excess comes from two passes). So I won't claim a cost reduction, and the guard stays opt-in.
On the remaining fifth: in the code, copies that a submission only looks at still count whole (
fetchguard::WHOLE, host.rs ~4539), so that is the likeliest source, but it was not measured. I pushed27d6475, which adds two counters to the same frame line: of the fetches sent to the drawing queue, how many were held back only by such a whole copy, and how many by writes of known bytes. If a pass withVICTORY_RELAY_FETCH_GUARD=1is cheap for you, that line will say whether narrowing the looked-at copies is worth doing.AI-assisted (Claude Code); no game data.
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.