Skip to content

UCT/UD: Do not complete an endpoint check on a simultaneous CREQ - #12409

Open
dmitrygx wants to merge 7 commits into
openucx:masterfrom
dmitrygx:topic/ucx/ud-simultaneous-creq-check
Open

dmitrygx wants to merge 7 commits into
openucx:masterfrom
dmitrygx:topic/ucx/ud-simultaneous-creq-check

Conversation

@dmitrygx

@dmitrygx dmitrygx commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

What

An endpoint check on a UD endpoint no longer completes when a simultaneous CREQ from the peer is handled as the ACK of our CREQ. The check now waits for the ACK of our CREP.

Why

A simultaneous CREQ shows only that we received the peer's packet, not that the peer received ours. UCP gates the recovery of a failed lane by such a check on an aux UD endpoint. When a link drops the packets of one side only, the probe of that side completed on the peer's CREQ, so the side put the lane back while its packets were still dropped. The lane then failed again and flapped.

On a NIXL disaggregated-inference test (KV cache PUSH, fault tolerance on, one NIC plane of the prefill node drops its TX traffic), the flapping lane stalled KV transfers for 35-40 s at a time while the drop lasted: -50% to -83% tok/s/GPU. With this fix, throughput during the drop is the same as with KV PULL (187k vs 108k tok/s/GPU before the fix), and no requests fail.

How

  • uct_ud_ep_crep_comp_wait(): before the incoming CREQ is handled as the ACK of our CREQ, move the completions waiting for our CREQ to the PSN of our CREP.
  • uct_ud_ep_crep_comp_purge(): a purge drops the CREP that is not sent yet, so it releases those completions with the packets sent.
  • Tests: test_ud.ep_check_simultaneous_creq_tx_lost and test_ud.ep_check_simultaneous_creq_destroy.

@dmitrygx
dmitrygx requested a review from a team as a code owner November 20, 2026 20:17
@svc-nvidia-pr-review

Copy link
Copy Markdown

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

Comment thread src/uct/ib/ud/base/ud_ep.c Outdated
/* No TX window while the window is released: a completion callback that
* sends on this EP gets UCS_ERR_NO_RESOURCE instead of adding a packet
* which this purge would not release */
uct_ud_ep_tx_stop(ep);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

can we move uct_ud_ep_tx_stop() to the beginning of the purge?
uct_ud_iface_dispatch_async_comps() and uct_ud_ep_purge_outstanding() also
invoke user completions that may send, and such a packet is then completed with
the purge error instead of getting UCS_ERR_NO_RESOURCE.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The purge order is changed in #12408 (68cc91c). This PR is now based on master and does not change it.

Comment thread src/uct/ib/ud/base/ud_ep.c Resolved
A CREQ from the peer that arrives while our own CREQ is not acknowledged
(a simultaneous connect) is handled as the ACK of our CREQ. An endpoint
check waiting behind our CREQ must not complete with it, since the peer
may not have received any packet of the endpoint, as on a link that
drops the packets of one side only.

ep_check_simultaneous_creq_tx_lost: the peer drops all packets of the
endpoint and connects back. The check must not complete until a packet
of the endpoint reaches the peer.

ep_check_simultaneous_creq_destroy: as above, but the endpoint cannot
send its CREP and is destroyed. The check must complete once, as
canceled.
A CREQ from the peer that arrives while our own CREQ is not acknowledged
(a simultaneous connect) is handled as the ACK of our CREQ, which is
removed from the TX window. An endpoint check added behind the CREQ by
uct_ep_check() was completed with it, although the peer may not have
received any packet from us.

UCP gates the recovery of a failed lane by such an endpoint check on an
aux UD endpoint on each side. The replier creates its aux endpoint
first, so the CREQ of the initiator probe arrives as a simultaneous one
and completes the replier probe. When the link drops the packets of the
replier only, the replier then connected its replacement queue pair and
put the lane back into its endpoint while the drop was still in place.
Its traffic and keepalive on that lane failed again, and the lane
flapped.

The CREQ still has to leave the TX window, since a connected endpoint
must not resend it. Before handling the incoming CREQ as its ACK, move
the checks waiting for our CREQ to the next PSN, the one of our CREP.
They complete when the peer acknowledges the CREP, one round trip later
on a working link, and only after a packet of ours reached the peer. A
purge that drops the CREP before it is sent releases them with the
packets sent.
@dmitrygx
dmitrygx force-pushed the topic/ucx/ud-simultaneous-creq-check branch from b355d52 to 390d02e Compare November 20, 2026 20:36
@svc-nvidia-pr-review

Copy link
Copy Markdown

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

Comment thread src/uct/ib/ud/base/ud_ep.c Resolved
Comment thread src/uct/ib/ud/base/ud_ep.c Resolved

/* No TX resources on m_e1: its CREP stays scheduled */
tx_available = iface(m_e1)->tx.available;
iface(m_e1)->tx.available = 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

On devices without ordered_send_comp every send is signaled, so the CREQ send completion polled inside validate_connect() adds the TX credit back and the CREP may be sent; then tx.psn advances, uct_ud_ep_crep_comp_purge() is not exercised anymore and the test still passes. Can we assert the CREP is still scheduled before destroy_ep(), e.g. ASSERT_TRUE(uct_ud_ep_ctl_op_check(ep(m_e1), UCT_UD_EP_OP_CREP))?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in 3c1273d.

@svc-nvidia-pr-review

Copy link
Copy Markdown

Coverage note: both new tests require UCT_UD_EP_DEBUG_HOOKS and real UD HW (ud_verbs/ud_mlx5), so they only run in HW-enabled jobs or under contrib/ibmock.

The negative check in ep_check_simultaneous_creq_tx_lost relies on a 100 ms progress window; that is consistent with existing tests (crep_drop2), so not flagged.

Not covered, and arguably out of scope: uct_ud_ep_flush() on a connected ep can still return UCS_OK while UCT_UD_EP_OP_CREP is pending after a simultaneous CREQ (same "nothing of ours reached the peer" hole, pre-existing for flush).

Print tx.psn on the CREP assert, make uct_ud_ep_crep_comp_wait() mirror
uct_ud_ep_crep_comp_purge() by tx.psn, and check in the destroy test
that the CREP is still scheduled, so the test cannot pass with the CREP
sent.
@dmitrygx

Copy link
Copy Markdown
Member Author

Re the summary: agreed, flush on a connected endpoint with a pending CREP is a separate, pre-existing case; this PR keeps to the endpoint check.

@svc-nvidia-pr-review

Copy link
Copy Markdown

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

uct_ud_ep_ctl_op_del(ep, ep->tx.pending.ops);
ucs_arbiter_group_desched(&iface->tx.pending_q, &ep->tx.pending.group);
ep->tx.acked_psn = (uct_ud_psn_t)(ep->tx.psn - 1);
uct_ud_ep_crep_comp_purge(ep);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

uct_ud_ep_flush(CANCEL) also forces acked_psn = tx.psn - 1 and relies on the ACK_REQ send completion to drain the window, but in the state created by uct_ud_ep_crep_comp_wait() (ep connected by the simultaneous CREQ, CREP still only scheduled, dummy comp skb at psn == tx.psn) the bumped completion stays at the queue head with psn > acked_psn, so ucs_queue_for_each_extract() stops there and neither it nor the flush completion queued behind it is released. The user completion then waits for the CREP ack or the peer timeout (UD_TIMEOUT, default 30s), i.e. flush(CANCEL) (UCP force close) can stall on such an ep. Can we call uct_ud_ep_crep_comp_purge() in the CANCEL branch of uct_ud_ep_flush() as well?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Right, the bumped completion blocked the window head after flush(CANCEL). Done in 7ec9414: the CANCEL branch of uct_ud_ep_flush() calls uct_ud_ep_crep_comp_purge() too. I did not add a test for it: the CREP stays unsent only without TX resources, and then flush() returns UCS_ERR_NO_RESOURCE before it gets to the window.

@svc-nvidia-pr-review

Copy link
Copy Markdown

Coverage note: both new tests require UCT_UD_EP_DEBUG_HOOKS plus UD HW (ud_verbs/ud_mlx5) or contrib/ibmock, which is consistent with the surrounding block. However, the flush(CANCEL) state described above is not exercised by either new test.

flush(CANCEL) acknowledges the packets sent, but a completion moved to
the PSN of the CREP which is not sent yet stayed in the window, and the
flush completion behind it waited for the CREP ACK or the endpoint
timeout.
@svc-nvidia-pr-review

Copy link
Copy Markdown

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

@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Review complete — no issues found.

@svc-ucx

svc-ucx commented Nov 21, 2026

Copy link
Copy Markdown

🤖 CI Triage Agent — UCX PR · commit 7ec9414d

Summary: Unable to fetch logs — cannot diagnose without them.
Root cause: Unknown — log access failed.
Implicated commit: unknown
File: unknown
Suggested fix: Provide a direct link to the failed build log in a follow-up comment.
Log fetch attempts:

  • fetch_azure_logs({'build_url': 'https://dev.azure.com/ucfconsort/0b36e3f0-8ab9-4a48-b68b-[REDACTED:Hex High Entropy String]/_build/results?buildId=146698'}) → [fetch_azure_logs ERROR: no failed job found in timeline for build 146698]
  • fetch_jenkins_stages({'job': 'UCX PR', 'build': 146698}) → [fetch_jenkins_stages ERROR] build URL names Jenkins controller 'https://dev.azure.com/ucfconsort/0b36e3f0-8ab9-4a48-b68b-[REDACTED:Hex High Entropy String]/_build/results?buildId=146698', but this deployment is configured for 'https://nbuprod.blsm.nvidia.com/nb
  • fetch_jenkins_logs({'job': 'UCX PR', 'build': 146698}) → [fetch_jenkins_logs ERROR] build URL names Jenkins controller 'https://dev.azure.com/ucfconsort/0b36e3f0-8ab9-4a48-b68b-[REDACTED:Hex High Entropy String]/_build/results?buildId=146698', but this deployment is configured for 'https://nbuprod.blsm.nvidia.com/nbu-
  • fetch_azure_logs({'build_url': 'https://dev.azure.com/ucfconsort/0b36e3f0-8ab9-4a48-b68b-[REDACTED:Hex High Entropy String]/_build/results?buildId=146698&view=logs'}) → [fetch_azure_logs ERROR: no failed job found in timeline for build 146698]
  • fetch_test_server_logs({'node': 'dev.azure.com', 'job': 'UCX PR 146698'}) → [fetch_test_server_logs ERROR] dev.azure.com/UCX PR 146698: FileNotFoundError: [Errno 2] No such file or directory: '/home/ci/.ssh/id_rsa'

🛡️ This comment had 1 potential secret(s) redacted (Hex High Entropy String). See request_id 212fee40-ca9f-42c4-9b60-7549efb38159 in the triage console for the audit trail.

@svc-nvidia-pr-review

Copy link
Copy Markdown

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

Comment thread test/gtest/uct/ib/test_ud.cc Outdated
ep_check_comp.status = UCS_OK;
ep_check_count = 0;
ep_check_status = UCS_OK;
flush_comp.func = [](uct_completion_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.

pls align these with the assignment block above and add the space before *; .clang-format has AlignConsecutiveAssignments: true and PointerAlignment: Right, so the format code CI job will report a diff on these 3 lines.

Suggested change
flush_comp.func = [](uct_completion_t*) {};
flush_comp.func = [](uct_completion_t *) {};
flush_comp.count = 1;
flush_comp.status = UCS_OK;

(All 8 assignments from ep_check_comp.func down to flush_comp.status are one consecutive run with no blank line, so clang-format aligns = to the column set by ep_check_comp.status.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The alignment was done in 3cf7a09, and f19d2fd adds the space before *.

@svc-nvidia-pr-review

Copy link
Copy Markdown

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

@dpressle

Copy link
Copy Markdown
Contributor

/build

roiedanino
roiedanino previously approved these changes Nov 22, 2026
ASSERT_EQ(UCS_INPROGRESS, uct_ep_check(m_e1->ep(0), 0, &ep_check_comp));

/* No TX resources on m_e1: its CREP stays scheduled */
tx_available = iface(m_e1)->tx.available;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In ep_check_simultaneous_creq_destroy: can we reclaim the CREQ send credit first, as in ep_check_simultaneous_creq_cancel?

Suggested change
tx_available = iface(m_e1)->tx.available;
/* Reclaim the local CREQ send credit before hiding the TX resources. */
short_progress_loop();
tx_available = iface(m_e1)->tx.available;
iface(m_e1)->tx.available = 0;

On devices with ordered_send_comp=0 (EFA) every send is signaled, so poll_tx() during validate_connect() returns the CREQ credit, the CREP gets sent and ASSERT_TRUE(..., UCT_UD_EP_OP_CREP) fails.

Impact: test-only flakiness, limited to transports where each send generates a CQE (uct_ud_verbs_post_send() forces IBV_SEND_SIGNALED when !dev->ordered_send_comp); on mlx5/IB the first CREQ is unsignaled (UCT_UD_TX_MODERATION=64), so the current code passes there.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in f19d2fd: the destroy test reclaims the CREQ send credit before hiding the TX resources, as the cancel test does.

@svc-nvidia-pr-review

Copy link
Copy Markdown

src/uct/ib/ud/base/ud_ep.c

minor: pls update the window; /* send window: [acked_psn+1, psn-1] */ comment in ud_ep.h — a completion skb now stays in the window with psn == tx.psn.

Poll the CREQ send completion in ep_check_simultaneous_creq_destroy
before hiding the TX resources, as ep_check_simultaneous_creq_cancel
does. Where every send is signaled, the completion polled later in
validate_connect() returned the credit and the CREP was sent. Also add
the space before '*' in the cancel test's completion lambda.
@svc-nvidia-pr-review

Copy link
Copy Markdown

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

@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Review complete — no issues found.

roiedanino
roiedanino previously approved these changes Nov 22, 2026
@roiedanino
roiedanino enabled auto-merge (squash) November 22, 2026 10:59
@svc-ucx

svc-ucx commented Nov 22, 2026

Copy link
Copy Markdown

🤖 CI Triage Agent — UCX PR (AddressSanitizer BlueField on worker 2) · commit f19d2fde

TL;DR: The BlueField ASan job failed on a LeakSanitizer report (68 KB in 17 allocations), not on the PR's UD code: test_ucp_proto_mock_rcx_speed_change.rma_get leaks a whole UCT resource chain (IB md UAR/dbrec/PD, one rc_mlx5 iface's DEVX CQ/RX umems, and one uct_rc_mlx5_ep plus its ucp_wireup_ep proxy) created in its init(). Root cause is UCT endpoints dropped during the mocked IBV_EVENT_DEVICE_SPEED_CHANGE reconfiguration being discarded asynchronously and never actually destroyed, so rerun/track this as a test-infra bug, not a PR regression.

Full analysis

Summary: make test in the gtest stage exited 1 because LeakSanitizer reported SUMMARY: AddressSanitizer: 68024 byte(s) leaked in 17 allocation(s), every leak stack rooted in test_ucp_proto_mock_rcx_speed_change_rma_get_Test::init().

Root cause: All 17 leak stacks come from objects allocated while setting up that one test:

  • uct_md_open → uct_ib_mlx5_devx_md_open_common → uct_ib_mlx5_devx_check_uar (ib_mlx5.c:645) and uct_ib_mlx5_add_page (dbrec mpool page), plus a suppressed ibv_alloc_pd hit → an IB md was never closed.
  • ucp_worker_iface_open → uct_rc_mlx5_iface_t_new → uct_ib_mlx5_devx_create_cq (ib_mlx5_dv.c:695) and uct_rc_mlx5_devx_init_rx_common (rc_mlx5_devx.c:233) → one rc_mlx5 iface was never destroyed.
  • ucp_ep_create → ucp_wireup_init_lanes → ucp_wireup_connect_lane_to_ep → a leaked ucp_wireup_ep/stub iface (uct_stub_iface_open, uct_iface.c:1232) and a leaked uct_rc_mlx5_ep with its DEVX QP (64 KB buffer, ib_mlx5_dv.c:290).

A leaked wireup proxy + its uct_rc_mlx5_ep is the signature of the endpoint-reconfiguration discard path: the test's set_port_speed() injects IBV_EVENT_DEVICE_SPEED_CHANGE (test_ucp_proto_mock.cc:5033), which re-runs ucp_wireup_init_lanes → ucp_wireup_check_config_intersect, where lanes not reused are handed to ucp_worker_discard_uct_ep() (src/ucp/wireup/wireup.c:2766) and destroyed only when the async flush/discard completes. If that discard never completes, the uct_ep — and the iface/md it pins — are freed neither at discard nor at worker destroy. Nothing in any stack touches UD/CREQ code, so this is not caused by commit f19d2fd / PR #12409 (UCT/UD: Do not complete an endpoint check on a simultaneous CREQ).

Implicated commit: unknown (not the PR commit). Most likely candidates in the touched area: [REDACTED:Hex High Entropy String] (Guy Ealey Morag, "TEST/UCP: Make test_port_speed more robust", #11901), f68fa5fc (dmitrygx, "UCP/CORE: Close endpoints by force on worker destroy", #12360), 48795b8b/4748c2a0 (dmitrygx, measured path-bandwidth per EP, #12334/#12362).

File: test/gtest/ucp/test_ucp_proto_mock.cc:5029-5035 (set_port_speed) and src/ucp/wireup/wireup.c:2760-2785 (ucp_wireup_check_config_intersect discard loop)

Suggested fix:

  1. Re-run the BlueField ASan job on this PR to confirm the leak is not caused by the UD change (expected: it is not — no UD frames appear).
  2. Make the speed-change test drain pending discards before teardown: in set_port_speed() (and in test_ucp_proto_mock_rcx_speed_change cleanup) progress the worker until the discard hash is empty (e.g. while (progress()); plus a wait on kh_size(&worker->discard_uct_ep_hash) == 0), instead of only while (progress()); once after ib_event().
  3. If the discard really never completes, fix the ownership bug in the reconfiguration path: ensure ucp_worker_discard_uct_ep() for lanes dropped by a speed-change-driven reselection is completed (or force-destroyed) on ucp_ep_destroy/ucp_worker_destroy, mirroring the force-close logic added in UCP/CORE: Close endpoints by force on worker destroy #12360.
  4. Do not paper over this with an LSan suppression — the leaked PD/UAR/QP indicate real resource retention.

Related: PR #12409 (the PR under test, unrelated to the failure); #11901 (test_port_speed robustness); #12360 (close endpoints by force on worker destroy); #12334 / #12362 (measured path bandwidth); #12206 (skip slow BW lanes during pairwise selection)

🛡️ This comment had 1 potential secret(s) redacted (Hex High Entropy String). See request_id 0837af25-d536-4d08-a41e-682c3c96b8c3 in the triage console for the audit trail.

gleon99
gleon99 previously approved these changes Nov 22, 2026
@roiedanino
roiedanino dismissed stale reviews from gleon99 and themself via 89d2ec0 November 23, 2026 09:34
@svc-nvidia-pr-review

Copy link
Copy Markdown

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

@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Review complete — no issues found.

Comment thread src/ucp/core/ucp_ep.c Resolved

This branch has not been deployed

No deployments
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