Repository navigation
UCT/CUDA: Push CUDA context for system device on rkey unpack - v1.20 - #11240
Merged
brminich merged 3 commits intoMar 11, 2026
Merged
Conversation
iyastreb
force-pushed
the
ucp-fix-cuda-ipc-selection-1.20
branch
from
March 10, 2026 06:57
7d7333a to
5044bc7
Compare
brminich
approved these changes
Mar 11, 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.
What?
Backport #11194 to v.1.20.x
In Sglang with NIXL/UCX backend cuda_ipc is never selected.
This PR fixes that, the real fix is in cuda_ipc.md
The rest is just moving common CUDA utils into a separate cuda_util files.
Why?
SGlang uses many threads, and CUDA memory allocation happens in one thread with some context, while MD exchange happens in another one without active CUDA context. MD exchange triggers rkey unpack, and for cuda_ipc we detect reachability there. Since there is no currently active context, cuda_ipc is marked as unreachable => never selected.
How?
When unpacking cuda_ipc rkey, if CUDA context is not set, use the first available active context.
What if we push the wrong context? That should be ok, because this push is just for reachability check. Later on during the CUDA operation we detect the actual CUDA ctx from CUDA memory attributes and select the right context.
The fix uses existing functionality that were in static functions in cuda_copy_md.
Why so much refactoring? Because there was no appropriate place for common CUDA utils.
So I moved CUDA utils functions into a new cuda_util files. They were previously scattered a bit everywhere in cuda module (md, iface, ep).