Skip to content

DRAFT : Register memory#1010

Draft
jeffnvidia wants to merge 13 commits intoopenucx:masterfrom
jeffnvidia:register_memory
Draft

DRAFT : Register memory#1010
jeffnvidia wants to merge 13 commits intoopenucx:masterfrom
jeffnvidia:register_memory

Conversation

@jeffnvidia
Copy link
Copy Markdown
Contributor

What

add callback function to replace cuda copy

Why ?

There is a deadlock when executing collectives in AI workload

@swx-jenkins3
Copy link
Copy Markdown

Can one of the admins verify this patch?

Comment thread src/components/ec/base/ucc_ec_base.h Outdated

typedef struct node_ucc_ee_executor_task node_ucc_ee_executor_task_t;
typedef struct node_ucc_ee_executor_task {
ucc_ee_executor_task_t *val;
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.

change val to etask

Comment thread src/components/tl/ucp/tl_ucp_coll.h Outdated
} \
} while(0)

// #define EXEC_TASK_TEST_2(_errmsg, _etask) do {
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.

remove

while (polls++ < task->n_polls) {
node_ucc_ee_executor_task_t *current_node;
current_node = task->allgather_kn.etask_linked_list_head;
while(current_node != 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.

Ask Sergey should this be put inside / outside of loop

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.

what are you talking about ? I don't remember

Copy link
Copy Markdown
Contributor

@lappazos lappazos Aug 22, 2024

Choose a reason for hiding this comment

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

performance wise, should we iterate the list of etasks inside the while loop, or outside (1 TIME OR N_POLL TIME)

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.

almost no performance difference according to Sergey

Comment thread src/components/tl/ucp/tl_ucp_coll.h Outdated
status = ucc_ee_executor_task_test(current_node->val); \
if (status > 0) { \
ucc_ee_executor_task_finalize(current_node->val); \
ucp_memcpy_device_complete(current_node->val->completion, status);
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.

have to come before finalize

Comment thread src/components/tl/ucp/tl_ucp_coll.h Outdated
node_ucc_ee_executor_task_t *current_node;
current_node = task->allgather_kn.etask_linked_list_head;
while(current_node != NULL) {
if (current_node->val != 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.

can be removed

Comment on lines +226 to +227
task->allgather_kn.etask_linked_list_head = (node_ucc_ee_executor_task_t *)malloc(sizeof(node_ucc_ee_executor_task_t));
task->allgather_kn.etask_linked_list_head->val = 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.

task->allgather_kn.etask_linked_list_head = NULL

ucc_tl_ucp_context_t *ctx = UCC_TL_UCP_TEAM_CTX(team);
ucp_mem_map_params_t mmap_params;
ucp_mem_h mh;
int size_of_list = 6;
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 start with 1;

UCP_MEM_MAP_PARAM_FIELD_MEMORY_TYPE;
mmap_params.memory_type = ucc_memtype_to_ucs[mem_type];

// EXEC_TASK_TEST(UCC_KN_PHASE_INIT, "failed during ee task test",
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.

could be removed


mmap_params.address = task->allgather_kn.sbuf;
mmap_params.length = local * dt_size;
UCPCHECK_GOTO(ucs_status_to_ucc_status(ucp_mem_map(ctx->worker.ucp_context, &mmap_params, &mh)),
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.

dst is not important? ask Sergey
ucc_tl_ucp_send_nb(void *buffer, size_t msglen, ucc_memory_type_t mtype,
ucc_rank_t dest_group_rank, ucc_tl_ucp_team_t *team,
ucc_tl_ucp_task_t *task)

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.

dest isnt important

Comment on lines +325 to +333
mmap_params.address = rbuf;
mmap_params.length = data_size;
UCPCHECK_GOTO(ucs_status_to_ucc_status(ucp_mem_map(ctx->worker.ucp_context, &mmap_params, &mh)),
task, out);
if (count_mh == size_of_list){
size_of_list *= 2;
mh_list = (ucp_mem_h *)realloc(mh_list, size_of_list * sizeof(ucp_mem_h));
}
mh_list[count_mh++] = mh;
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.

make sure all cases are perfectly identical logic (double list size etc), try to create a macro if possible

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.

what isnt identical, I'm not sure to understand

}
mh_list[count_mh++] = mh;
}

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.

task->allgather_kn.etask = NULL;
task->allgather_kn.etask_linked_list_head->etask);

// task->allgather_kn.etask_linked_list_head = 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.

remove


EXEC_TASK_TEST(UCC_KN_PHASE_INIT, "failed during ee task test",
task->allgather_kn.etask);
task->allgather_kn.etask = 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.

a BUG - you can't remove it. its needed

team, task),
team, task, mh_list[count_mh++]),
task, out);
if (count_mh >= max_count){
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.

there is a function ucc_assert for that look what its doing

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.

why u chose to out that check here?

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.

should I just raise an error maybe ? How ?

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 I use ucc_assert, I can't add my print right ?

task, out);
if (count_mh >= max_count){
printf("count_mh is bigger than it should (%d >= %d).", count_mh, max_count);
goto out;
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.

not good here

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.

you mean even with ucc_assert ?

team, task),
team, task, mh_list[count_mh++]),
task, out);
if (count_mh >= max_count){
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.

same as above

Comment thread src/components/tl/ucp/tl_ucp_context.c Outdated
status = ucc_coll_task_get_executor(&task->super, &exec);
if (ucc_unlikely(status != UCC_OK)) {
task->super.status = status;
return -1;
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 u can simply return uuc_status? check its values, it's enum so it's int eventually

Comment thread src/components/tl/ucp/tl_ucp_context.c Outdated

if (ucc_unlikely(status != UCC_OK)) {
task->super.status = status;
return -1;
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.

same as above

task->allgather_kn.etask_linked_list_head = new_node;

task->allgather_kn.etask_linked_list_head->etask->completion = completion;
return 1;
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.

same as above

Comment thread src/components/tl/ucp/tl_ucp_context.c Outdated
status = ucc_ee_executor_task_test(etask);
while (status>0) {
status = ucc_ee_executor_task_test(etask);
// if (ucc_unlikely(status < 0)) {
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.

why not remove?

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 added it now

Comment thread src/schedule/ucc_schedule.h Outdated
#ifndef UCC_SCHEDULE_H_
#define UCC_SCHEDULE_H_

#include <ucp/api/ucp.h>
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 really needed?

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 think so for the ucp_mem_map

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.

check again

@jeffnvidia jeffnvidia changed the title Register memory DRAFT : Register memory Aug 25, 2024
Comment thread src/components/tl/ucp/tl_ucp_coll.h Outdated
Comment on lines +112 to +113
ucp_mem_h *mh_list;
int count_mh;
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.

add both to allgather

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.

Why ? Is it a bug ?

ucc_sbgp_t *sbgp;

task = ucc_tl_ucp_init_task(coll_args, team);
ucc_mpool_init(&task->allgather_kn.etask_node_mpool, 0, sizeof(node_ucc_ee_executor_task_t),
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.

u didn't check for status

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.

what should I do if status<0 ?

task->subset.myrank = sbgp->group_rank;
task->subset.map = sbgp->map;
}
register_memory(&task->super);
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.

u didn't check for status

Comment thread src/components/tl/ucp/tl_ucp_coll.h Outdated
#define MEM_MAP() do { \
status = ucp_mem_map(ctx->worker.ucp_context, &mmap_params, &mh); \
if (UCC_OK != status) { \
task->super.status = status; \
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.

no, just return status and error

tl_error(self->super.super.lib,

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 should keep this self->super.super.lib or it's something else for here ?

Comment thread src/components/tl/ucp/tl_ucp_coll.h Outdated
node_ucc_ee_executor_task_t *etask_linked_list_head;
ucc_rank_t recv_dist;
ucc_mpool_t etask_node_mpool;
ucc_ee_executor_task_t *etask;
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.

move back to original place

if (UCC_INPROGRESS == ucc_tl_ucp_test_with_etasks(task)) {
SAVE_STATE(UCC_KN_PHASE_PROXY);
return;
}
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.

add in out
|ucc_assert(count_mh == max_count) or smth similar

size_t local = GET_LOCAL_COUNT(args, size, rank);
ucp_mem_h *mh_list = task->mh_list;
int max_count = task->count_mh;
int count_mh = 0;
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.

BUG - this is a mistake, because u want to keep it when u go in and out from progress

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.

right but so how do I initialize it ?


EXEC_TASK_TEST(UCC_KN_PHASE_INIT, "failed during ee task test",
task->allgather_kn.etask);

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.

remove


UCC_TL_UCP_PROFILE_REQUEST_EVENT(coll_task, "ucp_allgather_kn_start", 0);
ucc_tl_ucp_task_reset(task, UCC_INPROGRESS);
task->allgather_kn.etask = 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.

BUG - why removed?


if (KN_NODE_EXTRA == node_type) {
if (p->type != KN_PATTERN_ALLGATHERX) {

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.

no need for all of the line spaces

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