Skip to content

UCP: add UCX_FAILOVER_MODE parameter - #11994

Merged
evgeny-leksikov merged 5 commits into
openucx:masterfrom
evgeny-leksikov:ucp_tf_param
Sep 29, 2026
Merged

evgeny-leksikov merged 5 commits into
openucx:masterfrom
evgeny-leksikov:ucp_tf_param

Conversation

@evgeny-leksikov

Copy link
Copy Markdown
Contributor

What?

add UCX_FAILOVER_MODE parameter

Why?

to control failover mode

HW-PSN failover reads the token capability and lengths from the worker
iface. A transport that does not implement tokens still opens, with both
lengths left at 0.
Endpoints in failover error-handling mode can select software discard
or token failover. The error path does not read the setting yet.
Endpoints in failover mode with UCX_FAILOVER_MODE=token keep transports
that can query a token. Other modes keep the existing transport set.
@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Starting review — findings will be posted here when done.

Comment thread src/ucp/wireup/select.c
ucp_rsc_index_t rsc_index;

memset(tl_bitmap_out, 0, sizeof(*tl_bitmap_out));
UCS_STATIC_BITMAP_FOR_EACH_BIT(rsc_index, tl_bitmap_in) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

blocker: tl_bitmap is often ucp_tl_bitmap_max (all 128 bits set) coming from the ucp_wireup_init_lanes() callers (ucp_ep.c:782/1169, wireup.c:733/829/1016, wireup_ep.c:279, forwarded via ucp_wireup_try_select_lanes()), so this loop queries ucp_worker_iface_get_attr_v2()/context->tl_rscs[rsc_index] for resource indexes that don't exist. For an index outside context->tl_bitmap, ucp_worker_iface() hits ucs_assert(UCS_STATIC_BITMAP_GET(tl_bitmap, rsc_index)) in debug builds, and in release returns worker->ifaces[popcount] past the end of the num_ifaces-element array, i.e. an out-of-bounds read followed by a bogus pointer dereference; the context->tl_rscs[rsc_index] access in the trace is OOB as well. Please intersect with context->tl_bitmap first, like ucp_wireup_select_transport() does (select.c:466):

Suggested change
UCS_STATIC_BITMAP_FOR_EACH_BIT(rsc_index, tl_bitmap_in) {
ucp_tl_bitmap_t tl_bitmap = UCS_STATIC_BITMAP_AND(
*tl_bitmap_in, worker->context->tl_bitmap);
ucp_rsc_index_t rsc_index;
UCS_STATIC_BITMAP_RESET_ALL(tl_bitmap_out);
UCS_STATIC_BITMAP_FOR_EACH_BIT(rsc_index, &tl_bitmap) {

Comment thread src/ucp/wireup/select.c
ucs_status_t status;

UCS_STATIC_BITMAP_AND_INPLACE(&scalable_tl_bitmap, tl_bitmap);
if ((key->err_mode == UCP_ERR_HANDLING_MODE_FAILOVER) &&

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The filtered bitmap is used for every lane type, including aux/wireup-msg and keepalive candidates (criteria.tl_rsc_flags = UCP_TL_RSC_FLAG_AUX at select.c:1207 and 2572, both restricted by select_params->tl_bitmap). ud/ud_mlx5/tcp use uct_iface_base_query_v2 and never report UCT_IFACE_FLAG_V2_QUERY_TOKEN, so with UCX_FAILOVER_MODE=token they are removed and a p2p transport such as rc_mlx5 connected by worker address has no aux transport left for the wireup message lane → ep creation fails. Should the filter be limited to the lanes that actually need token failover?

Comment thread src/ucp/wireup/select.c
continue;
}

ucs_trace(UCT_TL_RESOURCE_DESC_FMT " : disabled, no token query",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

minor: continuation lines of the if condition and of ucs_trace() are over-indented relative to the opening paren, plus there are redundant outer parentheses in the if. Please re-run clang-format.

ucs_offsetof(ucp_context_config_t, recovery_retries),
UCS_CONFIG_TYPE_UINT},

{"FAILOVER_MODE", "auto",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

FAILOVER_MODE doc vs code: only UCP_FAILOVER_MODE_TOKEN is consumed in this PR; auto and sw are handled identically, although the help text describes different semantics. Is the per-lane auto selection coming in a follow-up?

/**
* @return worker's iface v2 attributes by resource index
*/
static UCS_F_ALWAYS_INLINE uct_iface_attr_v2_t*

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

minor: duplicate v2 queries — ucp_proto_common_find_lanes() (proto_common.c:602) and proto_multi.c:597 still call uct_iface_query_v2() per protocol init for the same static v2 cap flags that are now cached. Maybe use this helper there instead?

@svc-nvidia-pr-review

Copy link
Copy Markdown

PR-level gap: no test exercises the new config value. Please add a test that creates an endpoint with UCX_FAILOVER_MODE=token, so the new TL filtering path (and the aux-lane interaction noted above) is covered by CI.

Default UCX_FAILOVER_MODE to software until token failover is complete.
The token suite stays off until --gtest_also_run_disabled_tests. It
uses the same transport matrix and skips when lane selection finds no
token-capable transport.
Token recovery is not implemented, so automatic selection uses the
software PSN protocol and does not change the transport set. Protocol
init reads iface v2 attributes cached at open.
@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Starting review — findings will be posted here when done.

Comment thread src/ucp/core/ucp_worker.c
const uint64_t basic_mask = UCT_IFACE_ATTR_FIELD_CAP_FLAGS |
UCT_IFACE_ATTR_FIELD_MAX_PUT_SGL_ZCOPY_COUNT |
UCT_IFACE_ATTR_FIELD_MAX_GET_SGL_ZCOPY_COUNT;
const uint64_t token_mask = UCT_IFACE_ATTR_FIELD_TX_TOKEN_LENGTH |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nothing reads tx_token_length/rx_token_length in this PR — can we query only the basic fields now and add the token lengths together with the code that consumes them? It would also drop this fallback and the second uct_iface_query_v2() call that every non-token transport now does at open.

Comment thread src/ucp/wireup/select.c
{
ucp_rsc_index_t rsc_index;

memset(tl_bitmap_out, 0, sizeof(*tl_bitmap_out));

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
memset(tl_bitmap_out, 0, sizeof(*tl_bitmap_out));
UCS_STATIC_BITMAP_RESET_ALL(tl_bitmap_out);

Minor: pls use the bitmap API instead of memset, as in the rest of this file.

Comment thread src/ucp/wireup/select.c
if ((key->err_mode == UCP_ERR_HANDLING_MODE_FAILOVER) &&
(worker->context->config.ext.failover_mode ==
UCP_FAILOVER_MODE_TOKEN)) {
ucp_wireup_filter_token_tls(worker, &tl_bitmap, &tl_bitmap_filtered);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If no transport reports QUERY_TOKEN, tl_bitmap_filtered becomes zero and the failure surfaces later as the generic "no am transport to " error. Can we detect the empty result here and log why all transports were disabled?

@svc-nvidia-pr-review

Copy link
Copy Markdown

src/ucp/core/ucp_context.c

In the token help text: token recovery is not implemented yet (see the auto handling in ucp_fill_config), so UCX_FAILOVER_MODE=token today only disables transports and still runs the sw protocol; pls say that in the help text.

Residual coverage gap (already raised in the earlier review): the token path is only covered by DISABLED_test_ucp_fault_tolerance_tf, which CI never runs.

@gleon99

gleon99 commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

token says it forces token-based retransmits, but recovery still uses the SW path. Right now it only filters transports. Can we avoid advertising token recovery until it's wired up?

@evgeny-leksikov

Copy link
Copy Markdown
Contributor Author

token says it forces token-based retransmits, but recovery still uses the SW path. Right now it only filters transports. Can we avoid advertising token recovery until it's wired up?

#11995 is the first step of that protocol. Without transport filtering we cannot force token based protocol to make sure that everything works as expected. Default "auto" will work via tokens once we have FT tests passed with forced token mode, currently these test suite is disabled and require extra flags for gtest command

@gleon99

gleon99 commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

👍🏼

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