Add parameter to control whether to record stream#9
Open
RichardWooSJTU wants to merge 2 commits intoPFCCLab:paddlefrom
Open
Add parameter to control whether to record stream#9RichardWooSJTU wants to merge 2 commits intoPFCCLab:paddlefrom
RichardWooSJTU wants to merge 2 commits intoPFCCLab:paddlefrom
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
Add a skip_x_record_stream parameter (default false) to intranode_dispatch and intranode_combine, allowing callers to skip record_stream on large activation tensors (x, recv_x) to reduce GPU memory pressure
When skip_x_record_stream=True, PyTorch's CUDA caching allocator can reclaim the memory of x/recv_x earlier, instead of holding it until the communication stream finishes
Motivation
record_stream prevents the CUDA caching allocator from reusing a tensor's memory until the recorded stream completes. For large activation tensors like x and recv_x, this significantly increases peak GPU memory usage. In scenarios where the caller can guarantee the lifetime of these tensors externally (e.g., the tensors are kept alive by Python references until the comm stream finishes), skipping record_stream is safe and reduces memory footprint.
Changes
Usage