Repository navigation
fix(parallel_read): pin reader threads to the destination device - #46
Merged
Merged
Conversation
Reader threads start on cuda:0. Each one copies inside `torch.cuda.stream(stream)`, and leaving that context restores the thread's previous stream, which is cuda:0's, and switches the thread to device 0. On CUDA 12+ that switch initializes device 0's primary context. So every process that loads onto cuda:N (N > 0) leaves a ~600 MiB context on GPU 0. In an 8-rank job that is 7 extra contexts, ~4.3 GiB of GPU 0's memory, and rank 0 runs out of memory before its peers. Set the reader thread's device to the destination device first. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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
Every process that loads a flashpack onto
cuda:N(N > 0) through the parallel reader leaves a stray ~600 MiB CUDA context on GPU 0. In an 8-rank job, that's seven extra contexts, about 4.3 GiB of GPU 0's memory, so rank 0 runs out of memory before its peers.