GPU: a pipeline library save the host has no memory for waits, not aborts (1.7 GB library on NVIDIA) #2007

Manually merged
github merged 1 commit from gh-pr/2007/head into gh-pr/2007/base 2026-11-26 04:51:26 +00:00
Owner

@⁠KevinPratap on GitHub · 2026-11-25 02:48 UTC · original
KevinPratap:gpu/library-save-fallible → main · +26 −4 · 1 files · 1 commits · merged 2026-11-25 21:53 UTC

Problem

library::save serialises the pipeline library with vec![0u8; GetSerializedSize()]. On NVIDIA the library holds each pipeline's machine code: after translate --cache --pipelines it is about 1.7 GB on an RTX 4050 Laptop, where the README mentions about 4 MB on AMD. A save in the world then aborted the whole process:

memory allocation of 2650101862 bytes failed

(32 GB RAM, about 21 GB committed by the process at that point.)

Fix

The buffer is reserved with try_reserve_exact. Without memory, the save logs a warning and returns. The pipelines stay counted as added, so the next save tries again.

Verified

  • New test a_save_buffer_the_host_cannot_give_is_refused; the pipeline::library tests pass (9).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings is clean.

Related: the size itself (one blob rewritten whole every 20 s) is worth splitting on NVIDIA, but that is a larger change.

Only crates/victory-gpu/src/pipeline/library.rs changes.

AI-assisted.

🤖 Generated with Claude Code

**@⁠KevinPratap** on GitHub · 2026-11-25 02:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/2007) `KevinPratap:gpu/library-save-fallible` → `main` · +26 −4 · 1 files · 1 commits · merged 2026-11-25 21:53 UTC ## Problem `library::save` serialises the pipeline library with `vec![0u8; GetSerializedSize()]`. On NVIDIA the library holds each pipeline's machine code: after `translate --cache --pipelines` it is about **1.7 GB** on an RTX 4050 Laptop, where the README mentions about 4 MB on AMD. A save in the world then aborted the whole process: ``` memory allocation of 2650101862 bytes failed ``` (32 GB RAM, about 21 GB committed by the process at that point.) ## Fix The buffer is reserved with `try_reserve_exact`. Without memory, the save logs a warning and returns. The pipelines stay counted as added, so the next save tries again. ## Verified - New test `a_save_buffer_the_host_cannot_give_is_refused`; the `pipeline::library` tests pass (9). - `cargo clippy -p victory-gpu --all-targets -- -D warnings` is clean. Related: the size itself (one blob rewritten whole every 20 s) is worth splitting on NVIDIA, but that is a larger change. Only `crates/victory-gpu/src/pipeline/library.rs` changes. AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The library is serialised into one buffer of its whole size, allocated infallibly. On NVIDIA the library holds each pipeline's machine code, about 1.7 GB after translate --cache --pipelines, and a save in the world aborted the process: 'memory allocation of 2650101862 bytes failed' (RTX 4050 Laptop, 32 GB). The buffer is now reserved fallibly; without memory the save is left for later (the pipelines stay counted as added).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:51:23 +00:00
github manually merged commit 54b994d172 into gh-pr/2007/base 2026-11-26 04:51:26 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-25 03:35 UTC · original

Triage verdict — Keep the fallible allocation; preserve early-list retries (54b994d)

Evidence

  • The reservation failure now returns without aborting. There is one save path where leaving l.added intact is insufficient. When l.added == 0, prebuilt_changed is false, and the early list alone is dirty, the entry check consumes USED_CHANGED with swap(false, …) before calling zeroed. The new failure return leaves no dirty flag for a later retry. The existing serializer-error path has the same bookkeeping gap.

Checks and limits

  • The allocation helper test covers rejecting an unallocatable size and producing zero bytes for a small size. It does not go through save with only the early list dirty. The exact-head Windows check passed. I reviewed the source and CI without inducing host memory pressure.

Next step

  • Retain or restore the early-list dirty state when an allocation or serialization failure interrupts a save, without overwriting concurrent usage updates. A synthetic failed allocation with no new pipelines, followed by a successful retry, would pin the behavior. #72’s retry bookkeeping is a useful comparator for the broader save path.

This verification was AI-assisted.

**@⁠jeremygold02** on GitHub · 2026-11-25 03:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2007#issuecomment-7152062533) **Triage verdict — Keep the fallible allocation; preserve early-list retries** (`54b994d`) **Evidence** - The reservation failure now returns without aborting. There is one save path where leaving `l.added` intact is insufficient. When `l.added == 0`, `prebuilt_changed` is false, and the early list alone is dirty, the entry check consumes `USED_CHANGED` with `swap(false, …)` before calling `zeroed`. The new failure return leaves no dirty flag for a later retry. The existing serializer-error path has the same bookkeeping gap. **Checks and limits** - The allocation helper test covers rejecting an unallocatable size and producing zero bytes for a small size. It does not go through `save` with only the early list dirty. The [exact-head Windows check](https://github.com/Marvisak/VIctory/actions/runs/45535587136/job/138941267116) passed. I reviewed the source and CI without inducing host memory pressure. **Next step** - Retain or restore the early-list dirty state when an allocation or serialization failure interrupts a save, without overwriting concurrent usage updates. A synthetic failed allocation with no new pipelines, followed by a successful retry, would pin the behavior. #72’s retry bookkeeping is a useful comparator for the broader save path. This verification was AI-assisted.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 09:16 UTC · original

Automated triage for the maintainers.

Merge candidate.

crates/victory-gpu/src/pipeline/library.rs::save now allocates the serialisation buffer with try_reserve_exact (new helper zeroed) instead of vec[0u8; GetSerializedSize()], so a library too large for the host's free memory logs a warning and is retried on a later save instead of aborting the process. l.added/prebuilt_changed are left untouched on that path, so the retry does happen; on Windows the allocator reports failure rather than overcommitting, so try_reserve_exact is the right tool here. Small, focused, merges cleanly.

Optional follow-up, also raised in the earlier review comment: when only the early list is dirty, USED_CHANGED has already been swapped to false before the allocation, so a failed allocation (like the existing serialiser-error path) drops that pending early-list save until something else changes; restoring the flag on both failure returns would close that. #2129 contains the same fallible helper inside a much larger rework of the library file; this PR is the smaller way to land just the abort fix. Recommending a look, not approving.

CI: passing (check).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 09:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/2007#issuecomment-7158119598) <!-- victory-triage v1 head=54b994d172fbce85cb2e76fb10e4b901051efb4b verdict=merge-candidate at=2026-11-25T09:16:48Z --> Automated triage for the maintainers. **Merge candidate.** `crates/victory-gpu/src/pipeline/library.rs::save` now allocates the serialisation buffer with `try_reserve_exact` (new helper `zeroed`) instead of `vec[0u8; GetSerializedSize()]`, so a library too large for the host's free memory logs a warning and is retried on a later save instead of aborting the process. `l.added`/`prebuilt_changed` are left untouched on that path, so the retry does happen; on Windows the allocator reports failure rather than overcommitting, so `try_reserve_exact` is the right tool here. Small, focused, merges cleanly. Optional follow-up, also raised in the earlier review comment: when only the early list is dirty, `USED_CHANGED` has already been swapped to `false` before the allocation, so a failed allocation (like the existing serialiser-error path) drops that pending early-list save until something else changes; restoring the flag on both failure returns would close that. #2129 contains the same fallible helper inside a much larger rework of the library file; this PR is the smaller way to land just the abort fix. Recommending a look, not approving. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
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/Marvisak--VIctory!2007
No description provided.