Fix CUDA OOM reclaim - #18
Merged
Merged
Conversation
Address review: with exact-size pages, ExclusiveMemoryPool::get_free_page chose by free_count only, so a small request could occupy a much larger free page and strand the difference. Prefer the tightest fit, tie-break on free_count. Add regression tests for the sliced-pool OOM fallback (error propagation and single retry), SubSlices top-pool exactness, and tightest-fit reuse. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XGjMdBikQc3ZUptURQuE7B
Author
Review report (fresh-context code review + per-PR policy audit)Gate: PASS — no secrets, dangerous files, generated artifacts, caches, or debug leftovers in the diff. Net diff vs Findings and how they were addressed
Verification
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix CUDA OOM by reclaiming and retrying, and stop stranding memory in oversized slabs.
IoError::OutOfMemory(new variant): distinguishes a transient device OOM fromBufferTooBig.Command::reserve: on OOM, fence →memory_cleanup→ fence → retry once.SubSlicespreset: top pool is now exclusive with exact-size pages instead of awhole-device slab (an 800 MB tensor no longer reserves a 6 GB slab).
Risk: the exclusive-pool changes are backend-agnostic and also affect wgpu's staging/
uniform pools (less cross-size page reuse, bounded by the ~1.4× bucket ratio).
IoErrorgains a variant (non-#[non_exhaustive]; downstream exhaustive matches break).Verified:
cargo test -p t4a-cubecl-runtime --lib memory_management(43 pass);cargo check -p t4a-cubecl-cuda. The CUDA retry path itself needs a device to exercise.Note: the branch history also carries the CUDA complex-cast commits, but those are
already on
mainvia #17 and contribute no net diff here; squash-merge.Maintained by tensor4all to support tenferro-rs until merged upstream.