cuda.core: allow updating Buffer deallocation streams - #2602
Open
Andy-Jost wants to merge 9 commits into
Open
Conversation
Record a DeallocationStream at device-pointer creation so default-stream tokens pin the allocation context (and PTDS the allocating thread) instead of relying on ambient state at free time.
Make the deallocation stream's context current around free/unmap/MR cleanup so destruction no longer depends on ambient CUDA context, and wire cuCtxSetCurrent into the resource-handles driver table.
Add keyword-only stream= on Buffer/ManagedBuffer.from_handle when mr owns the pointer, bind it at construction, and cover teardown with no or foreign current context.
Stop treating CUDA_ERROR_INVALID_CONTEXT as a successful pool free, and let explicit mr.deallocate() raise; destruction still contains errors in the callback. Document PTDS deallocation ordering on the stream parameters and note the context-safe Buffer teardown fix in the 1.2.0 release notes.
Require default deallocation streams to bind a current context at creation so teardown never relies on an ambiguous ambient token. Expand coverage and documentation for context-independent cleanup and failure reporting.
Ensure spawned children can bind the imported buffer's default deallocation stream before their process target starts.
|
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.
Important
Please hold review until #2526 merges. This PR is based on that work and will be rebased onto
mainafterward.Summary
Closes #2600.
Add
Buffer.set_deallocation_streamso callers can replace the stream that orders eventual deallocation without closing the buffer. This supports transferring an allocation's lifetime to another stream while preserving the existingBufferobject.Changes
Buffer.set_deallocation_streamAPI and generated type stub.DeallocationStreamcapture path.Related Work
mainafter that PR merges.