Skip to content

UCT/CUDA_IPC: Detect different PID namespace to avoid non-reachable - #11514

Merged
gleon99 merged 10 commits into
openucx:masterfrom
shasson5:fabric-query-attr
Jul 16, 2026
Merged

UCT/CUDA_IPC: Detect different PID namespace to avoid non-reachable#11514
gleon99 merged 10 commits into
openucx:masterfrom
shasson5:fabric-query-attr

Conversation

@shasson5

@shasson5 shasson5 commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

What?

Improve cuda_ipc reachability checks for peers in different PID namespaces by advertising CUDA fabric IPC support only when the local process can actually use it.

This PR adds:

  • a configure-time check for CU_DEVICE_ATTRIBUTE_HANDLE_TYPE_FABRIC_SUPPORTED
  • a CUDA base helper that queries that device attribute with cuDeviceGetAttribute()
  • a runtime check for accessible NVIDIA IMEX channel devices
  • a CUDA IPC device-address flag that lets peers exchange fabric support capability

Why?

Legacy CUDA IPC handles cannot be exchanged across different PID namespaces. In that case cuda_ipc should be considered reachable only if both peers support fabric IPC handles.

The previous approach detected local fabric support by trying to allocate and release a small fabric VMM buffer. Querying the CUDA device attribute is cleaner and avoids using allocation as a capability probe.

How?

When building CUDA IPC device addresses, the transport now sets a FABRIC flag if the current CUDA device reports fabric-handle support and the process can access an IMEX channel. During reachability, peers in different PID namespaces require both local and remote FABRIC support.

Validation

  • git diff --check

@shasson5 shasson5 changed the title Fabric query attr UCT/CUDA: Detect cuda_ipc fabric support without allocation Jun 2, 2026
@shasson5
shasson5 force-pushed the fabric-query-attr branch 3 times, most recently from 6ffbfcd to d2c3e22 Compare June 2, 2026 10:59
@shasson5 shasson5 added the WIP-DNM Work in progress / Do not review label Jun 3, 2026
@shasson5
shasson5 marked this pull request as ready for review June 3, 2026 17:30
@shasson5
shasson5 force-pushed the fabric-query-attr branch from ba5f721 to 0c81629 Compare June 4, 2026 08:17
@shasson5 shasson5 changed the title UCT/CUDA: Detect cuda_ipc fabric support without allocation UCT/CUDA_IPC: Add fabric flag to cuda address and detect different PID namespace to avoid non-reachable Jun 4, 2026
@shasson5 shasson5 removed the WIP-DNM Work in progress / Do not review label Jun 4, 2026
@shasson5

shasson5 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

@svc-nvidia-pr-review

@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Starting review — findings will be posted here when done.

@svc-nvidia-pr-review svc-nvidia-pr-review left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

6 findings — 🚨 3 blockers, ⚠️ 3 minors

6 findings posted as inline comments.

Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_iface.c Outdated
Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_iface.c Outdated
Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_iface.c Outdated
Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_iface.c Outdated
Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_iface.c Outdated
Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_iface.c Outdated
@shasson5 shasson5 added the WIP-DNM Work in progress / Do not review label Jun 4, 2026
@shasson5
shasson5 force-pushed the fabric-query-attr branch 5 times, most recently from 836cf3c to f62130c Compare June 4, 2026 17:07
@shasson5 shasson5 changed the title UCT/CUDA_IPC: Add fabric flag to cuda address and detect different PID namespace to avoid non-reachable UCT/CUDA_IPC: Detect different PID namespace to avoid non-reachable Jun 4, 2026
@shasson5
shasson5 force-pushed the fabric-query-attr branch from f62130c to 33c4001 Compare June 4, 2026 17:28
@shasson5 shasson5 removed the WIP-DNM Work in progress / Do not review label Jun 4, 2026
@shasson5
shasson5 requested review from gleon99 and yosefe June 4, 2026 17:38
Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_md.c Outdated
int fabric_supported = 0;
CUdevice cu_device;

if ((UCT_CUDADRV_FUNC(cuCtxGetDevice(&cu_device),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If no current context -> fabric_supported=0 is cached forever -> cross-PID-ns peers that actually support fabric won't advertise that flag.

Maybe query device 0 / all visible devices, or otherwise make the cached value independent of a current context? @rakhmets WDYT?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, query device 0 is enough.

@shasson5
shasson5 requested a review from gleon99 June 8, 2026 12:14
iface_addr_len = UCS_PARAM_VALUE(UCT_IFACE_IS_REACHABLE_FIELD, params,
iface_addr_length, IFACE_ADDR_LENGTH,
sizeof(remote_iface_addr.pid));
/* Older peers do not send pid_ns, so preserve legacy same-node reachability

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This misses the default/non-default pid ns case. A new peer in the default ns advertises only the legacy iface addr, so a non-default local peer enters this path w iface_addr_len < sizeof(remote_iface_addr) -> skips the fabric req.

That can mark legacy cuda ipc reachable across different pid ns's.

Need to distinguish default-ns peers from legacy ones, e.g can compare the unpacked default pid_ns against the local pid_ns

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to distinguish default-ns peers from legacy ones, e.g can compare the unpacked default pid_ns against the local pid_ns

this will cancel wire compatibility when local + remote are on the same non-default namespace.

@rakhmets is it safe to add pid_ns packing in cuda_ipc_iface address for default NS?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's safe to always pack pid ns to iface address. The only reason was to pack as less as possible. If it's the only way to implement the feature, then we have to pack this into the address.

@shasson5

Copy link
Copy Markdown
Contributor Author

@svc-nvidia-pr-review

@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Starting review — findings will be posted here when done.

@shasson5

Copy link
Copy Markdown
Contributor Author

@svc-nvidia-pr-review

@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Starting review — findings will be posted here when done.

@shasson5
shasson5 requested a review from gleon99 June 17, 2026 09:34
@shasson5

Copy link
Copy Markdown
Contributor Author

@rakhmets can review?

@shasson5

Copy link
Copy Markdown
Contributor Author

@svc-nvidia-pr-review

Comment thread src/ucp/wireup/wireup.c
.device_addr = ae->dev_addr,
.iface_addr = ae->iface_addr,
.device_addr_length = ae->dev_addr_len
.device_addr_length = ae->dev_addr_len,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we also update ucp_wireup_connect_lane_to_iface? and maybe other places that create ep and need to pass device/iface/ep address length?

@shasson5 shasson5 Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added to ucp_wireup_ep_connect_aux (no other relevant call site was found)

Comment thread src/uct/cuda/base/cuda_util.c Outdated
Comment on lines +29 to +46
int uct_cuda_base_device_supports_fabric(CUdevice cuda_device)
{
#if HAVE_CUDA_FABRIC && \
HAVE_DECL_CU_DEVICE_ATTRIBUTE_HANDLE_TYPE_FABRIC_SUPPORTED
int supported;

if (UCT_CUDADRV_FUNC(cuDeviceGetAttribute(
&supported,
CU_DEVICE_ATTRIBUTE_HANDLE_TYPE_FABRIC_SUPPORTED,
cuda_device), UCS_LOG_LEVEL_DEBUG) != UCS_OK) {
return 0;
}

return supported;
#else
return 0;
#endif
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why needed? we already check fabric support in current code , and the result is reflected in enabled_mnnvl field

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you refer to uct_cuda_ipc_md_check_fabric_info, it checks MNNVL support

typedef enum {
UCT_CUDA_IPC_DEVICE_ADDR_FLAG_MNNVL = UCS_BIT(0)
UCT_CUDA_IPC_DEVICE_ADDR_FLAG_MNNVL = UCS_BIT(0),
UCT_CUDA_IPC_DEVICE_ADDR_FLAG_FABRIC = UCS_BIT(1)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is FABRIC support different from MNNVL support? can we unite them?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fabric API can be available regardless of MNNVL support (for example for intra node communication between containers). We can use it on setups without NVLink

uct_cuda_ipc_iface_dev_addr_flags(const uct_cuda_ipc_device_addr_t *dev_addr,
size_t dev_addr_len)
{
if (dev_addr_len == sizeof(uint64_t)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if it's < 8 ?

@shasson5 shasson5 Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will fail in line 129:

    ucs_assertv(dev_addr_len >= sizeof(uct_cuda_ipc_device_addr_t),
                "dev_addr_len=%zu", dev_addr_len);

Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_iface.c Outdated
Comment on lines +178 to +182
/* Older peers do not send pid_ns, so preserve legacy same-node reachability
* and apply the cross-namespace fabric check only to extended addresses. */
remote_iface_addr = uct_cuda_ipc_iface_address_unpack(params->iface_addr,
iface_addr_len);
if ((iface_addr_len >= sizeof(remote_iface_addr)) &&

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if remote pid_ns is not present, we can assume it's the default ns, like in rkey case

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to distinguish "old address" from "default NS address" because for default NS we'd want to confirm Fabric API is supported, o/w a connection between host process and "container process" may be identified as reachable

uct_cuda_ipc_iface_address_t *cuda_ipc_iface_address;

*(pid_t*)iface_addr = getpid();
if (ucs_sys_ns_is_default(UCS_SYS_NS_TYPE_PID)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why need to pack NS in case it is default? we could save on the address length

@shasson5 shasson5 Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to distinguish "old address" vs "default NS address":

  1. old address -> this is wire compatibility mode, we'd want to keep same behavour as today (reachable regardless to PID NS).
  2. default NS -> if remote is default NS and local is non-default (e.g. run in container), then Fabric API is required for communication

}
#endif

static int uct_cuda_ipc_md_check_fabric_support(void)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it needed for reachability?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because different PID namespaces are only reachable when using Fabric API

@shasson5
shasson5 requested a review from yosefe June 22, 2026 15:04
Comment thread src/uct/cuda/base/cuda_util.c Outdated
Comment thread src/uct/cuda/base/cuda_util.c Outdated
Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_md.c Outdated
@shasson5
shasson5 requested a review from rakhmets July 5, 2026 09:21
@shasson5

shasson5 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

@yosefe please review

@gleon99
gleon99 requested a review from evgeny-leksikov July 8, 2026 05:44
@gleon99

gleon99 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

@yosefe WDYT?
All comments addressed.

@shasson5

Copy link
Copy Markdown
Contributor Author

@yosefe can take a look?

Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_iface.c
@shasson5
shasson5 requested a review from gleon99 July 16, 2026 07:36
@gleon99
gleon99 merged commit 12fe228 into openucx:master Jul 16, 2026
161 checks passed
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.

5 participants