Skip to content

UCT/CUDA_IPC: Implement uct_ep_put_sgl_zcopy - #11359

Merged
michal-shalev merged 8 commits into
openucx:masterfrom
michal-shalev:uct-cuda-ipc-sgl
Jul 10, 2026
Merged

michal-shalev merged 8 commits into
openucx:masterfrom
michal-shalev:uct-cuda-ipc-sgl

Conversation

@michal-shalev

@michal-shalev michal-shalev commented Apr 19, 2026 •

Copy link
Copy Markdown
Contributor

What?

Implement uct_ep_put_sgl_zcopy for the cuda_ipc transport.

Why?

Allow UCP SGL put offload to run over cuda_ipc, replacing N separate per-buffer copies with a single batched submission and reducing per-element overhead on multi-buffer transfers.

How?

On CUDA 13+, issue one cuMemcpyBatchAsync for the whole SGL, with all mappings tracked in a per-event uct_cuda_ipc_sgl_mapping_t and unmapped on completion. On older CUDA, fall back to per-element uct_cuda_ipc_ep_put_zcopy, arming the user completion only on the last element.

@michal-shalev michal-shalev self-assigned this Apr 19, 2026
@michal-shalev michal-shalev added the WIP-DNM Work in progress / Do not review label Apr 19, 2026
@michal-shalev
michal-shalev marked this pull request as draft April 19, 2026 16:18
@michal-shalev
michal-shalev force-pushed the uct-cuda-ipc-sgl branch 2 times, most recently from 81ed122 to 2101677 Compare April 26, 2026 15:17
@michal-shalev michal-shalev added Ready for Review and removed WIP-DNM Work in progress / Do not review labels Apr 26, 2026
@michal-shalev
michal-shalev marked this pull request as ready for review April 26, 2026 15:18
@michal-shalev
michal-shalev force-pushed the uct-cuda-ipc-sgl branch 2 times, most recently from e66fb59 to f56085d Compare April 26, 2026 16:08
@michal-shalev
michal-shalev marked this pull request as draft April 26, 2026 16:54
@michal-shalev michal-shalev added the WIP-DNM Work in progress / Do not review label Apr 26, 2026
@openucx openucx deleted a comment from svc-nixl May 4, 2026
@michal-shalev
michal-shalev force-pushed the uct-cuda-ipc-sgl branch 3 times, most recently from 325279b to 50b7f6f Compare June 24, 2026 11:55
@michal-shalev michal-shalev added Ready for Review and removed WIP-DNM Work in progress / Do not review Ready for Review labels Jun 30, 2026
@michal-shalev
michal-shalev force-pushed the uct-cuda-ipc-sgl branch 3 times, most recently from be7b14d to e4b5a14 Compare July 2, 2026 10:17
@michal-shalev
michal-shalev marked this pull request as ready for review July 2, 2026 10:18
@michal-shalev
michal-shalev requested a review from brminich July 2, 2026 10:19
Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_ep.c Resolved
Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_ep.c Outdated
Comment on lines +304 to +307
if (ucs_unlikely(count == 0)) {
ucs_trace_data("Zero count put_sgl_zcopy: skip it");
return UCS_OK;
}

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 we do not need this check separately - it is covered by the check on line 320 below. you can move trace there

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_ep.c Outdated
mapping->count = count;
mapping->entries = (uct_cuda_ipc_sgl_entry_t *)(mapping + 1);

cuda_dsts = ucs_malloc(count * sizeof(CUdeviceptr), "cuda_ipc_sgl_dsts");

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 we combine with mapping allocation? i.e. have one malloc covering both?

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_ep.c Resolved
Comment thread src/uct/cuda/cuda_ipc/cuda_ipc_iface.c Outdated
uct_cuda_ipc_sgl_unmap(mapping, mapping->count,
cuda_ipc_event->cuda_device,
iface->config.enable_cache);
ucs_free(mapping);

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 we can free in uct_cuda_ipc_sgl_unmap? they are always used together

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

@michal-shalev
michal-shalev requested a review from brminich July 9, 2026 12:32
return status;
}

mapping = ucs_malloc(sizeof(*mapping) +

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.

for the next PR, we can alloca if batch is not big

Comment on lines +337 to +344
#if CUDA_VERSION >= 13000
if (cuda_ipc_event->sgl_mapping != NULL) {
uct_cuda_ipc_sgl_mapping_destroy(cuda_ipc_event->sgl_mapping,
cuda_ipc_event->cuda_device,
iface->config.enable_cache);
return;
}
#endif

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.

for the next PR, we can keep CUDA > 13 macro guard only inside uct_cuda_ipc_sgl_mapping_destroy and cuda_ipc_event->sgl_mapping will always be NULL for older cuda
This would reduce number of ifdefs thru the code a bit


_UCT_INSTANTIATE_TEST_CASE(test_cuda_ipc_rma_device, cuda_ipc)

class test_cuda_ipc_put_sgl : public test_cuda_ipc_rma {

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.

next PRs, we can make it generic UCT test for all tls supporting put_SGL

@michal-shalev
michal-shalev enabled auto-merge (squash) July 9, 2026 15:17
@michal-shalev
michal-shalev merged commit b01c4ed into openucx:master Jul 10, 2026
161 checks passed
@michal-shalev
michal-shalev deleted the uct-cuda-ipc-sgl branch July 15, 2026 12:43
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.

3 participants