Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TL/UCP: Allow self copy in allgather using network loopback #1021

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

yaeliyac
Copy link

@yaeliyac yaeliyac commented Sep 19, 2024

What

Add option for self copy loopback in out of place start for allgather algorithms: knomial, ring, neighbor, sparbit

Why ?

When using UCC plugin for NCCL, using cuda_memcpy might cause deadlock

How ?

Add UCC_TL_UCP_ALLGATHER_USE_LOOPBACK flag to control this
Tested on ISRAEL-1 with multiple test cases - showed good results and same performance with and without loopback
image

@swx-jenkins3
Copy link

Can one of the admins verify this patch?

@yaeliyac yaeliyac closed this Nov 6, 2024
@yaeliyac yaeliyac reopened this Nov 6, 2024
@yaeliyac yaeliyac marked this pull request as ready for review November 18, 2024 15:39
@yaeliyac yaeliyac changed the title UCC plugin for NCCL - adjustments Allow self copy in allgather using network loopback Dec 11, 2024
@janjust janjust requested review from nsarka and janjust December 11, 2024 16:08
@Sergei-Lebedev
Copy link
Contributor

ok to test

src/components/cl/basic/cl_basic_context.c Outdated Show resolved Hide resolved
src/components/ec/cuda/ec_cuda_executor.c Outdated Show resolved Hide resolved
src/components/ec/cuda/ec_cuda_executor.c Outdated Show resolved Hide resolved
src/components/tl/ucp/allgather/allgather_knomial.c Outdated Show resolved Hide resolved
src/components/tl/ucp/allgather/allgather_knomial.c Outdated Show resolved Hide resolved
src/components/tl/ucp/allgather/allgather_knomial.c Outdated Show resolved Hide resolved
src/components/tl/ucp/allgather/allgather_neighbor.c Outdated Show resolved Hide resolved
src/components/tl/ucp/tl_ucp.c Outdated Show resolved Hide resolved
@samnordmann samnordmann self-requested a review December 13, 2024 12:35
@yaeliyac yaeliyac force-pushed the origin/for_plugin branch 3 times, most recently from 482006f to eecdebf Compare December 13, 2024 15:28
@janjust
Copy link
Collaborator

janjust commented Dec 13, 2024

@Sergei-Lebedev why do we have to keep approving runs when force pushing?? Seems an outlier here

@yaeliyac yaeliyac force-pushed the origin/for_plugin branch 3 times, most recently from 32b3ccd to b1c875b Compare December 15, 2024 11:49
@yaeliyac yaeliyac changed the title Allow self copy in allgather using network loopback TL/UCP: Allow self copy in allgather using network loopback Dec 15, 2024
@yaeliyac yaeliyac force-pushed the origin/for_plugin branch 3 times, most recently from 2dc74f3 to a2c5fee Compare December 15, 2024 16:18
src/components/tl/ucp/allgather/allgather_ring.c Outdated Show resolved Hide resolved
src/components/tl/ucp/allgather/allgather_neighbor.c Outdated Show resolved Hide resolved
src/components/tl/ucp/allgather/allgather_knomial.c Outdated Show resolved Hide resolved
step = task->tagged.send_posted;
int iter = use_cuda ? tsize - 1 : tsize; //when using loopback tagged.send_posted has 1 more which will cause non-complete ring algorithm
while (task->tagged.send_posted < iter) {
step = use_cuda ? task->tagged.send_posted : task->tagged.send_posted - 1; //when using loopback tagged.send_posted has 1 more which will cause wrong calculation of send/recv
Copy link
Contributor

Choose a reason for hiding this comment

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

since loopback affects algorithm flow I would rather consider checking loopback copy result somehow differently, maybe add custom callback for ucp recv completion

Copy link
Collaborator

@samnordmann samnordmann left a comment

Choose a reason for hiding this comment

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

Thank you! It Looks good, I left a bunch of comments mainly on codestyle.

However, please add tests for that feature.

Also please note from the CI:

Commit title is too long: 59
Bad commit title: 'TL/UCP: Allow self copy in allgather using network loopback'

src/components/tl/ucp/allgather/allgather_knomial.c Outdated Show resolved Hide resolved
src/components/tl/ucp/allgather/allgather_knomial.c Outdated Show resolved Hide resolved
src/components/tl/ucp/tl_ucp.h Outdated Show resolved Hide resolved
src/components/tl/ucp/tl_ucp.c Outdated Show resolved Hide resolved
src/components/tl/ucp/tl_ucp.c Outdated Show resolved Hide resolved
src/components/tl/ucp/allgather/allgather_sparbit.c Outdated Show resolved Hide resolved
src/components/tl/ucp/allgather/allgather_sparbit.c Outdated Show resolved Hide resolved

if (UCC_INPROGRESS == ucc_tl_ucp_test(task)) {
return;
}
sendto = ucc_ep_map_eval(task->subset.map, (trank + 1) % tsize);
recvfrom = ucc_ep_map_eval(task->subset.map, (trank - 1 + tsize) % tsize);

while (task->tagged.send_posted < tsize - 1) {
step = task->tagged.send_posted;
int iter = use_loopback ? tsize : tsize - 1; //when using loopback tagged.send_posted has 1 more which will cause non-complete ring algorithm
Copy link
Collaborator

@samnordmann samnordmann Dec 16, 2024

Choose a reason for hiding this comment

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

declaration of variable goes to the beginning of the function

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure to understand the comment. What do you mean by "will cause non-complete ring algorithm"?
Can you use a more explicit name than iter for that variable?

src/components/tl/ucp/allgather/allgather_ring.c Outdated Show resolved Hide resolved
@samnordmann
Copy link
Collaborator

@yaeliyac btw, for knomial inplace, we don't expect any change, right? Do we have an explanation for the degradation in the graph?

if (ucc_unlikely(status != UCC_OK)) {
task->super.status = status;
return status;
if (!use_loopback) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

minor: suggestion for better readability is to use direct logic in cases:

if (use_loopback) {
...
} else {
...
}

@@ -140,6 +140,10 @@ ucc_config_field_t ucc_tl_ucp_lib_config_table[] = {
ucc_offsetof(ucc_tl_ucp_lib_config_t, allgather_kn_radix),
UCC_CONFIG_TYPE_UINT},

{"ALLGATHER_USE_LOOPBACK", "0", "If set to 1 uses mc cuda copy, otherwise performs loopback for self copy",
Copy link
Collaborator

Choose a reason for hiding this comment

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

minor: alignment of {

return UCC_OK;
}


Copy link
Collaborator

Choose a reason for hiding this comment

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

minor: extra line

ucc_status_t status;



Copy link
Collaborator

Choose a reason for hiding this comment

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

extra line

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

Successfully merging this pull request may close these issues.

8 participants