Skip to content

Submission split: card_record reads each copy's before hashes once (port of Biskwit/VIctory-reloaded 4d3eae2) - #3881

Open
JSa25 wants to merge 2 commits into
trustno1-coder:mainfrom
JSa25:pr/split-befores
Open

JSa25 wants to merge 2 commits into
trustno1-coder:mainfrom
JSa25:pr/split-befores

Conversation

@JSa25

@JSa25 JSa25 commented Nov 30, 2026

Copy link
Copy Markdown

Fixes #

What it changes

With VICTORY_SUBMIT_SPLIT=1, one thread prepares the next submission while the sending thread records and sends the one before it. The preparing side's card_take makes a copy's "before" hash buffer (Shadow::card_make_before; Card::before is a lock-free OnceLock) without CARD_WORK, as the comment at its call site says. The sending thread holds CARD_WORK while it records. (The comment inside card_make_before, "the sole current caller already holds CARD_WORK", is out of date.)

card_record asked whether a copy has its "before" buffer several times while recording one sync list:

  • for the sends' transitions (send::Own::record, card_has_before());
  • for the fallback path's transition from COPY_DEST to NON_PIXEL_SHADER_RESOURCE;
  • again for the hash passes (card_before_gpu()).

If the other thread makes the buffer between those reads, the first read says "none", so no barrier to a read state is recorded. A later read says "there", so a hash pass is recorded over a copy still in COPY_DEST or UNORDERED_ACCESS.

This change looks at each copy's buffer once, right after the sync list is taken (befores), and gives that one answer to the sends, the transitions and the hash passes. A copy whose buffer appears later is hashed whole by the take that made it, which is behind this list on the queue. send::Own::record takes the answers as a new befores parameter. The compare lists recorded later in card_record (from declared and looked) are not changed.

This is a port of Biskwit/VIctory-reloaded 4d3eae2 (GPL-3.0-or-later, like this repository), adapted to main. We found the race by reading the code. We have not caught it in a log.

Why now: #3809 turns VICTORY_SUBMIT_SPLIT=1 on by default, and then this window exists in every run. With the split off, both sides run on one thread and nothing changes.

How it was tested

  • GPU and profile: RTX 5090, Ryzen 9 9950X3D, Series X, 2560x1440 with DLSS Quality, frame generation off, ray tracing off, VICTORY_SUBMIT_SPLIT=1.
  • Before / after: no change in speed is expected or claimed; it adds one Vec<Option<u64>> per sync list. We did not A/B it for fps.
  • In game: five runs of the opening cell route on main 41adb55 plus this change (and other local switches) had no device loss. One of them, with an unrelated experimental shader switch also on, ended about 10 s into the world on "a host command list did not close (0x80070057)". That error was not in our 21 earlier logs, the command was not identified (no D3D12 debug layer installed), and it has not happened again in the run since.
  • For shader changes, the wave sizes tested: not a shader change.
  • cargo test passed for the crates it touches:
    • cargo test --release --locked -p victory-gpu --lib -- --test-threads=1 on this branch: 921 passed, 1 failed. On unchanged main 41adb55 the result is identical: the same 921 passed and the same 1 failed.
    • The one failure is main's own: shader_cache::tests::every_switch_of_the_translator_is_in_the_key, which reports "VICTORY_SCALAR_SPLITS is not read by the translator any more".
    • Run in parallel, both this branch and main fail 1 to 4 more tests from run to run (card_steps, menu, pool, resource). Each passes alone; see card_steps: the two "late" tests forget what an earlier one learned of their pages (order-dependent failure) #3668.
  • cargo check --release --locked -p victory: passes.

Checked for overlap

AI use: Claude Code (Claude Opus 5.5) prepared this branch, ran the tests and wrote this text. Posted with the account owner's approval.

@github-actions github-actions Bot added the pr-fix Pull request: fixes a bug label Nov 30, 2026
@github-actions github-actions Bot changed the title [pr-fix] Submission split: card_record reads each copy's before hashes once (port of Biskwit/VIctory-reloaded 4d3eae2) Submission split: card_record reads each copy's before hashes once (port of Biskwit/VIctory-reloaded 4d3eae2) Nov 30, 2026
@tyr0nsur

Copy link
Copy Markdown
Contributor

I found a second ordering case after the sync-list snapshot at ba9fd3b. With split submission, A's take can fail the first hash-buffer allocation. B's take can retry and publish the buffer before the sender records A. B's whole fill still runs behind A on the queue. A can therefore select a declared compare or lazy compare using hashes it cannot yet rely on, even with a consistent sync snapshot.

The follow-up stores the filling submission's existing sent_as alongside the GPU address in the OnceLock. The sync pass, declared ranges, looked ranges, lazy sweep and compute compare all check it. A uses the existing conservative copy-back and B can fill and use its buffer in queue order. This keeps the PR's single sync snapshot.

The new regression forces the first reservation to fail and the second to allocate a real D3D12 buffer. It failed on this PR head because the earlier submission could see that buffer. It passed with the patch on an RTX 4060 and WARP. The focused diagnostics suite passed 15 tests. This is a synthetic allocation-order test.

Companion commit

@akimfomin

Copy link
Copy Markdown

@tyr0nsur I carried your a36da0b5 follow-up and @JSa25’s snapshot onto the pinned Lab control, preserving its coalesced copy plan and borrowed declared/looked iterators. The exact generated allocation-order regression executed on our Windows RTX 4070 Ti SUPER. Submission 10 rejected the allocation first filled by submission 11, and 11 and 12 both saw the expected address. Five send-plan tests also passed. A full-RT walk is running on the combined port. I’ll keep the split setting opt-in while collecting gameplay evidence.

PranThow added a commit to PranThow/VIctory-NVIDIA that referenced this pull request Nov 30, 2026
…h copy's before hashes once (port of Biskwit/VIctory-reloaded 4d3eae2)
FormulaChenZen added a commit to FormulaChenZen/VIctory-NVIDIA that referenced this pull request Nov 30, 2026
Preserve EXEC masks across loop joins, including the light atlas used in 24/7 interiors. Include the shader regression cases from trustno1-coder#2853 and trustno1-coder#3871.

Enable split submission in the two Foxhound launchers (trustno1-coder#3809). Snapshot the hash buffers before the sender records work (trustno1-coder#3881), including allocation failures affecting declared and probed ranges.

Port the incremental resource sweep and empty-pass backoff from trustno1-coder#3858. Preserve manual flush behavior and include coverage for sweep progression and eviction.
moritz-eckhard-nickel added a commit to moritz-eckhard-nickel/VIctory-NVIDIA that referenced this pull request Nov 30, 2026
…hes once (VICTORY_SUBMIT_SPLIT race)

Conflicts: our own-memory split (own_until) gets befores[..own_until]; the direct loop
keeps its index; the hash loop takes the one answer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JSa25 and others added 2 commits November 30, 2026 09:04
With VICTORY_SUBMIT_SPLIT=1 the next submission's card_take can make a
copy's "before" hash buffer (Card::before, a lock-free OnceLock) while
card_record records the sync list of the one before it. card_record asked
for that buffer separately for the sends' transitions
(send::Own::record), for the fallback path's transition to a read state and
for the hash passes, so a pass could be recorded over a copy still in
COPY_DEST or UNORDERED_ACCESS with no barrier to a read state.

The buffers are now looked at once, right after the sync list is taken,
and that one answer goes to the sends, the transitions and the hash
passes. A copy whose buffer appears later is hashed whole by the take
that made it, which is behind this list on the queue. The compare lists
recorded later in card_record are unchanged.

Port of Biskwit/VIctory-reloaded 4d3eae2 (GPL-3.0-or-later).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When an earlier allocation fails, let that submission retain its conservative copy-back even if the split prepare thread has published a later buffer. Gate both sync and compare passes on the number of the first whole fill.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@JSa25

JSa25 commented Nov 30, 2026

Copy link
Copy Markdown
Author

Thanks @tyr0nsur. I reviewed it and pulled your commit in as it is, with your authorship kept (59c79f3 after the rebase). The numbering holds: with the relay on, both take paths number from QUEUE_ORDER, and without it every take is 0, so nothing changes there.

I also rebased the branch onto c71899d, since main had moved. send::Own::record now runs on the scratch guard and copy_runs, and host.rs uses looked.iter(&declared). It shows as mergeable again. Two notes from that:

  • Main's lib tests don't compile at c71899d. The compare-prelude UAV test (990be53) calls card_pass with 5 arguments since Copy-back by memory class: opt-in switches to leave GPU writes the title does not read on the card #3838 added capture. With , [0, 0, 0] added to its two calls, which is not part of this PR, cargo test --release --locked -p victory-gpu --lib -- --test-threads=1 gives:

    • this branch: 1115 passed, 2 failed;
    • main: 1114 passed, the same 2 failed (shader_cache::tests::every_switch_of_the_translator_is_in_the_key and list::thin::tests::bindings_record_no_work).

    The extra pass is your later_hash_allocation_is_hidden_from_an_earlier_submission, which ran on an RTX 5090 rather than skipping.

  • One ungated read is left, and it's harmless. The new compare prelude's UAV barrier list takes card_sides()'s before for compared ranges. compared is twin && fits, and every twin is now the gated card_before_gpu(sent_as), so this only adds barriers for buffers this submission may use.

Thanks also @akimfomin for running the regression on the Lab branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-fix Pull request: fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants