Skip to content

UCP/RNDV/PPLN: Advertise error handling capability for put_mtype/ppln protocols - #10075

Merged
yosefe merged 1 commit into
openucx:masterfrom
iyastreb:ucp/ppln/advertise-error-handling
Sep 26, 2024
Merged

yosefe merged 1 commit into
openucx:masterfrom
iyastreb:ucp/ppln/advertise-error-handling

Conversation

@iyastreb

@iyastreb iyastreb commented Aug 20, 2024 •

Copy link
Copy Markdown
Contributor

What

Using UCX in this combination: 1.18+proto_v2+CUDA async+error handling, causes memory transfer via host instead of bounce buffers, making transfers prohibitively slow. Unlike with proto_v1, pipeline protocol (rndv_ppln over rnvd_(put/rtr)_mtype) is not being selected, because it doesn't support error handling.
As a result, memory copy is done through host staging buffers which drastically affect performance. The proper solution would be to enable error handling for aforementioned protocols with rkey invalidation.

This PR is the first step towards the real solution: here we just advertise support for error handling without providing invalidation flow. Subsequent PR will provide the invalidation functionality.

Related PRs: #8666, #9999

Comment thread test/gtest/ucp/test_ucp_am.cc Resolved
@iyastreb
iyastreb marked this pull request as draft August 22, 2024 09:13
@iyastreb iyastreb changed the title UCP/RNDV/PPLN: Advertize error handling capability for put_mtype/ppln UCP/RNDV/PPLN: Invalidation workflow for put_mtype/ppln Aug 28, 2024
@iyastreb
iyastreb force-pushed the ucp/ppln/advertise-error-handling branch from 6109394 to 362dcc1 Compare August 29, 2024 14:05
@iyastreb
iyastreb force-pushed the ucp/ppln/advertise-error-handling branch from 362dcc1 to 1218213 Compare September 10, 2024 12:10
@iyastreb iyastreb changed the title UCP/RNDV/PPLN: Invalidation workflow for put_mtype/ppln UCP/RNDV/PPLN: Advertise error handling capability for put_mtype/ppln protocols Sep 10, 2024
@iyastreb
iyastreb marked this pull request as ready for review September 10, 2024 12:14
@iyastreb
iyastreb requested a review from ivankochin September 10, 2024 12:14
@iyastreb
iyastreb force-pushed the ucp/ppln/advertise-error-handling branch from 1218213 to 5d0fe20 Compare September 10, 2024 12:26
Comment thread src/ucp/core/ucp_context.c Outdated
"Use two stage pipeline rendezvous protocol for intra-node GPU to GPU transfers",
ucs_offsetof(ucp_context_config_t, rndv_shm_ppln_enable), UCS_CONFIG_TYPE_BOOL},

{"RNDV_PIPELINE_ERRH_ENABLE", "n",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

An idea came to my mind that maybe it worth to introduce more common variable that allows using all the protocols which don't have implemented abort even if error handling is enabled. That control will allow customers to use all the protocols if they are OK that any abort call will cause hard error. Also it can be useful for testing and debugging from my point of view.

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 this idea might be useful, but maybe it's out of scope of this PR. Because in this particular case we plan to implement proper support for error handling and therefore this env var will be removed in the subsequent commit. So for these protocols it's not gonna be used anymore, and for the other ones - it can be addressed separately with clear scope & testing

Comment thread src/ucp/rndv/rndv_ppln.c Outdated
[UCP_PROTO_RNDV_PPLN_STAGE_ACK] = ucp_proto_rndv_send_ppln_atp_progress,
},
.abort = ucp_proto_abort_fatal_not_implemented,
.abort = ucp_proto_rndv_ppln_abort,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe it would be better to leave that aborts pointers set to ucp_proto_abort_fatal_not_implemented so when it is called, user will get hard error instead of half-ready abortion implementation without memory invalidation?

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.

For now I would keep it for 2 reasons:

  1. As discussed on the meeting, we don't want to crash the application in case of remote peer failure.
  2. Current protocol selection logic explicitly requires that abort function pointer is set to a different function:
void ucp_proto_select_add_proto
...
    if (init_params->ep_config_key->err_mode != UCP_ERR_HANDLING_MODE_NONE) {
        ucs_assertv(ucp_protocols[proto_id]->abort !=
                            ucp_proto_abort_fatal_not_implemented,
                    "error handling is enabled, but %s doesn't support abort()",
                    proto_name);
    }

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 add warning message to ucp_proto_rndv_ppln_abort and ucp_proto_rndv_put_mtype_abort? BTW, they are 100% identical, so can be replaced with one common function, for example ucp_proto_ppln_abort

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.

Ok for warning message
Ok for common function

Comment thread src/ucp/core/ucp_context.c Outdated
"Use two stage pipeline rendezvous protocol for intra-node GPU to GPU transfers",
ucs_offsetof(ucp_context_config_t, rndv_shm_ppln_enable), UCS_CONFIG_TYPE_BOOL},

{"RNDV_PIPELINE_ERRH_ENABLE", "n",

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

Suggested change
{"RNDV_PIPELINE_ERRH_ENABLE", "n",
{"RNDV_PIPELINE_ERROR_HANDLING", "n",

to be consistent with UCX_POSIX_ERROR_HANDLING

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 test/gtest/ucp/test_ucp_am.cc Outdated
Comment on lines +1984 to +1985
test_ucp_am_nbx_rndv_ppln() : m_mem_type(UCS_MEMORY_TYPE_HOST) {
}

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 to change

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.

ok

Comment thread test/gtest/ucp/test_ucp_am.cc Outdated
Comment on lines +2068 to +2089
bool is_ppln_supported(ucs_memory_type_t mem_type)
{
const auto ep = sender().ep();
const auto config = ucp_ep_config(ep);

for (auto i = 0; i < config->key.num_lanes; ++i) {
const auto lane = config->key.rma_bw_lanes[i];
if (lane == UCP_NULL_LANE) {
break;
}
if (ucp_ep_md_attr(ep, lane)->reg_mem_types & UCS_BIT(mem_type)) {
const auto iface_attr =
ucp_worker_iface_get_attr(sender().worker(),
ucp_ep_get_rsc_index(ep, lane));
if (iface_attr->cap.flags & UCT_IFACE_FLAG_PUT_ZCOPY) {
return true;
}
}
}

return false;
}

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 is it needed?
there is ucp_test_base::entity::is_rndv_put_ppln_supported()

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.

Thanks for spotting this, this is not needed, and not actually used, it's just a leftover after rebasing on master

brminich
brminich previously approved these changes Sep 16, 2024
Comment thread src/ucp/rndv/proto_rndv.inl Outdated
Comment on lines +389 to +390
static UCS_F_ALWAYS_INLINE void
ucp_proto_rndv_ppln_abort(ucp_request_t *req, ucs_status_t 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.

minor: this function is supposed to be called by pointer on non-fast path, no need inline and static, i.e. it can be declared in some common .h and defined in .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.

Done

Comment thread src/ucp/core/ucp_context.c Resolved
"Use two stage pipeline rendezvous protocol for intra-node GPU to GPU transfers",
ucs_offsetof(ucp_context_config_t, rndv_shm_ppln_enable), UCS_CONFIG_TYPE_BOOL},

{"RNDV_PIPELINE_ERROR_HANDLING", "n",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
{"RNDV_PIPELINE_ERROR_HANDLING", "n",
{"MOCK_RNDV_PPLN_ERROR_HANDLING", "n",

Not the perfect suggestion but I think it is important to represent in the name the fact that ppln error handling is just mocked but not really supported 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.

Personally I would not add "mock" prefix, but let's see what others think

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe RNDV_PPLN_IGNORE_FAILURES?

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 don't know, sounds a bit broad.. which failures?
maybe RNDV_PIPELINE_UNSAFE_ERROR_HANDLING?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe RNDV_PPLN_ERROR_HANDLING?

The short form PPLN also appears in UCX_RNDV_SCHEME values

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.

ok, sure

@brminich brminich Sep 24, 2024 •

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.

[mikhailb@rock20 ucx]$ ucx_info -c | grep PIPELINE
UCX_RNDV_PIPELINE_SEND_THRESH=inf
UCX_RNDV_PIPELINE_SHM_ENABLE=y
[mikhailb@rock20 ucx]$ ucx_info -c | grep PPLN
[mikhailb@rock20 ucx]$

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.

wait, it's dissonant with previous vars:

  {"RNDV_PIPELINE_SEND_THRESH", "inf",
   "RNDV size threshold to enable sender side pipeline for mem type",
   ucs_offsetof(ucp_context_config_t, rndv_pipeline_send_thresh), UCS_CONFIG_TYPE_MEMUNITS},

  {"RNDV_PIPELINE_SHM_ENABLE", "y",
   "Use two stage pipeline rendezvous protocol for intra-node GPU to GPU transfers",
   ucs_offsetof(ucp_context_config_t, rndv_shm_ppln_enable), UCS_CONFIG_TYPE_BOOL},

  {"RNDV_PPLN_ERROR_HANDLING", "n",

Comment thread src/ucp/rndv/proto_rndv.c Outdated
/* FIXME: Proper abort functionality is not implemented yet.
* This stub function is used to advertise error-handling capability for
* pipeline protocols, but proper implementation is to be done */
ucs_warn("aborting ppln request %p with status %s", req,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WDYT about making warning more informative and describe what it can lead to?

Suggested change
ucs_warn("aborting ppln request %p with status %s", req,
ucs_warn("rndv ppln request %p was aborted with status %s. "
"This may lead to memory leaks since rndv ppln abortion "
"mocking was enabled", req,

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.

My understanding is that it may lead to memory corruption rather than memory leak.
Because when we detect that EP is in failed state, we should invalidate the memh we exposed to prevent stale writes to it. Since we don't do invalidation yet, these writes may appear and damage chunk elements already used for different purpose.
So in worst case the same element is reused for some other operation and we can get data corrupted.
I can update the warning message with these details if you agree

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yeah, AFAIK that is true too. I thought about memory leaks because we are using mempools and I am not sure that we are returning them back in case of this abortion stub calling.

Mentioning memory corruption is OK from my point of view.

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 use ucs_diag instead of ucs_warn

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 use ucs_diag instead of ucs_warn

why? AFAIU this callback is not expected to be called, IMO warning is ok here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

+1 for leaving as warning (or at least debug message)

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.

+1 for leaving as warning (or at least debug message)

we are not going to remove it. We are duscussing the log level to be used

@evgeny-leksikov evgeny-leksikov Sep 20, 2024 •

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.

if you are sure that connect-to-ep works as expected, then this message will only confuse with any level.

I see 2 potential issues here:

  1. completion if single fragment might be not enough to complete full ppl protocol. It may be relevant for any type of transport. (@iyastreb confirmed that this is not the case).
  2. invalidation flow is valid only for connect-to-iface transport.
    So,
  • that's the reason to have it for connect-to-ep?
  • invalidation flow may lead to hardly reproducible data corruption bug, IMO warning is preferable because on re-run (with log level diag) error flow may be not invoked at all or invoked but without data corruption.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

+1 for leaving as warning (or at least debug message)

we are not going to remove it. We are duscussing the log level to be used

I understand, but I think that we need to print a warning message instead of diag to explicitly show user that something went wrong and call that was not supposed to be called was called. FMPOV if we didn't print warning in that case in protov1 it doesn't mean that we should keep this behavior now.

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.

let's discuss it on meeting, this discussion becomes too long

Comment thread src/ucp/rndv/rndv_put.c Resolved
"Use two stage pipeline rendezvous protocol for intra-node GPU to GPU transfers",
ucs_offsetof(ucp_context_config_t, rndv_shm_ppln_enable), UCS_CONFIG_TYPE_BOOL},

{"RNDV_PIPELINE_ERROR_HANDLING", "n",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe RNDV_PPLN_IGNORE_FAILURES?

Comment thread src/ucp/rndv/proto_rndv.c Resolved
Comment thread test/gtest/ucp/test_ucp_peer_failure.cc Resolved
Comment thread test/gtest/ucp/test_ucp_peer_failure.cc Resolved
Comment thread test/gtest/ucp/test_ucp_peer_failure.cc Resolved
Comment thread test/gtest/common/test_helpers.h Resolved
Comment thread test/gtest/common/test_helpers.h Resolved
Comment thread test/gtest/common/test_helpers.h Resolved
Comment thread test/gtest/common/test_helpers.h Resolved
Comment thread test/gtest/common/test_helpers.h Resolved
Comment thread src/ucp/rndv/rndv_ppln.c Resolved
Comment thread test/gtest/ucp/test_ucp_peer_failure.cc Resolved
Comment thread test/gtest/ucp/test_ucp_peer_failure.cc Resolved

@yosefe yosefe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

pls squash

@iyastreb
iyastreb force-pushed the ucp/ppln/advertise-error-handling branch from 7a65829 to f9fa5ea Compare September 25, 2024 12:46
@yosefe
yosefe enabled auto-merge September 25, 2024 13:04
@yosefe
yosefe merged commit 1b0cece into openucx:master Sep 26, 2024
@iyastreb
iyastreb deleted the ucp/ppln/advertise-error-handling branch September 26, 2024 09:24
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.

6 participants