Honor non-blocking pinned-memory copies - #35
Merged
Conversation
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.
Summary
This PR allows contiguous CPU-to-Infini and Infini-to-CPU copies to return asynchronously only when non_blocking=True, the CPU tensor uses torch-infini pinned memory, the runtime advertises asynchronous memcpy and pinned-host allocation, and the device storage lifetime can be tracked.
It records both host and device storage use on the active stream and waits for recorded work before releasing either allocation. Sliced pinned tensors and alternative DataPtr contexts are resolved through the HostAllocator context and live pointer range contracts.
Copies involving ordinary host memory, unsupported runtime capabilities, or external device storage continue to execute in stream order and synchronize before returning without raising after a successful copy.
It documents the supported contract and adds behavioral tests for early return, immediate storage release, sliced storage, alternative contexts, external allocators, and CPU capability fallback.
This advances #10. This PR is stacked on #32 because the lifecycle tests create enough streams to require the stream registry teardown fix.
Validation