fix(gpu): round send buffers in 64 MiB steps so a send over 2 GiB is not a 4 GiB buffer (#3532) #4135

Closed
github-bot wants to merge 1 commit from gh-pr/4135/head into gh-pr/4135/base
Owner

@⁠t91a60 on GitHub · 2026-11-30 16:34 UTC · original
t91a60:orchestrator/send-buffer/round-64mib → main · +56 −4 · 1 files · 1 commits · closed without merging

What

send::memory rounded every send buffer up to the next power of two, with an 8 MiB floor:

let size = size.max(8 << 20).next_power_of_two();

A submission that sends a little over 2 GiB therefore took a 4 GiB buffer. Per #3532 some cards/drivers kill the device on the attempt (D3D12's largest buffer is 4 GiB - 64 KiB) instead of refusing it.

Change (crates/victory-gpu/src/host/send.rs)

  • Round up in 64 MiB steps instead of doubling, so 2 GiB + 1 gets a 2 GiB + 64 MiB buffer rather than 4 GiB.
  • Cap buffers at 4 GiB - 64 KiB (MAX_SEND), the largest D3D12 makes. Rounding the top sliver would land on 4 GiB, so it takes the cap instead.
  • A send needing more than the cap gets None, the same answer a failed allocation gives today: host::card_before then falls back to the older upload path instead of asking the device for an impossible buffer.
  • Spare reuse is unchanged: SPARE is still matched on the requested size (m.size >= size), so any spare at least that big is taken, and a 64 MiB step still finds the previous frame's buffer.

Tests

Three unit tests added beside the code:

  • a_send_a_little_over_two_gib_is_not_made_a_four_gib_buffer
  • send_buffers_round_up_in_steps_of_64_mib (never smaller than the request, always a step or the cap)
  • a_send_past_the_largest_buffer_has_none_and_the_last_sliver_is_capped

Verification

UNVERIFIED — no Rust toolchain on the machine this was written on (cargo, rustc and rustup are all absent), so these could not be run here:

cargo test --locked -p victory-gpu
cargo clippy -p victory-gpu --all-targets --no-deps -- -D warnings

The diff is one file, 56 insertions and 4 deletions, with no new dependencies. Please let CI be the gate before merge.

Fixes #3532.

**@⁠t91a60** on GitHub · 2026-11-30 16:34 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4135) `t91a60:orchestrator/send-buffer/round-64mib` → `main` · +56 −4 · 1 files · 1 commits · closed without merging ## What `send::memory` rounded every send buffer up to the next power of two, with an 8 MiB floor: ```rust let size = size.max(8 << 20).next_power_of_two(); ``` A submission that sends a little over 2 GiB therefore took a **4 GiB** buffer. Per #3532 some cards/drivers kill the device on the attempt (D3D12's largest buffer is 4 GiB - 64 KiB) instead of refusing it. ## Change (`crates/victory-gpu/src/host/send.rs`) - Round up in **64 MiB steps** instead of doubling, so 2 GiB + 1 gets a 2 GiB + 64 MiB buffer rather than 4 GiB. - Cap buffers at **4 GiB - 64 KiB** (`MAX_SEND`), the largest D3D12 makes. Rounding the top sliver would land on 4 GiB, so it takes the cap instead. - A send needing more than the cap gets `None`, the same answer a failed allocation gives today: `host::card_before` then falls back to the older upload path instead of asking the device for an impossible buffer. - Spare reuse is unchanged: `SPARE` is still matched on the _requested_ size (`m.size >= size`), so any spare at least that big is taken, and a 64 MiB step still finds the previous frame's buffer. ## Tests Three unit tests added beside the code: - `a_send_a_little_over_two_gib_is_not_made_a_four_gib_buffer` - `send_buffers_round_up_in_steps_of_64_mib` (never smaller than the request, always a step or the cap) - `a_send_past_the_largest_buffer_has_none_and_the_last_sliver_is_capped` ## Verification **UNVERIFIED — no Rust toolchain on the machine this was written on** (`cargo`, `rustc` and `rustup` are all absent), so these could not be run here: ```text cargo test --locked -p victory-gpu cargo clippy -p victory-gpu --all-targets --no-deps -- -D warnings ``` The diff is one file, 56 insertions and 4 deletions, with no new dependencies. Please let CI be the gate before merge. Fixes #3532.
next_power_of_two() took a send a little over 2 GiB to a 4 GiB buffer, and some cards/drivers kill the device on the attempt instead of refusing it. Round up in 64 MiB steps instead, cap at 4 GiB - 64 KiB, and refuse a send that needs more than that. Spare reuse is unchanged: the lookup still uses the requested size, so any spare at least that big is taken.

Tests: 2 GiB + 1 takes 2 GiB + 64 MiB, the steps from 0 to just under the cap, and the cap/refusal at 4 GiB - 64 KiB.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 16:39:46 +00:00
github-bot closed this pull request 2026-11-30 16:39:46 +00:00
Author
Owner

@⁠t91a60 on GitHub · 2026-11-30 16:37 UTC · original

Closing as superseded: main already has this fix.

memory() no longer doubles past the small sizes. In crates/victory-gpu/src/host/send.rs on main, made_for() now:

  • doubles up to 64 MiB (LEAST, STEP),
  • goes in 64 MiB steps up to 256 MiB (BIG),
  • and past that is made at the request's own size in 64 KiB steps, and never kept.

That landed after this branch's base (c71899d9) in 1ecaa98a ("Sends: ... made in 64 MiB steps past 64 MiB") and 8b801739 ("... memory past 256 MiB is never kept"). 1ecaa98a's message names the same failure this PR was written for: "one of 2112 MiB at load at 4 GiB, which one upload buffer may not be." It is why this branch both conflicts and repeats the change.

Issue #3532 was also closed as not planned by @⁠trustno1-coder at 15:30 UTC on 2026-11-30, before this PR was opened (16:34 UTC).

No tests were run here: this machine has no Rust toolchain installed.

The branch t91a60:orchestrator/send-buffer/round-64mib is left in place and can be deleted.

**@⁠t91a60** on GitHub · 2026-11-30 16:37 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4135#issuecomment-7284972290) Closing as superseded: `main` already has this fix. `memory()` no longer doubles past the small sizes. In `crates/victory-gpu/src/host/send.rs` on `main`, `made_for()` now: - doubles up to 64 MiB (`LEAST`, `STEP`), - goes in 64 MiB steps up to 256 MiB (`BIG`), - and past that is made at the request's own size in 64 KiB steps, and never kept. That landed after this branch's base (`c71899d9`) in `1ecaa98a` ("Sends: ... made in 64 MiB steps past 64 MiB") and `8b801739` ("... memory past 256 MiB is never kept"). `1ecaa98a`'s message names the same failure this PR was written for: "one of 2112 MiB at load at 4 GiB, which one upload buffer may not be." It is why this branch both conflicts and repeats the change. Issue #3532 was also closed as not planned by @⁠trustno1-coder at 15:30 UTC on 2026-11-30, before this PR was opened (16:34 UTC). No tests were run here: this machine has no Rust toolchain installed. The branch `t91a60:orchestrator/send-buffer/round-64mib` is left in place and can be deleted.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!4135
No description provided.