Repository navigation
Preserve device contexts when duplicate init fails - #176
Merged
nihalpasham merged 1 commit intoJun 17, 2026
Merged
nihalpasham merged 1 commit into
nihalpasham merged 1 commit into
Conversation
Collaborator
|
LGTM 👍🏾
Reviewer note, verified: the added duplicate-init test passes and genuinely fails on the old code. |
meefs
pushed a commit
to meefs/cuda-oxide
that referenced
this pull request
Sep 30, 2026
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
init_device_contextsfrom clearing the thread-local device map while checking for duplicate initializationWhy
ctx.devices.replace(None).is_none()used the duplicate-init predicate itself to replace the existing map withNone. That made the first duplicate call returnContext already initialized, but it also dropped the initialized state, so a later call could initialize again.Validation
cargo fmt --checkgit diff --checkcargo test -p cuda-async duplicate_init_preserves_existing_device_contexts(blocked locally: CUDA toolkit headers are not installed;cuda-bindingscould not findcuda.hunder/usr/local/cuda)