Skip to content

UCT/CUDA: Push CUDA context for system device on rkey unpack - v1.20 - #11240

Merged
brminich merged 3 commits into
openucx:v1.20.xfrom
iyastreb:ucp-fix-cuda-ipc-selection-1.20
Mar 11, 2026
Merged

brminich merged 3 commits into
openucx:v1.20.xfrom
iyastreb:ucp-fix-cuda-ipc-selection-1.20

Conversation

@iyastreb

@iyastreb iyastreb commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

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).

@iyastreb
iyastreb force-pushed the ucp-fix-cuda-ipc-selection-1.20 branch from 7d7333a to 5044bc7 Compare March 10, 2026 06:57
@brminich
brminich merged commit 8b77fb8 into openucx:v1.20.x Mar 11, 2026
143 checks passed
@iyastreb
iyastreb deleted the ucp-fix-cuda-ipc-selection-1.20 branch March 11, 2026 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants