Repository navigation
Conversation
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.
|
🤖 CI Triage Agent — TL;DR: The gtest binary aborted on a UCX debug assertion in the registration cache ( Full analysisSummary: Root cause: Backtrace from the log: Implicated commit: Not caused by File: Suggested fix:
Related: #11958 ( |
tvegas1
left a comment
There was a problem hiding this comment.
the description says inter-node falls back to tcp, but NO_IPC buffers do not get UCS_MEM_FLAG_MEMTYPE_COPY_INTER_NODE, so cuda_ipc should already be left out of their rndv rkey inter-node. what makes cuda_ipc unreachable there?
| goto out; | ||
| } | ||
|
|
||
| /* The remote buffer could not be exported (e.g. a memory pool without |
There was a problem hiding this comment.
maybe instead of packing a NO_IPC key and classifying the unpack failure on the receiver, cuda_ipc could skip such buffers at registration, like gdr_copy does with UCS_MEM_FLAG_GDR_CAPABLE:
- add
UCS_MEM_FLAG_IPC_CAPABLE, set by cuda_copy memory detection when the buffer has a handle thatuct_cuda_ipc_mem_add_reg()can export (legacy, fabric, or POSIX FD on VMM).uct_cuda_copy_md_detect_memtype_copy_flags()already queries most of these attributes, so a shared helper could keep both in sync - set
md_attr->required_mem_flags = UCS_MEM_FLAG_IPC_CAPABLEinuct_cuda_ipc_md_query()
UCP already skips registration for MDs whose required memory flags are missing, and ucp_proto_rndv_ctrl_get_md_map() leaves them out of the rndv rkey. so the receiver never fails to unpack cuda_ipc for these buffers, unreachable_md_map does not get cuda_ipc for them, and the rtr/mtype fragments keep cuda_ipc, without the new map or the new cache states. this is similar to how UCS_MEM_FLAG_MEMTYPE_COPY_INTER_NODE already keeps buffers without a fabric handle out of inter-node rndv rkeys.
it does not cover failed imports of exportable handles. if we need that too, a UCP_RKEY_CONFIG_FLAG_* bit could replace peer_unreachable_md_map, since only cuda_ipc returns UCS_ERR_UNREACHABLE from rkey unpack.
There was a problem hiding this comment.
Thanks, I tried this with a prototype: UCS_MEM_FLAG_IPC_CAPABLE set next to UCS_MEM_FLAG_MEMTYPE_COPY_INTER_NODE for buffers with a legacy, fabric or POSIX FD handle, and used as required_mem_flags of cuda_ipc. It fixes the GB200 case, but it loses the #11979 fix for exactly these buffers on GPUs without P2P access. The NVML check needs the peer's device UUID, which the receiver only gets by unpacking the peer's cuda_ipc rkey. If NO_IPC buffers carry no cuda_ipc rkey, the receiver never finds out that the peer has no P2P access to it, so it again selects a cuda_ipc put into its rtr/mtype fragment, which the peer then cannot do.
ucx_perftest tag_bw, 64 MB, DGX-1 V100 (GPU0<->GPU1 have P2P over NVLink, GPU0<->GPU5 have no P2P per NVML). cuda is cudaMalloc, cuda-async is the default memory pool, i.e. NO_IPC like the RMM pool buffers on GB200 (with UCX_CUDA_COPY_ASYNC_MEM_TYPE=cuda):
| cuda, P2P | cuda, no P2P | cuda-async, P2P | cuda-async, no P2P | |
|---|---|---|---|---|
| master | 23.1 GB/s | 4.2 GB/s | 4.6 GB/s | 4.9 GB/s |
IPC_CAPABLE prototype |
23.1 GB/s | 4.5 GB/s | 22.9 GB/s | 0.68 GB/s |
| this PR | 23.1 GB/s | 4.7 GB/s | 22.9 GB/s | 4.6 GB/s |
With the prototype on the no-P2P pair the receiver selects zero-copy flushed write to remote, cuda_copy, frag cuda | cuda_ipc/cuda, and the sender then falls back to fragmented copy-in copy-out | sysv/memory. (The cuda-async P2P column on master is also a single-node reproducer of the GB200 regression.)
So I kept packing NO_IPC keys, but took your other suggestion: peer_unreachable_md_map is now replaced by a UCP_RKEY_CONFIG_FLAG_PEER_UNREACHABLE rkey config flag, so the rkey config key layout, hash, compare and dump are unchanged. I also narrowed the buffer-only case to "mapping failed, NVML reports P2P access and the remote buffer is NO_IPC". Every other failure, including failed imports of exportable handles and the case where NVML cannot tell, keeps returning UCS_ERR_UNREACHABLE as with #11979.
|
🤖 Starting review — findings will be posted here when done. |
| /* The remote buffer could not be exported (e.g. a memory pool without | ||
| * an exportable handle type), so it cannot be mapped regardless of the | ||
| * devices */ | ||
| if (rkey->super.super.ph.handle_type == |
There was a problem hiding this comment.
this returns before uct_cuda_ipc_map_memhandle(), which succeeds for a key of this process on the same device (mapped_addr == d_bptr) even for a NO_IPC handle, so such keys now fail with UCS_ERR_UNSUPPORTED instead of UCS_OK (local keys are also unpacked by ucp_mem_type_reg_buffers(), which is fatal on failure). can we classify NO_IPC only after the mapping attempt fails?
There was a problem hiding this comment.
Fixed: NO_IPC is now only considered after uct_cuda_ipc_map_memhandle() fails, so a key of this process on the same device is mapped directly again. test_cuda_ipc_md.unpack_no_ipc_handle now checks that case too.
| ++rkey_index; | ||
| } else if (status == UCS_ERR_UNREACHABLE) { | ||
| } else if ((status == UCS_ERR_UNREACHABLE) || | ||
| (status == UCS_ERR_UNSUPPORTED)) { |
There was a problem hiding this comment.
pls document this status contract in uct_rkey_unpack_v2() (UCS_ERR_UNREACHABLE for the device, UCS_ERR_UNSUPPORTED for this buffer only), so all components follow the same meaning.
| if (status == UCS_ERR_UNREACHABLE) { | ||
| peer_unreachable_md_map |= UCS_BIT(remote_md_index); | ||
| } | ||
| ucs_trace("rkey[%d] for remote md %d is 0x%lx not reachable: %s", |
There was a problem hiding this comment.
minor: tl_rkey->rkey.rkey is not set when the unpack fails, pls drop it from the message.
| ucs_trace("rkey[%d] for remote md %d is 0x%lx not reachable: %s", | |
| ucs_trace("rkey[%d] for remote md %d is not reachable: %s", | |
| rkey_index, remote_md_index, ucs_status_string(status)); |
| rkey_config_key.mem_type = params->super.reg_mem_info.type; | ||
| rkey_config_key.flags = 0; | ||
| rkey_config_key.unreachable_md_map = unreachable_md_map; | ||
| rkey_config_key.unreachable_md_map = unreachable_md_map; |
There was a problem hiding this comment.
minor: pls align the whole assignment block (md_map..flags) on the new column, same in test_ucp_proto.cc; docs/CodeStyle.md requires consecutive assignments aligned on the column.
There was a problem hiding this comment.
Done. test_ucp_proto.cc is no longer changed by this PR, since the new rkey config field was replaced by a flag.
| EXPECT_EQ(UCT_CUDA_IPC_KEY_HANDLE_TYPE_NO_IPC, rkey.super.ph.handle_type); | ||
|
|
||
| /* Bypass the same-process shortcut; NVML cannot resolve this UUID */ | ||
| auto uuid64 = reinterpret_cast<int64_t*>(rkey.super.uuid.bytes); |
There was a problem hiding this comment.
minor: pls reuse tamper_rkey_uuid() here, it can be moved out of the #if HAVE_DECL_SYS_PIDFD_GETFD block.
|
Notes on residual coverage: The new UCT test only runs with Notes on residual coverage: No test covers the same-process/same-device Notes on residual coverage: |
Replace peer_unreachable_md_map in ucp_rkey_config_key_t by the rkey config flag UCP_RKEY_CONFIG_FLAG_PEER_UNREACHABLE, set when an rkey unpack returned UCS_ERR_UNREACHABLE. Only cuda_ipc returns UCS_ERR_UNREACHABLE from rkey unpack, so a per-MD map is not needed, and the rkey config key layout, hash, compare and dump stay unchanged. Also drop the unset rkey value from the trace message and align the remote rkey config key assignments.
…2P peers Classify an rkey unpack failure as specific to the remote buffer only if mapping the handle failed, NVML reports P2P access to the remote device and the remote buffer has no IPC handle (NO_IPC). Checking NO_IPC only after the mapping attempt keeps keys of this process on the same device working, since those are mapped directly. All other failures, including when NVML cannot tell whether P2P access exists, keep returning UCS_ERR_UNREACHABLE as before. Document the meaning of UCS_ERR_UNREACHABLE and UCS_ERR_UNSUPPORTED in uct_rkey_unpack_v2(), restore the master expectations of test_cuda_ipc_md, reuse tamper_rkey_uuid() and extend unpack_no_ipc_handle to cover the same-process, unresolvable-UUID and P2P-peer cases.
|
🤖 Starting review — findings will be posted here when done. |
pentschev
left a comment
There was a problem hiding this comment.
the description says inter-node falls back to tcp, but
NO_IPCbuffers do not getUCS_MEM_FLAG_MEMTYPE_COPY_INTER_NODE, so cuda_ipc should already be left out of their rndv rkey inter-node. what makes cuda_ipc unreachable there?
Thanks @tvegas1 , and you're right, nothing makes it unreachable there, the description was wrong on that point and has now been updated. I re-ran the 2-node case on master with UCX_PROTO_INFO=y and the inter-node protocol tables are identical to the ones with this PR: NO_IPC buffers carry no cuda_ipc rkey for inter-node peers, and the receiver uses rtr/mtype with cuda_ipc into its fragment in both cases. The 2-node slowdown (13.5 s -> 88 s) comes only from the intra-node peers (3 of the 7 peers of each rank, 4 GPUs per node), which switch to fragmented copy-in copy-out | sysv/memory.
| goto out; | ||
| } | ||
|
|
||
| /* The remote buffer could not be exported (e.g. a memory pool without |
There was a problem hiding this comment.
Thanks, I tried this with a prototype: UCS_MEM_FLAG_IPC_CAPABLE set next to UCS_MEM_FLAG_MEMTYPE_COPY_INTER_NODE for buffers with a legacy, fabric or POSIX FD handle, and used as required_mem_flags of cuda_ipc. It fixes the GB200 case, but it loses the #11979 fix for exactly these buffers on GPUs without P2P access. The NVML check needs the peer's device UUID, which the receiver only gets by unpacking the peer's cuda_ipc rkey. If NO_IPC buffers carry no cuda_ipc rkey, the receiver never finds out that the peer has no P2P access to it, so it again selects a cuda_ipc put into its rtr/mtype fragment, which the peer then cannot do.
ucx_perftest tag_bw, 64 MB, DGX-1 V100 (GPU0<->GPU1 have P2P over NVLink, GPU0<->GPU5 have no P2P per NVML). cuda is cudaMalloc, cuda-async is the default memory pool, i.e. NO_IPC like the RMM pool buffers on GB200 (with UCX_CUDA_COPY_ASYNC_MEM_TYPE=cuda):
| cuda, P2P | cuda, no P2P | cuda-async, P2P | cuda-async, no P2P | |
|---|---|---|---|---|
| master | 23.1 GB/s | 4.2 GB/s | 4.6 GB/s | 4.9 GB/s |
IPC_CAPABLE prototype |
23.1 GB/s | 4.5 GB/s | 22.9 GB/s | 0.68 GB/s |
| this PR | 23.1 GB/s | 4.7 GB/s | 22.9 GB/s | 4.6 GB/s |
With the prototype on the no-P2P pair the receiver selects zero-copy flushed write to remote, cuda_copy, frag cuda | cuda_ipc/cuda, and the sender then falls back to fragmented copy-in copy-out | sysv/memory. (The cuda-async P2P column on master is also a single-node reproducer of the GB200 regression.)
So I kept packing NO_IPC keys, but took your other suggestion: peer_unreachable_md_map is now replaced by a UCP_RKEY_CONFIG_FLAG_PEER_UNREACHABLE rkey config flag, so the rkey config key layout, hash, compare and dump are unchanged. I also narrowed the buffer-only case to "mapping failed, NVML reports P2P access and the remote buffer is NO_IPC". Every other failure, including failed imports of exportable handles and the case where NVML cannot tell, keeps returning UCS_ERR_UNREACHABLE as with #11979.
| /* The remote buffer could not be exported (e.g. a memory pool without | ||
| * an exportable handle type), so it cannot be mapped regardless of the | ||
| * devices */ | ||
| if (rkey->super.super.ph.handle_type == |
There was a problem hiding this comment.
Fixed: NO_IPC is now only considered after uct_cuda_ipc_map_memhandle() fails, so a key of this process on the same device is mapped directly again. test_cuda_ipc_md.unpack_no_ipc_handle now checks that case too.
| ++rkey_index; | ||
| } else if (status == UCS_ERR_UNREACHABLE) { | ||
| } else if ((status == UCS_ERR_UNREACHABLE) || | ||
| (status == UCS_ERR_UNSUPPORTED)) { |
| if (status == UCS_ERR_UNREACHABLE) { | ||
| peer_unreachable_md_map |= UCS_BIT(remote_md_index); | ||
| } | ||
| ucs_trace("rkey[%d] for remote md %d is 0x%lx not reachable: %s", |
| rkey_config_key.mem_type = params->super.reg_mem_info.type; | ||
| rkey_config_key.flags = 0; | ||
| rkey_config_key.unreachable_md_map = unreachable_md_map; | ||
| rkey_config_key.unreachable_md_map = unreachable_md_map; |
There was a problem hiding this comment.
Done. test_ucp_proto.cc is no longer changed by this PR, since the new rkey config field was replaced by a flag.
| peer_key = params->super.super.rkey_config_key; | ||
| if ((peer_key != NULL) && | ||
| (peer_key->flags & UCP_RKEY_CONFIG_FLAG_PEER_UNREACHABLE)) { | ||
| unreachable_md_map = remote_md_map & peer_key->unreachable_md_map; |
There was a problem hiding this comment.
The relaxed UCS_ERR_UNSUPPORTED handling is only applied to the nested estimation, not to the MD map that is actually packed. ucp_proto_rndv_ctrl_init_priv() still masks rpriv->md_map with unreachable_md_map unconditionally for protos without UCP_PROTO_COMMON_KEEP_MD_MAP, so in the UNSUPPORTED case we also don't register/pack those MDs in our own key (e.g. rndv/rtr with a user buffer), and then unreachable_md_map here is already 0 and the flag is never set. Impact: the peer still cannot use cuda_ipc for our buffer even though the comment says it may be accessible. Can we condition that masking on UCP_RKEY_CONFIG_FLAG_PEER_UNREACHABLE as well?
There was a problem hiding this comment.
I tried this, and it brings back the slowdown when both sides use buffers without an IPC handle, which is the common case since both usually come from the same allocator. rndv/rtr then advertises cuda_ipc for the receiver's own NO_IPC buffer, its estimate includes a cuda_ipc put into it, so it wins over rndv/rtr/mtype, and the sender then cannot unpack that rkey and falls back to fragmented copy-in copy-out | sysv/memory. ucx_perftest tag_bw 64 MB, DGX-1 V100 GPU pair with P2P, cuda-async = default pool (NO_IPC), cuda = cudaMalloc:
| sender / receiver buffer | master | this PR | this PR + masking only with the flag |
|---|---|---|---|
| cuda-async / cuda-async | 4.6 GB/s | 22.9 GB/s | 0.68 GB/s |
| cuda-async / cuda | 4.7 GB/s | 22.9 GB/s | 23.1 GB/s |
| cuda / cuda-async | 23.1 GB/s | 23.1 GB/s | 23.1 GB/s |
The case it would help (sender without an IPC handle, receiver with one) only gains ~1%, since rndv/rtr/mtype also writes over NVLink and only adds a local copy. So I kept the masking as it was before #11979: the receiver doesn't advertise an MD for its own user buffer if the sender's rkey for that MD couldn't be unpacked, and only the rndv fragments, which UCX allocates itself, keep it. I also clarified the comment in ucp_proto_rndv_ctrl_select_remote_proto(), which could be read as saying the user buffer stays accessible: it now says that only local buffers which keep their full MD map (UCP_PROTO_COMMON_KEEP_MD_MAP, i.e. the rndv fragments) may still be accessible by the peer.
| ASSERT_UCS_OK(md()->ops->mem_reg(md(), (void*)ptr, size, NULL, &memh)); | ||
| ASSERT_UCS_OK(md()->ops->mkey_pack(md(), memh, (void*)ptr, size, NULL, | ||
| &rkey)); | ||
| EXPECT_EQ(UCT_CUDA_IPC_KEY_HANDLE_TYPE_NO_IPC, rkey.super.ph.handle_type); |
There was a problem hiding this comment.
EXPECT_EQ on the handle type lets the test continue with wrong assumptions. The rest of the test (especially the UCS_ERR_UNSUPPORTED expectation) is valid only for a NO_IPC key; with EXPECT_EQ a non-NO_IPC allocation fails later with a confusing UNREACHABLE != UNSUPPORTED error. posix_fd_same_node_ipc in the same file uses ASSERT_EQ for the same check. Suggestion:
| EXPECT_EQ(UCT_CUDA_IPC_KEY_HANDLE_TYPE_NO_IPC, rkey.super.ph.handle_type); | |
| ASSERT_EQ(UCT_CUDA_IPC_KEY_HANDLE_TYPE_NO_IPC, rkey.super.ph.handle_type); |
| /* Some MDs in unreachable_md_map failed to unpack because the remote | ||
| * device is not reachable at all (rather than only the remote buffer), so | ||
| * the peer is not expected to access local buffers through them either */ | ||
| UCP_RKEY_CONFIG_FLAG_PEER_UNREACHABLE = UCS_BIT(2) |
There was a problem hiding this comment.
minor: ucp_worker_dump_rkey_config_key() does not print key->flags. With the new bit, two rkey configs can now differ only by UCP_RKEY_CONFIG_FLAG_PEER_UNREACHABLE, and the dump prints only md_map/cfg_index/sys_dev/mem_type/unrch_md_map, so the debug log would show the two configs as identical. Please also print key->flags.
|
Residual coverage notes: Finding 1 is not covered by any test — |
| *accessible = UCT_CUDA_IPC_ACCESS_OK; | ||
| } else if ((peer_accessible == UCS_YES) && | ||
| (rkey->super.super.ph.handle_type == | ||
| UCT_CUDA_IPC_KEY_HANDLE_TYPE_NO_IPC)) { |
There was a problem hiding this comment.
It might be worth considering (if it hasn't been considered yet) a different approach. Change how we pack the key. Maybe we can get rid of this handle type at all, return specific failure status, allow rkey pack in UCP when some components return the specific failure status.
There was a problem hiding this comment.
Thanks, I considered it. Not packing a cuda_ipc rkey for these buffers gives the peer the same rkey as the UCS_MEM_FLAG_IPC_CAPABLE prototype from @tvegas1's suggestion (#12344 (comment)), and that has the problem described there. The NO_IPC key is what carries the sender's device UUID, and the receiver needs that UUID for the NVML P2P check. Without it, on a GPU pair without P2P the receiver no longer learns that the sender cannot access its device, so it again estimates a cuda_ipc put into its rtr/mtype fragment that the sender cannot do. With the prototype, NO_IPC (cuda-async) buffers on such a pair dropped from 4.9 GB/s to 0.68 GB/s, i.e. the #11979 regression for exactly these buffers.
Failing at pack time would also be decided later than the protocol selection. The receiver selects rndv/rtr before it packs the RTR rkey, so its estimate would still include cuda_ipc for its own user buffer while the packed key would not, and rpriv->packed_rkey_size is computed from the MD map at protocol init. The memory-flag variant at least avoids this part, because the flags are known when the protocols are selected.
So I'd rather keep the NO_IPC key as "device UUID without a handle".
|
|
||
| ASSERT_EQ(CUDA_SUCCESS, cuCtxGetDevice(&local_device)); | ||
| ASSERT_EQ(CUDA_SUCCESS, cuStreamCreate(&cu_stream, CU_STREAM_NON_BLOCKING)); | ||
| ASSERT_EQ(CUDA_SUCCESS, cuMemAllocAsync(&ptr, size, cu_stream)); |
There was a problem hiding this comment.
pls use mem_buffer buf(size, UCS_MEMORY_TYPE_CUDA, mem_buffer::alloc_mode::ASYNC) here; it allocates from the default pool the same way and frees the buffer even if an ASSERT_* below returns early, so the stream code can go away.
| EXPECT_EQ(UCS_ERR_UNREACHABLE, | ||
| uct_rkey_unpack_v2(md()->component, &rkey, &unpack_params, NULL)); | ||
|
|
||
| /* Pretend the memory is on a peer device with P2P access */ |
There was a problem hiding this comment.
maybe change the pid instead of the UUID, e.g. rkey.super.pid ^= 1: it skips the same-process shortcut, and NVML returns UCS_YES for the same UUID, so the UCS_ERR_UNSUPPORTED case runs on a single GPU and this loop and the skip are not needed.
There was a problem hiding this comment.
Good idea, done. The test now runs the UCS_ERR_UNSUPPORTED case on a single GPU, and the loop and the skip are gone. It still tampers the UUID afterwards to check the UCS_ERR_UNREACHABLE case when NVML can't resolve the device.
| break; | ||
| } | ||
|
|
||
| rkey.super.uuid = local_uuid; |
There was a problem hiding this comment.
minor: rkey is not used after the loop, so this assignment and local_uuid can be removed.
There was a problem hiding this comment.
Removed together with the loop.
| uct_md_mem_dereg_params_t dereg_params; | ||
| dereg_params.field_mask = UCT_MD_MEM_DEREG_FIELD_MEMH; | ||
| dereg_params.memh = memh; | ||
| EXPECT_UCS_OK(uct_md_mem_dereg_v2(md(), &dereg_params)); |
There was a problem hiding this comment.
minor: pls reuse mem_dereg(), it can be moved out of the #if HAVE_CUDA_FABRIC block like tamper_rkey_uuid().
There was a problem hiding this comment.
Done, moved mem_dereg() out of the HAVE_CUDA_FABRIC block.
| /* The devices have P2P access, but the remote buffer has no IPC | ||
| * handle (e.g. a memory pool without an exportable handle type), | ||
| * so other buffers of the peer may still be accessible */ | ||
| *accessible = UCT_CUDA_IPC_ACCESS_NO_HANDLE; |
There was a problem hiding this comment.
minor: pls add a ucs_debug() here like the nvml p2p check above; this verdict is cached for all buffers of the peer device with this handle type, and today the only debug line is unsupported key handle type: 0 from the open.
| *accessible = UCT_CUDA_IPC_ACCESS_NO_HANDLE; | |
| *accessible = UCT_CUDA_IPC_ACCESS_NO_HANDLE; | |
| ucs_debug("device %d has p2p access, but remote memory addr %p " | |
| "len %zu has no ipc handle", | |
| cu_dev, (void*)rkey->super.super.d_bptr, | |
| rkey->super.super.b_len); |
There was a problem hiding this comment.
Done, with the suggested message.
- Log when a remote buffer of a P2P accessible device has no IPC handle, since this verdict is cached for all buffers of the peer device with this handle type. - Print the rkey config flags in ucp_worker_dump_rkey_config_key(), since configs may now differ only by UCP_RKEY_CONFIG_FLAG_PEER_UNREACHABLE. - Clarify in ucp_proto_rndv_ctrl_select_remote_proto() that only local buffers which keep their full MD map (the rndv fragments) may still be accessible by the peer when only the peer's buffer was not accessible. - test_cuda_ipc_md.unpack_no_ipc_handle: allocate with mem_buffer, assert the NO_IPC handle type, and change the PID instead of the UUID to test UCS_ERR_UNSUPPORTED on a single GPU; reuse mem_dereg().
pentschev
left a comment
There was a problem hiding this comment.
Residual coverage notes: Finding 1 is not covered by any test —
test_ucp_proto_mock_cuda_ipcbuilds the rkey config key by hand, so therpriv->md_mapmasking inucp_proto_rndv_ctrl_init_priv()is never exercised for theUCS_ERR_UNSUPPORTEDcase. Also, the newUCT_CUDA_IPC_ACCESS_NO_HANDLEstate is only reached forhandle_type == NO_IPC; failures of other handle types with NVMLUCS_YES(e.g. fabric/VMM import errors) still map toUNREACHABLEand are untested.
The rpriv->md_map masking for the UCS_ERR_UNSUPPORTED case is unchanged from before #11979 and covered end to end by the perftest numbers in #12344 (comment). Failures of other handle types with NVML UCS_YES are intentionally still UCS_ERR_UNREACHABLE, the same as with #11979.
| peer_key = params->super.super.rkey_config_key; | ||
| if ((peer_key != NULL) && | ||
| (peer_key->flags & UCP_RKEY_CONFIG_FLAG_PEER_UNREACHABLE)) { | ||
| unreachable_md_map = remote_md_map & peer_key->unreachable_md_map; |
There was a problem hiding this comment.
I tried this, and it brings back the slowdown when both sides use buffers without an IPC handle, which is the common case since both usually come from the same allocator. rndv/rtr then advertises cuda_ipc for the receiver's own NO_IPC buffer, its estimate includes a cuda_ipc put into it, so it wins over rndv/rtr/mtype, and the sender then cannot unpack that rkey and falls back to fragmented copy-in copy-out | sysv/memory. ucx_perftest tag_bw 64 MB, DGX-1 V100 GPU pair with P2P, cuda-async = default pool (NO_IPC), cuda = cudaMalloc:
| sender / receiver buffer | master | this PR | this PR + masking only with the flag |
|---|---|---|---|
| cuda-async / cuda-async | 4.6 GB/s | 22.9 GB/s | 0.68 GB/s |
| cuda-async / cuda | 4.7 GB/s | 22.9 GB/s | 23.1 GB/s |
| cuda / cuda-async | 23.1 GB/s | 23.1 GB/s | 23.1 GB/s |
The case it would help (sender without an IPC handle, receiver with one) only gains ~1%, since rndv/rtr/mtype also writes over NVLink and only adds a local copy. So I kept the masking as it was before #11979: the receiver doesn't advertise an MD for its own user buffer if the sender's rkey for that MD couldn't be unpacked, and only the rndv fragments, which UCX allocates itself, keep it. I also clarified the comment in ucp_proto_rndv_ctrl_select_remote_proto(), which could be read as saying the user buffer stays accessible: it now says that only local buffers which keep their full MD map (UCP_PROTO_COMMON_KEEP_MD_MAP, i.e. the rndv fragments) may still be accessible by the peer.
| ASSERT_UCS_OK(md()->ops->mem_reg(md(), (void*)ptr, size, NULL, &memh)); | ||
| ASSERT_UCS_OK(md()->ops->mkey_pack(md(), memh, (void*)ptr, size, NULL, | ||
| &rkey)); | ||
| EXPECT_EQ(UCT_CUDA_IPC_KEY_HANDLE_TYPE_NO_IPC, rkey.super.ph.handle_type); |
| /* Some MDs in unreachable_md_map failed to unpack because the remote | ||
| * device is not reachable at all (rather than only the remote buffer), so | ||
| * the peer is not expected to access local buffers through them either */ | ||
| UCP_RKEY_CONFIG_FLAG_PEER_UNREACHABLE = UCS_BIT(2) |
| EXPECT_EQ(UCS_ERR_UNREACHABLE, | ||
| uct_rkey_unpack_v2(md()->component, &rkey, &unpack_params, NULL)); | ||
|
|
||
| /* Pretend the memory is on a peer device with P2P access */ |
There was a problem hiding this comment.
Good idea, done. The test now runs the UCS_ERR_UNSUPPORTED case on a single GPU, and the loop and the skip are gone. It still tampers the UUID afterwards to check the UCS_ERR_UNREACHABLE case when NVML can't resolve the device.
| break; | ||
| } | ||
|
|
||
| rkey.super.uuid = local_uuid; |
There was a problem hiding this comment.
Removed together with the loop.
| uct_md_mem_dereg_params_t dereg_params; | ||
| dereg_params.field_mask = UCT_MD_MEM_DEREG_FIELD_MEMH; | ||
| dereg_params.memh = memh; | ||
| EXPECT_UCS_OK(uct_md_mem_dereg_v2(md(), &dereg_params)); |
There was a problem hiding this comment.
Done, moved mem_dereg() out of the HAVE_CUDA_FABRIC block.
| /* The devices have P2P access, but the remote buffer has no IPC | ||
| * handle (e.g. a memory pool without an exportable handle type), | ||
| * so other buffers of the peer may still be accessible */ | ||
| *accessible = UCT_CUDA_IPC_ACCESS_NO_HANDLE; |
There was a problem hiding this comment.
Done, with the suggested message.
|
|
||
| ASSERT_EQ(CUDA_SUCCESS, cuCtxGetDevice(&local_device)); | ||
| ASSERT_EQ(CUDA_SUCCESS, cuStreamCreate(&cu_stream, CU_STREAM_NON_BLOCKING)); | ||
| ASSERT_EQ(CUDA_SUCCESS, cuMemAllocAsync(&ptr, size, cu_stream)); |
CLA check failed
See items 1 and 2 of CONTRIBUTING.md for how |
|
🤖 Starting review — findings will be posted here when done. |
|
🤖 CI Triage Agent — TL;DR: This isn't a code or test failure — the Full analysisSummary: The Root cause: The workflow checked out master's All four commits on branch Implicated commit: No faulty commit — the 4 PR commits ( File: Suggested fix: Contributor-side action, not a CI change:
Also worth noting for maintainers: because the list lives in masked repo secrets, contributors can't self-diagnose which address is missing beyond the email echoed in the log — consider having the script print the matching rule/hint (never the list contents) to reduce round-trips. The masked Related: PR #12344 (the failing PR). Issue/PR search for this signature returned only unrelated open PRs (#12439, #12422, #12410, #12438, #12394) — no existing report of a
|
|
🤖 Review complete — no issues found. |
What
Since #11979, cudf-polars PDS-H on GB200 NVL72 is 7-9x slower (SF10K Q9: 1 node 22 s -> 184-203 s, 2 nodes 13.5 s -> 88 s).
The cause is the UCP part of #11979 in
ucp_proto_rndv_ctrl_select_remote_proto(): MDs which the receiver failed to unpack from the sender's rkey are also marked unreachable in the estimation of the protocol the peer runs on the local buffer. This holds when the two devices cannot access each other, but not when only the sender's buffer cannot be mapped. In this workload the user buffers come from an RMM async memory pool without an exportable handle type, so cuda_ipc packs them as NO_IPC, while the receiver's rndv fragments (allocated by UCX with an exportable handle) are accessible by the sender.Between GPUs of the same node, the receiver's
rendezvous data fetch into cuda/GPU0 from cuda/dev[0]changes fromzero-copy flushed write to remote, cuda_copy, frag cuda | cuda_ipc/cuda(rtr/mtype) tofragmented copy-in copy-out | sysv/memory. Inter-node is not affected, since NO_IPC buffers are not packed with cuda_ipc for inter-node peers (#11754); the 2-node slowdown comes from the intra-node peers.Single-node reproducer:
UCX_CUDA_COPY_ASYNC_MEM_TYPE=cuda ucx_perftest -t tag_bw -m cuda-async:1,cuda-async:0 -s 67108864between two GPUs with P2P access: 22.9 GB/s with this PR, 4.6 GB/s on master (DGX-1 V100).How
UCS_ERR_UNSUPPORTEDif mapping failed, NVML reports P2P access to the remote device and the remote buffer has no IPC handle (NO_IPC). All other failures keep returningUCS_ERR_UNREACHABLE, including when NVML cannot tell whether P2P access exists. The per-device accessibility cache gets an explicit state enum to remember which of the two it was.UCP_RKEY_CONFIG_FLAG_PEER_UNREACHABLEonly forUCS_ERR_UNREACHABLE.ucp_proto_rndv_ctrl_select_remote_proto()propagates unreachable MDs to the remote protocol estimation only if this flag is set.test_ucp_proto_mock_cuda_ipc.rndv_recv_unreachablesets the flag; newrndv_recv_unsupported_handlechecks that cuda_ipc is still used for rtr/mtype without it; newtest_cuda_ipc_md.unpack_no_ipc_handle.Testing
Alternatives considered
UCP_PROTO_COMMON_KEEP_MD_MAPprotocols (rndv/rtr/mtype): on the no-P2P pair with cudaMalloc buffers the bandwidth drops to 0.08 GB/s, because the receiver again selects a cuda_ipc put into its fragment that the sender cannot do.UCS_MEM_FLAG_IPC_CAPABLEfor cuda_ipc, so NO_IPC buffers carry no cuda_ipc rkey: on the no-P2P pair with NO_IPC buffers the bandwidth drops to 0.68 GB/s, because the receiver never gets the peer's device UUID for the NVML check.