Skip to content

UCT/CUDA: Reject IPC without P2P read/write support - #11979

Merged
tvegas1 merged 4 commits into
openucx:masterfrom
pentschev:reject-ipc-without-native-peer-access
Nov 10, 2026
Merged

tvegas1 merged 4 commits into
openucx:masterfrom
pentschev:reject-ipc-without-native-peer-access

Conversation

@pentschev

@pentschev pentschev commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

What?

Prevent CUDA IPC from being selected when NVML reports that the local and remote GPUs support neither P2P read nor P2P write access.

During CUDA IPC rkey unpack, UCX now looks up the local and remote GPU UUIDs in NVML. If both P2P capabilities are explicitly unsupported, the rkey is marked unreachable. UCP then records the rejected memory domain as unreachable in the remote rkey it models for nested rendezvous selection. This lets the existing host-staged pipeline be selected.

If NVML cannot resolve the peer or reports an unknown P2P status, the existing IPC handle-mapping probe still decides reachability.

Why?

Importing a CUDA IPC handle successfully does not mean the GPU pair supports native P2P access. The test system is an AWS g7e.48xlarge with 8 x NVIDIA RTX PRO 6000 Blackwell Server Edition GPUs. On it, CUDA allows mapping memory between GPUs behind different PCIe bridges, even though NVML reports P2P access as unsupported. Transfers through that mapping are extremely slow.

So with cuda_ipc enabled, UCX would not select its faster host-staged pipeline. Users had to disable the transport explicitly.

The system has eight GPUs arranged as four same-bridge pairs:

  • GPU0-GPU1, GPU2-GPU3, GPU4-GPU5, and GPU6-GPU7: PIX
  • GPU pairs behind different PCIe bridges in the same NUMA node: NODE
  • GPU pairs across NUMA nodes: SYS

NVML reports P2P read and write as supported for the PIX pairs and NVML_P2P_STATUS_NOT_SUPPORTED for every NODE and SYS pair. The same capability matrix was seen on a second identical g7e.48xlarge.

Results for ucx_perftest -t tag_bw -m cuda with 100 MiB messages, -O 2, UCX_TLS=^srd, 100 iterations, and processes pinned to the GPUs' NUMA node:

GPU pair Topology Unpatched Patched cuda_ipc disabled Selected data path
GPU0 -> GPU2 NODE, P2P unsupported 0.88 GB/s (unpatched: CUDA IPC driver fallback)
GPU4 -> GPU6 NODE, P2P unsupported 33 GB/s (23-44) 33-44 GB/s cuda_copy/CMA host-staged pipeline
GPU6 -> GPU4 NODE, P2P unsupported 32-44 GB/s cuda_copy/CMA host-staged pipeline
GPU4 -> GPU7 NODE, P2P unsupported 33-44 GB/s cuda_copy/CMA host-staged pipeline
GPU4 -> GPU5 PIX, P2P supported 52.5 GB/s CUDA IPC

On unsupported pairs the patched build matches running with cuda_ipc disabled, while cuda_ipc stays enabled and is still used for the supported PIX pair. Host-staged bandwidth varies between runs, ranging from about 33 to 44 GB/s.

How?

The packed CUDA IPC rkey already contains the remote GPU UUID. During rkey unpack, UCX now:

  1. Resolves the local and remote UUIDs to NVML devices.
  2. Queries P2P read and write capability.
  3. Keeps CUDA IPC when either capability is supported.
  4. Returns UCS_ERR_UNREACHABLE when both capabilities are explicitly unsupported.
  5. Falls back to the existing handle-mapping probe when NVML cannot resolve the peer or reports an unknown result.

CUDA IPC has one reachability result that covers both GET and PUT. Rejecting the pair only when neither direction is supported keeps the existing behavior on topologies that support just one direction.

During nested rendezvous selection, UCP models the remote protocol with a synthetic remote rkey that describes the local buffer. The peer is expected to fail to unpack the same memory domains that failed locally. These domains are therefore moved from md_map to unreachable_md_map in the synthetic key, matching what ucp_ep_rkey_unpack_internal() produces on the peer. This also covers rndv/rtr/mtype with CUDA staging buffers, which keeps its full packed MD map. Without it, the peer's write through CUDA IPC would still be estimated, and the slow path would be selected again.

This is a conservative capability check, not a bandwidth heuristic. GPU pairs for which NVML reports P2P read or write support remain eligible for CUDA IPC.

CUDA IPC handle mapping may succeed even when GPUs do not support
native peer access. This can select a very slow driver fallback for GPU
pairs connected through different PCIe bridges.

Resolve local and remote GPU UUIDs with NVML and require native read and
write peer access. Mark unsupported IPC rkeys unreachable and exclude their
memory domains from nested rendezvous modeling so UCP can select its
host-staged pipeline.

Keep the existing handle-mapping probe as a fallback when NVML cannot
resolve the peer or returns an unknown status.
@pentschev pentschev self-assigned this Sep 22, 2026
@pentschev pentschev added Optimization Code / performance optimization Ready for Review labels Sep 22, 2026
@tvegas1
tvegas1 self-requested a review September 22, 2026 08:23
@svc-nvidia-pr-review

Copy link
Copy Markdown

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

Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_md.c Outdated
bytes[15]);
}

int uct_cuda_ipc_nvml_peer_accessible(CUdevice cu_dev,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

the function returns ternary values, pls use the ternary type instead of int

Suggested change
int uct_cuda_ipc_nvml_peer_accessible(CUdevice cu_dev,
ucs_ternary_auto_value_t
uct_cuda_ipc_nvml_peer_accessible(CUdevice cu_dev, const CUuuid *remote_uuid)

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.

Done.

Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_md.c Outdated
int uct_cuda_ipc_nvml_peer_accessible(CUdevice cu_dev,
const CUuuid *remote_uuid)
{
char local_uuid_string[NVML_DEVICE_UUID_ASCII_LEN];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

is NVML_DEVICE_UUID_ASCII_LEN defined in the oldest nvml.h we support? NVML decls that are not always present are guarded by AC_CHECK_DECLS in config/m4/cuda.m4.

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.

Removed. The buffer now uses NVML_DEVICE_UUID_BUFFER_SIZE.

Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_md.c Outdated
return UCS_TRY;
}

if (!memcmp(&local_uuid, remote_uuid, sizeof(local_uuid))) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

minor: memcmp() is not a boolean, pls compare explicitly (same as cuda_ipc_cache.c:848)

Suggested change
if (!memcmp(&local_uuid, remote_uuid, sizeof(local_uuid))) {
if (memcmp(&local_uuid, remote_uuid, sizeof(local_uuid)) == 0) {

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.

Done.

Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_md.c Outdated
(UCT_CUDA_NVML_WRAP_CALL(nvmlDeviceGetHandleByUUID,
remote_uuid_string,
&remote_device) != UCS_OK) ||
(UCT_CUDA_NVML_WRAP_CALL(nvmlDeviceGetP2PStatus, local_device,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

why do we require both READ and WRITE to be NVML_P2P_STATUS_OK? On topologies where NVML reports read P2P as not supported but the driver still allows peer copies, this silently disables cuda_ipc for the pair.

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.

is it possible to declare P2P it if any is true, to err on safe side

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.

The peer is now rejected only if NVML reports that neither READ nor WRITE is supported.

Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_md.c Outdated
rkey->stream_id = cache->dev_num;
accessible = &cache->accessible[cu_dev];
if (ucs_unlikely(*accessible == UCS_TRY)) { /* unchecked, add to cache */
*accessible = uct_cuda_ipc_nvml_peer_accessible(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

minor: the value written here is overwritten by the open-memhandle result below, only UCS_NO needs to be cached; maybe keep the NVML result in a local variable to make that clear.

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.

Done.

Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_md.h Outdated


int uct_cuda_ipc_nvml_peer_accessible(CUdevice cu_dev,
const CUuuid *remote_uuid);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

minor: one extra space, pls align with the definition in cuda_ipc_md.c.

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.

Fixed.

Comment thread src/ucp/rndv/proto_rndv.c
*/
rkey_config_key.md_map = ucp_proto_rndv_md_map_to_remote(params,
md_map);
if (params->super.super.rkey_config_key != NULL) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

should this be skipped when UCP_PROTO_COMMON_KEEP_MD_MAP is set, like in ucp_proto_rndv_ctrl_init_priv()? Otherwise rndv/rtr/mtype estimates the remote protocol with a smaller md_map than the one it actually packs.

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.

I tried this, and it brings back the slow path. On g7e GPU4 -> GPU6 (NODE, no native P2P), RNDV_RECV selected rndv/rtr/mtype with a CUDA staging buffer, and the peer wrote to it through cuda_ipc.

rtr/mtype still packs cuda_ipc for its staging buffer, but the peer cannot unpack it for the same GPU pair. So the estimate without cuda_ipc matches what the peer can actually use. With https://github.com/openucx/ucx/pull/11979/changes#r4131274778, the synthetic key now matches the peer's unpack result: the packed MDs are split into md_map and unreachable_md_map, like ucp_ep_rkey_unpack_internal() does. The new rndv_recv_unreachable test covers this case and fails if the mask is skipped for KEEP_MD_MAP.

@svc-nvidia-pr-review

Copy link
Copy Markdown

Residual coverage gap: the new gtest requires ≥2 CUDA devices and skips when NVML is unavailable, and it asserts NVML P2P status equals cuDeviceCanAccessPeer for visible devices only — the motivating case (peer GPU hidden by CUDA_VISIBLE_DEVICES, or P2P reported unsupported while cuIpcOpenMemHandle succeeds) is not exercised.

Residual coverage gap: the proto_rndv.c masking has no test; test/gtest/ucp/test_ucp_proto.cc:523 always sets unreachable_md_map = 0, so this path is only covered indirectly by real unreachable-MD runs.

@svc-ucx

svc-ucx commented Sep 22, 2026

Copy link
Copy Markdown

🤖 CI Triage Agent — UCX PR (WireCompat Build on gpu) · commit 66b6afd1

TL;DR: The WireCompat/gpu build fails to compile cuda_ipc_md.c because the new uct_cuda_ipc_nvml_peer_accessible() function (added by this PR) uses NVML_DEVICE_UUID_ASCII_LEN, a macro that does not exist in the older NVML header shipped with CUDA 11.2 on that CI image; replace it with a UCX-local buffer size constant (or NVML_DEVICE_UUID_BUFFER_SIZE).

Full analysis

Summary: Build ucx artifact stage failed with -Werror compile errors in src/uct/cuda/cuda_ipc/cuda_ipc_md.c — 'NVML_DEVICE_UUID_ASCII_LEN' undeclared.

Root cause: The build container uses CUDA 11.2 (log: Detected CUDA version: 11.2, plus nvmlDeviceGetGpuFabricInfoV ... no, NVML_FI_DEV_C2C_LINK_COUNT ... no — i.e. an old nvml.h). NVML_DEVICE_UUID_ASCII_LEN was introduced in a later NVML/CUDA release, so on this image the identifier is undefined:

cuda_ipc/cuda_ipc_md.c:509:28: error: 'NVML_DEVICE_UUID_ASCII_LEN' undeclared (first use in this function)
cuda_ipc/cuda_ipc_md.c:510:10: error: unused variable 'remote_uuid_string' [-Werror=unused-variable]
cuda_ipc/cuda_ipc_md.c:509:10: error: unused variable 'local_uuid_string' [-Werror=unused-variable]
cc1: all warnings being treated as errors

The two "unused variable" errors are secondary fallout from the failed array-size expansion. UCX builds with -Wall -Werror, so this is fatal. Nothing in src/uct/cuda/base/cuda_nvml.h or configure provides a fallback definition for this macro, and the code that formats the UUID (uct_cuda_ipc_uuid_to_string, line 492) is UCX's own and does not actually need an NVML-provided size.

Implicated commit: [REDACTED:Hex High Entropy String] — "UCT/CUDA: Reject IPC without native peer access", Peter Andreas Entschev

File: src/uct/cuda/cuda_ipc/cuda_ipc_md.c:509-510

Suggested fix: Don't depend on the newer NVML macro. The string produced by uct_cuda_ipc_uuid_to_string() is a fixed GPU-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx form (40 bytes + NUL), so define a local constant and use it:

/* "GPU-" + 32 hex chars + 4 dashes + '\0' */
#define UCT_CUDA_IPC_UUID_STR_LEN 41
...
char local_uuid_string[UCT_CUDA_IPC_UUID_STR_LEN];
char remote_uuid_string[UCT_CUDA_IPC_UUID_STR_LEN];

Alternatively use the long-standing NVML_DEVICE_UUID_BUFFER_SIZE (present since early NVML), or add a compatibility fallback in src/uct/cuda/base/cuda_nvml.h:

#ifndef NVML_DEVICE_UUID_ASCII_LEN
#define NVML_DEVICE_UUID_ASCII_LEN NVML_DEVICE_UUID_BUFFER_SIZE
#endif

The first option is preferable since it keeps the buffer size tied to UCX's own formatter. Also note uct_cuda_ipc_nvml_peer_accessible() is declared int but returns UCS_YES/UCS_NO/UCS_TRY; consider ucs_ternary_value_t for clarity while touching this code.

Related: PR #11979 (this PR) — #11979

🛡️ This comment had 1 potential secret(s) redacted (Hex High Entropy String). See request_id 325dcf92-697e-4ebd-b3b5-8927a85405db in the triage console for the audit trail.

Comment thread src/ucp/rndv/proto_rndv.c
*/
rkey_config_key.md_map = ucp_proto_rndv_md_map_to_remote(params,
md_map);
if (params->super.super.rkey_config_key != NULL) {

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.

to cover maybe:

UCS_TEST_P(test_ucp_proto_mock_cuda_ipc_unreachable, rtr_md_map)
{
    const ucp_md_index_t md_index = cuda_ipc_md_index();
    ASSERT_NE(UCP_NULL_RESOURCE, md_index) << "no cuda_ipc lane";
    /* cuda_ipc rejected at unpack must not be re-proposed by nested rndv */
    EXPECT_TRUE(rtr_md_map(0) & UCS_BIT(md_index));
    EXPECT_FALSE(rtr_md_map(UCS_BIT(md_index)) & UCS_BIT(md_index));
}

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 test_ucp_proto_mock_cuda_ipc.rndv_recv_unreachable. rndv/rtr already removed unreachable MDs from its packed RTR map in ucp_proto_rndv_ctrl_init_priv(). The gap was the nested remote estimate, mostly for rndv/rtr/mtype, which keeps its packed MD map. So the test checks the RNDV_RECV selection instead of rtr_md_map().

Comment thread src/ucp/rndv/proto_rndv.c Outdated

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.

Should we also set rkey_config_key.unreachable_md_map here instead of leaving it 0? ucp_ep_rkey_unpack_internal() keeps the two maps disjoint, and mirroring that on the synthetic key would avoid this config aliasing onto a peer config that never had cuda_ipc.

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.

Done.

Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_md.c Outdated
(UCT_CUDA_NVML_WRAP_CALL(nvmlDeviceGetHandleByUUID,
remote_uuid_string,
&remote_device) != UCS_OK) ||
(UCT_CUDA_NVML_WRAP_CALL(nvmlDeviceGetP2PStatus, local_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.

is it possible to declare P2P it if any is true, to err on safe side

Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_md.c Outdated
*accessible = uct_cuda_ipc_nvml_peer_accessible(
cu_dev, &rkey->super.super.uuid);
if (*accessible == UCS_NO) {
ucs_debug("CUDA IPC peer does not support native P2P access");

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.

can you pls add details of the memory ptr size etc, similar to done inside open mem handle below (specific step to be mentioned in same log where it failed during the new p2p check)?

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.

Done. The log now names the NVML P2P check step and prints the local device, remote buffer address and length.

Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_md.c Outdated
int uct_cuda_ipc_nvml_peer_accessible(CUdevice cu_dev,
const CUuuid *remote_uuid)
{
char local_uuid_string[NVML_DEVICE_UUID_ASCII_LEN];

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.

seems we should use NVML_DEVICE_UUID_BUFFER_SIZE?

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.

Done.

Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_md.c Outdated
bytes[15]);
}

int uct_cuda_ipc_nvml_peer_accessible(CUdevice cu_dev,

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.

Done, with the uct_cuda_ipc_nvml_device_by_uuid() structure you proposed and a loop over the READ/WRITE capabilities. The loop returns UCS_YES on the first supported direction as requested in https://github.com/openucx/ucx/pull/11979/changes#r4131304643.

EXPECT_FALSE(cuda_ipc_md->enable_mnnvl);
}

UCS_TEST_P(test_cuda_ipc_md, nvml_peer_accessibility)

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.

pls also assert the selected protocol, not only md_map. test_cuda_rma() + check_rkey_config() already compare the protocol desc/config per size range, so a rkey config with unreachable_md_map set on the cuda_ipc MD should show RNDV_RECV moving from "cuda_ipc/cuda" to the cuda_copy host-staged pipeline.

It can reuse the existing flow: take the rkey_cfg_index from send_recv_rma(), copy its rkey_config_key, set unreachable_md_map to the cuda_ipc MD bit, call ucp_worker_rkey_config_get() to get a second index, then check_rkey_config() on it with key.param.op_id_flags = UCP_OP_ID_RNDV_RECV. This is the behavior claimed in the PR description, and it needs no extra GPU.

It could look like:

UCS_TEST_P(test_ucp_proto_mock_cuda_ipc, rndv_recv_ipc_unreachable,
           "ZCOPY_THRESH=1")
{
    ucp_worker_h worker = sender().worker();
    ucp_worker_cfg_index_t rkey_cfg_index, unreachable_cfg_index;
    ucp_rkey_config_key_t rkey_config_key;
    ucp_md_index_t dst_md_index;

    /* Real CUDA RMA to obtain a populated rkey config */
    rkey_cfg_index = send_recv_rma(UCS_MBYTE, UCP_OP_ID_PUT,
                                   UCS_MEMORY_TYPE_CUDA);
    ASSERT_NE(UCP_WORKER_CFG_INDEX_NULL, rkey_cfg_index);

    dst_md_index    = cuda_ipc_dst_md_index();
    ASSERT_NE(UCP_NULL_RESOURCE, dst_md_index);

    /* Same config, but with cuda_ipc rejected at unpack */
    rkey_config_key = ucs_array_elem(&worker->rkey_config, rkey_cfg_index).key;
    rkey_config_key.md_map             &= ~UCS_BIT(dst_md_index);
    rkey_config_key.unreachable_md_map  = UCS_BIT(dst_md_index);

    ASSERT_UCS_OK(ucp_worker_rkey_config_get(worker, &rkey_config_key, NULL,
                                             &unreachable_cfg_index));

    ucp_proto_select_key_t key = any_key();
    key.param.op_id_flags      = UCP_OP_ID_RNDV_RECV;
    key.param.op_attr          = 0;
    key.param.mem_type         = UCS_MEMORY_TYPE_CUDA;

    /* cuda_ipc must not be selected; host staging is used instead */
    check_rkey_config(sender(), {
        {1, INF, "pipeline", "cuda_copy"},
    }, key, unreachable_cfg_index);
}

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.

Done, following the proposed approach.

UCS_TEST_SKIP_R("NVML peer accessibility is unavailable");
}
}

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.

maybe also in UCT to test fallback:

/*
 * When NVML cannot resolve the peer, the capability check must not decide
 * reachability: it has to return UCS_TRY so the memhandle probe still runs.
 */
UCS_TEST_P(test_cuda_ipc_md, nvml_peer_unresolved_falls_back)
{
    constexpr size_t size = 4096;
    CUuuid unknown_uuid;
    CUdevice cu_dev;
    CUdeviceptr ptr;

    ASSERT_EQ(CUDA_SUCCESS, cuDeviceGet(&cu_dev, 0));

    /* UUID of no device on this system */
    memset(unknown_uuid.bytes, 0xAB, sizeof(unknown_uuid.bytes));
    EXPECT_EQ(UCS_TRY,
              uct_cuda_ipc_nvml_peer_accessible(cu_dev, &unknown_uuid));

    /* End-to-end: unpack keeps the pre-existing probe verdict */
    ASSERT_EQ(CUDA_SUCCESS, cuMemAlloc(&ptr, size));
    unpack_common(md(), 0xABABABABABABABABLL, ptr, size);
    EXPECT_EQ(CUDA_SUCCESS, cuMemFree(ptr));
}

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 nvml_peer_unresolved, which checks that an unknown UUID returns UCS_TRY. I didn't add the unpack_common() part, because it expects UCS_ERR_UNREACHABLE in the same process both when NVML returns UCS_TRY and when it returns UCS_NO, so it can't tell the two apart. I believe the existing posix_fd_same_node_ipc test already covers the end-to-end case. It unpacks an rkey with a fake UUID and expects UCS_OK, which passes only if NVML returns UCS_TRY and the handle probe runs.

When a remote key MD could not be unpacked, the peer is expected to fail
unpacking the same MD from the local key. Mirror ucp_ep_rkey_unpack_internal()
in the synthetic remote key used for nested protocol estimation by moving such
MDs from md_map to unreachable_md_map instead of dropping them, so the two maps
stay disjoint and the key matches the configuration the peer creates.

This also covers protocols which keep their full packed MD map, such as
rndv/rtr/mtype with CUDA staging buffers, which would otherwise estimate the
peer write through CUDA IPC for GPU pairs without native P2P access.
Keep CUDA IPC reachable when NVML reports native P2P support in either
direction, and reject it only when neither read nor write is supported.

Also address review comments: return ucs_ternary_auto_value_t, resolve NVML
devices through a shared helper, use NVML_DEVICE_UUID_BUFFER_SIZE instead of
NVML_DEVICE_UUID_ASCII_LEN which is missing from older NVML headers, compare
memcmp() explicitly, cache only an explicit NVML rejection, and log the
rejected remote buffer.

Signed-off-by: Peter Andreas Entschev <peter@entschev.com>
Comment thread src/ucp/rndv/proto_rndv.c
*/
rkey_config_key.md_map = ucp_proto_rndv_md_map_to_remote(params,
md_map);
if (params->super.super.rkey_config_key != NULL) {

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.

I tried this, and it brings back the slow path. On g7e GPU4 -> GPU6 (NODE, no native P2P), RNDV_RECV selected rndv/rtr/mtype with a CUDA staging buffer, and the peer wrote to it through cuda_ipc.

rtr/mtype still packs cuda_ipc for its staging buffer, but the peer cannot unpack it for the same GPU pair. So the estimate without cuda_ipc matches what the peer can actually use. With https://github.com/openucx/ucx/pull/11979/changes#r4131274778, the synthetic key now matches the peer's unpack result: the packed MDs are split into md_map and unreachable_md_map, like ucp_ep_rkey_unpack_internal() does. The new rndv_recv_unreachable test covers this case and fails if the mask is skipped for KEEP_MD_MAP.

Comment thread src/ucp/rndv/proto_rndv.c
*/
rkey_config_key.md_map = ucp_proto_rndv_md_map_to_remote(params,
md_map);
if (params->super.super.rkey_config_key != NULL) {

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 test_ucp_proto_mock_cuda_ipc.rndv_recv_unreachable. rndv/rtr already removed unreachable MDs from its packed RTR map in ucp_proto_rndv_ctrl_init_priv(). The gap was the nested remote estimate, mostly for rndv/rtr/mtype, which keeps its packed MD map. So the test checks the RNDV_RECV selection instead of rtr_md_map().

Comment thread src/ucp/rndv/proto_rndv.c Outdated

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.

Done.

Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_md.c Outdated
bytes[15]);
}

int uct_cuda_ipc_nvml_peer_accessible(CUdevice cu_dev,

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.

Done.

Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_md.c Outdated
bytes[15]);
}

int uct_cuda_ipc_nvml_peer_accessible(CUdevice cu_dev,

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.

Done, with the uct_cuda_ipc_nvml_device_by_uuid() structure you proposed and a loop over the READ/WRITE capabilities. The loop returns UCS_YES on the first supported direction as requested in https://github.com/openucx/ucx/pull/11979/changes#r4131304643.

Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_md.c Outdated
rkey->stream_id = cache->dev_num;
accessible = &cache->accessible[cu_dev];
if (ucs_unlikely(*accessible == UCS_TRY)) { /* unchecked, add to cache */
*accessible = uct_cuda_ipc_nvml_peer_accessible(

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.

Done.

Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_md.c Outdated
*accessible = uct_cuda_ipc_nvml_peer_accessible(
cu_dev, &rkey->super.super.uuid);
if (*accessible == UCS_NO) {
ucs_debug("CUDA IPC peer does not support native P2P access");

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.

Done. The log now names the NVML P2P check step and prints the local device, remote buffer address and length.

Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_md.h Outdated


int uct_cuda_ipc_nvml_peer_accessible(CUdevice cu_dev,
const CUuuid *remote_uuid);

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.

Fixed.

EXPECT_FALSE(cuda_ipc_md->enable_mnnvl);
}

UCS_TEST_P(test_cuda_ipc_md, nvml_peer_accessibility)

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.

Done, following the proposed approach.

UCS_TEST_SKIP_R("NVML peer accessibility is unavailable");
}
}

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 nvml_peer_unresolved, which checks that an unknown UUID returns UCS_TRY. I didn't add the unpack_common() part, because it expects UCS_ERR_UNREACHABLE in the same process both when NVML returns UCS_TRY and when it returns UCS_NO, so it can't tell the two apart. I believe the existing posix_fd_same_node_ipc test already covers the end-to-end case. It unpacks an rkey with a fake UUID and expects UCS_OK, which passes only if NVML returns UCS_TRY and the handle probe runs.

@svc-nvidia-pr-review

Copy link
Copy Markdown

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

@tvegas1

tvegas1 commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Tested on Vera Rubin: cuda_ipc is still used at full NVLink bandwidth intra-node and inter-node (MNNVL), including under MPS with MLOPart. New gtests pass.

@tvegas1
tvegas1 merged commit 8f17911 into openucx:master Nov 10, 2026
162 checks passed
pentschev added a commit to pentschev/ucx that referenced this pull request Nov 16, 2026
PR openucx#11979 marks the MDs which could not be unpacked from the peer's rkey as
unreachable also in the nested remote protocol estimation, assuming the
peer would fail the same way when accessing local buffers. This holds when
the devices cannot access each other, but not when only the remote buffer
cannot be mapped, e.g. a memory pool allocation without an exportable
handle type (NO_IPC). The peer can then still access local buffers which
have their own handle, such as the rndv/rtr/mtype fragments, and excluding
cuda_ipc from the estimation makes the receiver fall back to much slower
protocols (e.g. sysv copy-in copy-out on GB200, ~7x slower end to end).

cuda_ipc rkey unpack now returns UCS_ERR_UNSUPPORTED when the failure is
known to be specific to the remote memory handle: the remote buffer has no
IPC handle, or mapping failed although NVML reports P2P access between the
devices. It keeps returning UCS_ERR_UNREACHABLE when NVML reports no P2P
access, and when mapping failed and NVML cannot tell whether P2P access
exists, since missing P2P access may then be the cause. The NVML verdict
takes precedence over the NO_IPC check.

UCP treats both statuses as unreachable for the remote key, so protocol
selection for that key does not change, and records UCS_ERR_UNREACHABLE
MDs also in a new rkey config field, peer_unreachable_md_map, which is the
only one propagated to the remote protocol estimation.
Comment on lines +527 to +541
if (UCT_CUDADRV_FUNC(cuDeviceGetUuid(&local_uuid, cu_dev),
UCS_LOG_LEVEL_DEBUG) != UCS_OK) {
return UCS_TRY;
}

if (memcmp(&local_uuid, remote_uuid, sizeof(local_uuid)) == 0) {
return UCS_YES;
}

if ((uct_cuda_ipc_nvml_device_by_uuid(&local_uuid, &local_device) !=
UCS_OK) ||
(uct_cuda_ipc_nvml_device_by_uuid(remote_uuid, &remote_device) !=
UCS_OK)) {
return UCS_TRY;
}

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.

@tvegas1
I'm not sure I understand this logic.
CUDA driver sees two GPUs with MPS with MLOPart, and NVML sees only one. Does cuDeviceGetUuid return the same UUID for two different CUdevices in this 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.

No. Each MLOPart device has its own UUID, different from the UUID of the underlying GPU, and NVML is not aware of these UUIDs (MPS docs, "Limitations of Locality Domains": https://docs.nvidia.com/deploy/mps/when-to-use-mps.html). I also checked it on GB200 with start_server -uid <uid> -mlopart: the driver then exposes 8 CUDA devices, two per GPU with the same PCI address (e.g. devices 0 and 1 are both 0008:01:00.0), cuDeviceGetUuid() returns a different UUID for each of them, and nvmlDeviceGetHandleByUUID() returns NVML_ERROR_NOT_FOUND for all 8. So uct_cuda_ipc_nvml_peer_accessible() returns UCS_TRY, and the handle-mapping probe decides, the same as before this PR.

If two CUdevices did return the same UUID, the memcmp() shortcut would return UCS_YES. That still doesn't skip the probe, because uct_cuda_ipc_is_peer_accessible() only short-circuits on UCS_NO. So with MLOPart this check can't reject a peer, whatever the UUIDs look like: UCS_NO is only possible when NVML resolves both UUIDs to two different physical GPUs and reports that neither P2P read nor write is supported.

With MLOPart, cudaIpcOpenMemHandle() works both between the two partitions of a GPU and across GPUs (~750 GB/s device copy), and ucx_perftest -t tag_bw -m cuda uses rendezvous zero-copy read from remote | cuda_ipc/cuda: 848 GB/s between the two partitions of one GPU, 737 GB/s between partitions of different GPUs. This is consistent with what @tvegas1 saw on Vera Rubin.

rkey->stream_id = cache->dev_num;
accessible = &cache->accessible[cu_dev];
if (ucs_unlikely(*accessible == UCS_TRY)) { /* unchecked, add to cache */
peer_accessible = uct_cuda_ipc_nvml_peer_accessible(

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.

What prevents us from completely removing the opening the IPC handle from accessibility check?
Have you faced any cases where it was not enough?
It looks like for cuIpcOpenMemHandle it's enough to check P2P status. There is still an open question: how does it work with MPS/MLOPart.

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.

The P2P status alone is not enough, for two reasons:

  1. NVML can't always answer. The check returns UCS_TRY when NVML is not available or fails to initialize, or when a UUID is unknown to NVML. The latter includes MLOPart devices (see UCT/CUDA: Reject IPC without P2P read/write support #11979 (comment), where NVML resolves neither the local nor the remote UUID while IPC works at full NVLink bandwidth) and remote GPUs on another node with multi-node NVLink, whose UUID is never known to the local NVML (nvmlDeviceGetHandleByUUID() returns "Not Found" on GB200 NVL72, and importing the fabric handle is the only check we have). Without the probe we would have to either accept or reject every such peer.
  2. P2P support doesn't mean the buffer can be mapped. Importability depends on the handle type, which is why the device cache key includes the handle type (uct_cuda_ipc_uuid_hash_key_t). We hit this in UCT/CUDA_IPC/UCP: Propagate only peer-level cuda_ipc unreachability #12344: memory from a pool without an exportable handle type is packed as NO_IPC, and mapping it fails even though NVML reports P2P access. Legacy IPC handles from another node, fabric imports without IMEX channel access and POSIX FD imports from another machine/PID namespace or without pidfd_getfd() permission can fail the same way. If the rkey unpacked successfully in these cases, the error would only show up later, when uct_cuda_ipc_map_remote_addr() fails in put/get, where UCP can no longer switch protocols, so the request would fail. Failing at unpack time lets UCP select a different protocol instead.

The opposite also holds, which is why this PR added the NVML check on top of the probe: on the g7e system in the description cuIpcOpenMemHandle() succeeds between GPUs without native P2P (0.88 GB/s), so the probe alone accepts a pair that should be rejected. On g7e we never saw NVML report P2P support for a pair where cuIpcOpenMemHandle() then failed with cudaMalloc buffers, so for legacy handles NVML is enough on topologies it knows about, but not for the other handle types or the cases above. On other systems the probe also catches missing P2P; e.g. on a DGX-1 V100, for a GPU pair which NVML reports as NVML_P2P_STATUS_IOH_TOPOLOGY_NOT_SUPPORTED, cudaIpcOpenMemHandle() fails with "peer access is not supported between these two devices".

The probe is also cheap: it runs once per local device, remote device and handle type, and when it succeeds the mapping goes into the IPC cache and the first put/get reuses it.

For MPS/MLOPart, as in the other thread: NVML returns UCS_TRY for the partition UUIDs and the probe succeeds, so cuda_ipc is used within a GPU and across GPUs at full bandwidth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Optimization Code / performance optimization Ready for Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants