fix(gpu): never make a send buffer past D3D12's largest, 4 GiB - 64 KiB (#3532) #4149

Closed
github-bot wants to merge 11 commits from github-bot/gh-4149 into main AGit
Owner

@⁠t91a60 on GitHub · 2026-11-30 16:49 UTC · original
t91a60:orchestrator/send-buffer/largest-send → main · +25 −2 · 1 files · 1 commits · closed without merging

What

#3994 (merged) took send buffers off powers of two: made_for() doubles to 64 MiB, goes in 64 MiB steps to 256 MiB (BIG), and past that makes the buffer at the send's own size in 64 KiB steps.

That last branch has no upper bound. A send in the last sliver before the limit therefore asks for a buffer of exactly 4 GiB, and D3D12's largest buffer is 4 GiB - 64 KiB. Per #3532, some cards/drivers kill the device on the attempt instead of refusing it.

Change

crates/victory-gpu/src/host/send.rs:

  • MAX_SEND = (4 << 30) - (64 << 10).
  • memory() answers None when made_for(size) would exceed it, before any buffer is asked for. host::card_before then takes the older upload path, as it does for any failed allocation.

The 64 MiB-step rounding itself — the other half of #3532 — is already on main in #3994; this PR only adds the cap.

Tests

a_send_past_the_largest_buffer_is_not_made_one: made_for() at the last sliver (4 GiB - 32 KiB → 4 GiB, above the cap), at the cap, and just past 2 GiB.

Verification

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

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

One file, +25/−2, no new dependencies. CI should be the gate before merge.

Refs #3532.

**@⁠t91a60** on GitHub · 2026-11-30 16:49 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4149) `t91a60:orchestrator/send-buffer/largest-send` → `main` · +25 −2 · 1 files · 1 commits · closed without merging ## What #3994 (merged) took send buffers off powers of two: `made_for()` doubles to 64 MiB, goes in 64 MiB steps to 256 MiB (`BIG`), and past that makes the buffer at the send's own size in 64 KiB steps. That last branch has no upper bound. A send in the last sliver before the limit therefore asks for a buffer of exactly **4 GiB**, and D3D12's largest buffer is **4 GiB - 64 KiB**. Per #3532, some cards/drivers kill the device on the attempt instead of refusing it. ## Change `crates/victory-gpu/src/host/send.rs`: - `MAX_SEND = (4 << 30) - (64 << 10)`. - `memory()` answers `None` when `made_for(size)` would exceed it, before any buffer is asked for. `host::card_before` then takes the older upload path, as it does for any failed allocation. The 64 MiB-step rounding itself — the other half of #3532 — is already on `main` in #3994; this PR only adds the cap. ## Tests `a_send_past_the_largest_buffer_is_not_made_one`: `made_for()` at the last sliver (4 GiB - 32 KiB → 4 GiB, above the cap), at the cap, and just past 2 GiB. ## Verification **UNVERIFIED — no Rust toolchain on the machine this was written on** (`cargo`, `rustc` and `rustup` are absent), so these were not run: ```text cargo test --locked -p victory-gpu cargo clippy -p victory-gpu --all-targets --no-deps -- -D warnings ``` One file, +25/−2, no new dependencies. CI should be the gate before merge. Refs #3532.
Past BIG (256 MiB) made_for() makes the buffer at the send's own size in 64 KiB steps, so a send in the last sliver before the limit asked for exactly 4 GiB. D3D12's largest buffer is 4 GiB - 64 KiB, and some cards/drivers die on the attempt at more instead of refusing it (#3532), so memory() answers None for such a send and the caller takes the older upload path.

The 64 MiB-step rounding itself already landed on main in PR #3994; this is the part of the issue it left: the cap.

Tests: made_for() at the last sliver, at the cap, and just past 2 GiB.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 16:51:54 +00:00
github-bot closed this pull request 2026-11-30 16:58:05 +00:00
Author
Owner

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

Closing as superseded.

#3532 is already fixed on main by merged PR #3994. In crates/victory-gpu/src/host/send.rs, made_for() no longer doubles past STEP: it goes in 64 MiB steps up to BIG (256 MiB), and past that makes the buffer at the send's own size in 64 KiB steps, with memory past 256 MiB never kept. That removes the 4 GiB request this PR was about before it can be made.

The cap-only follow-up proposed here — a MAX_SEND guard before a buffer is asked for — is not needed on top of that, so nothing from this branch is being carried forward.

Thanks for the write-up and the test; the 4 GiB vs. 4 GiB - 64 KiB analysis is what pointed at the rounding half that #3994 addresses.

No code changes made; the branch is left as is.

**@⁠t91a60** on GitHub · 2026-11-30 16:57 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4149#issuecomment-7285502445) Closing as superseded. #3532 is already fixed on `main` by merged PR #3994. In `crates/victory-gpu/src/host/send.rs`, `made_for()` no longer doubles past `STEP`: it goes in 64 MiB steps up to `BIG` (256 MiB), and past that makes the buffer at the send's own size in 64 KiB steps, with memory past 256 MiB never kept. That removes the 4 GiB request this PR was about before it can be made. The cap-only follow-up proposed here — a `MAX_SEND` guard before a buffer is asked for — is not needed on top of that, so nothing from this branch is being carried forward. Thanks for the write-up and the test; the 4 GiB vs. 4 GiB - 64 KiB analysis is what pointed at the rounding half that #3994 addresses. No code changes made; the branch is left as is.

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!4149
No description provided.