Skip to content

UCP/RMA: Fix restart of partially sent PUT requests - #12322

Merged
tvegas1 merged 4 commits into
openucx:masterfrom
tvegas1:rndv_resume_probe
Nov 23, 2026
Merged

tvegas1 merged 4 commits into
openucx:masterfrom
tvegas1:rndv_resume_probe

Conversation

@tvegas1

@tvegas1 tvegas1 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What?

Fix the restart of a partially sent PUT request.

Why?

When a request is restarted after part of it was sent, for example when the endpoint replays its pending requests after a reconfiguration or with UCX_PROTO_REQUEST_RESET=y, it is reselected with the resume flag. Only a protocol that continues from the request offset may accept it:

  • put/offload/bcopy keeps its offset on reset but does not declare resume support. Without a resumable AM protocol, such as with UCX_PROTO_EMULATION_ENABLE=n, no protocol is found and the request is canceled.
  • put/rndv accepts the resume flag but ignores the offset: its RTS carries the original buffer, remote address and length, so it sends the whole message again.

How?

  • put/offload/bcopy declares resume support, like put/am/bcopy. Its send path already continues from the iterator offset, so an IOV request now resumes in both bcopy PUT protocols.
  • Both protocols share a new reset, ucp_proto_put_bcopy_reset(), which makes a contiguous request start from the current point: the buffer and the remote address move forward by the offset, the length shrinks by it, and the offset becomes 0. The request is reselected as a fresh PUT of the remaining data without the resume flag, so any protocol can send it, including rendezvous for GPU memory. This is safe because:
    • The offset counts posted fragments, whose data bcopy has already copied out of the user buffer.
    • Bcopy uses no memory registration, and the PUT protocols read only the current length of the iterator. The user request still completes once, when the remaining data is sent.
  • After this change, no contiguous PUT or GET request is restarted with the resume flag, so put/rndv and get/rndv only see requests that start from offset 0.
  • test_ucp_rma_restart sends a PUT that is larger than the send queue, restarts it by purging and replaying the lane pending queue, and checks the data. It also checks that only IOV requests are resumed. Without the fix, put/offload/bcopy requests are canceled, and contiguous requests are reselected with the resume flag.

Tested on a host without GPU, so the rendezvous path is not covered:

  • test_ucp_rma_restart on rc_x, shm and tcp. On shm and tcp, put_offload_bcopy is skipped since their RMA bandwidth lanes do not support put bcopy.
  • *test_ucp_rma* and *test_ucp_ep_reconfig*, with and without UCX_PROTO_REQUEST_RESET=y.

A restarted PUT which was partially sent is reselected with the resume
flag. put/offload/bcopy kept its offset on reset but cannot resume, so
without a resumable AM protocol the request was canceled. put/rndv and
get/rndv accepted the resume flag but ignored the offset.

Skip the data which was already sent by a contiguous bcopy PUT, so any
protocol can send the rest. Rewind an IOV request in put/offload/bcopy,
and reject the resume flag in the RMA rendezvous probes.
@tvegas1
tvegas1 requested a review from a team as a code owner November 11, 2026 20:15
@svc-nvidia-pr-review

Copy link
Copy Markdown

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

Comment thread src/ucp/rma/put_offload.c Resolved
Comment thread src/ucp/rma/rma_rndv.c Resolved
Comment thread test/gtest/ucp/test_ucp_rma.cc Resolved
@svc-nvidia-pr-review

Copy link
Copy Markdown

Residual coverage gap: the IOV rewind branch of ucp_proto_put_offload_bcopy_reset is exercised but not asserted — the test checks UCP_PROTO_SELECT_OP_FLAG_RESUME only for the contig variant, so the "offload never resumes" property is unverified for IOV.

Residual coverage gap: UCP_INSTANTIATE_TEST_CASE_TLS(..., shm, ...) will almost certainly hit UCS_TEST_SKIP_R("request was not partially sent") for put_offload_bcopy, since the shm RMA transports have no pending queue (cf. skip_no_pending_rma() in test_ucp_request.cc); real coverage there comes only from put_am_bcopy.

@svc-ucx

svc-ucx commented Nov 12, 2026

Copy link
Copy Markdown

🤖 CI Triage Agent — UCX PR · commit 090c2612

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=144653'}) → [fetch_azure_logs ERROR: no failed job found in timeline for build 144653]
  • fetch_jenkins_stages({'job': 'UCX PR', 'build': 144653}) → [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=144653', but this deployment is configured for 'https://nbuprod.blsm.nvidia.com/nb
  • fetch_azure_logs({'build_url': 'https://dev.azure.com/ucfconsort/ucx/_build/results?buildId=144653'}) → [fetch_azure_logs ERROR: no failed job found in timeline for build 144653]
  • fetch_jenkins_logs({'job': 'UCX PR', 'build': 144653}) → [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=144653', 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=144653&view=logs'}) → [fetch_azure_logs ERROR: no failed job found in timeline for build 144653]
  • fetch_azure_logs({'build_url': 'https://dev.azure.com/ucfconsort/0b36e3f0-8ab9-4a48-b68b-[REDACTED:Hex High Entropy String]/_build/results?buildId=144653', 'job_id': '00000000-0000-0000-0000-000000000000'}) → [fetch_azure_logs ERROR: no failed job found in timeline for build 144653]

🛡️ This comment had 1 potential secret(s) redacted (Hex High Entropy String). See request_id ab156462-1659-4d22-b7cc-ee33c7a67940 in the triage console for the audit trail.

Let put/offload/bcopy resume a restarted request like put/am/bcopy, so an
IOV request resumes in both protocols instead of being rewound by one.
Share their reset, which still skips the sent data of a contig request.

Drop the resume check in the RMA rendezvous probes, since no contig
request is resumed anymore. In the test, take the async lock before
checking the request, and check the resume flag for IOV requests too.
@svc-nvidia-pr-review

Copy link
Copy Markdown

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

Comment thread src/ucp/rma/put_offload.c Resolved
@svc-nvidia-pr-review

Copy link
Copy Markdown

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

Comment thread src/ucp/rma/rma_send.c Resolved

test_ucp_rma_restart()
{
modify_config("PROTO_REQUEST_RESET", "y");

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: pls skip when !is_proto_enabled() - ucp_put_nbx() returns UCS_ERR_UNSUPPORTED with proto v1, so the first ASSERT_UCS_OK fails.

@svc-nvidia-pr-review

Copy link
Copy Markdown

Residual coverage gap (unchanged from the previous revision): put/offload/bcopy on shm will skip via "request was not partially sent", so that instantiation only really exercises put_am_bcopy.

@svc-ucx

svc-ucx commented Nov 13, 2026

Copy link
Copy Markdown

🤖 CI Triage Agent — UCX PR (Tests roce on worker 1) · commit 521cbaac

TL;DR: ud/test_ucp_atomic32.fetch/2 hung forever (two 3‑minute "request did not complete on time" timeouts, then the teardown hung in close_all_eps and gtest aborted) because this PR's new request‑restart logic re‑selects a protocol with UCP_PROTO_SELECT_OP_FLAG_RESUME for any request whose datatype iterator is not at the beginning — and the SW AMO protocol advances the iterator while only packing the atomic value, so a restarted AMO fetch is misclassified as "partially sent" and never gets re-sent/completed. Fix: don't mark AMO (non‑resumable op) requests as partially sent on restart — rewind the dt_iter / clear UCP_REQUEST_FLAG_PROTO_AMO_PACKED in the AMO reset, or only set the RESUME flag for ops that actually support resume (PUT/GET/AM).

Full analysis

Summary: Azure job "roce on worker 1" (build 144992) failed: gtest ud/test_ucp_atomic32.fetch/2 <ud_v,cuda_copy,rocm_copy/guess> hung — the UCP AMO fetch request never completed, the subsequent host->host ADD request also timed out, and ucp_test_base::entity::close_all_eps() spun until the 18‑minute abort (make: *** [test] Aborted (core dumped)).

Root cause: Timeline evidence of a hang, not slowness: the test starts at 10:35:01 and the next line is at 10:38:02 (ucp_test.cc:310 UCX ERROR request 0x562df5845020 did not complete on time → test_ucp_atomic.cc:117: Error: Operation in progress), then another 3‑minute silence for the second request, then a 12‑minute silence inside close_all_eps(). So the very first atomic on that endpoint was accepted by UCX and then silently parked — no error, no abort.
The only code exercised here that this PR changes is the request restart path. ucp_proto_request_restart() (src/ucp/proto/proto_common.c:862‑890) now does:

if (!ucp_datatype_iter_is_begin(&req->send.state.dt_iter))
        select_param.op_id_flags |= UCP_PROTO_SELECT_OP_FLAG_RESUME;

On ud_v, the first AMO goes out while the lane is still a wireup proxy, so the request is queued and later replayed via ucp_wireup_replay_pending_request() → ucp_proto_request_restart() (src/ucp/wireup/wireup.c:2009‑2029). But ucp_proto_amo_sw_progress() (src/ucp/rma/amo_sw.c:389‑395) already advanced the dt_iter to the end with ucp_datatype_iter_next_pack() merely to copy the operand into req->send.amo.value — nothing was sent. The restarted AMO therefore looks "partially sent", is re‑selected with the RESUME flag, and the AMO protocols have no resume support (UCP_PROTO_COMMON_INIT_FLAG_RESUME is never set for amo/fetch/sw, and ucp_proto_request_bcopy_id_reset() neither rewinds the iterator nor clears UCP_REQUEST_FLAG_PROTO_AMO_PACKED), so the selection degrades to the always‑present "reconfig" stub (src/ucp/proto/proto_reconfig.c:79‑137) which just returns UCS_ERR_NO_RESOURCE and keeps the request queued on the AM lane forever — exactly the observed silent, permanent stall and the flush/close hang that follows.

Implicated commit: [REDACTED:Hex High Entropy String] — "UCP/RMA: Move the shared PUT bcopy reset to rma_send.c", Thomas Vegas (PR #12322 "UCP/RMA: Fix restart of partially sent PUT requests")

File: src/ucp/proto/proto_common.c:879‑882 (RESUME decision in ucp_proto_request_restart), with src/ucp/rma/amo_sw.c:389‑395 / src/ucp/rma/rma_send.c:126‑143 and src/ucp/wireup/wireup.c:2028 as the interacting sites

Suggested fix: Make the "partially sent" test reflect data actually transmitted, not iterator position:

  1. Preferred: give AMO protocols a reset that restores the request to a restartable state — e.g. add an amo reset in amo_sw.c that does ucp_datatype_iter_rewind(&req->send.state.dt_iter, UCP_DT_MASK_ALL) and clears UCP_REQUEST_FLAG_PROTO_AMO_PACKED (or simply don't advance the iterator when packing the AMO value, since the operand is copied into req->send.amo.value), mirroring what ucp_proto_put_bcopy_reset() now does for PUT bcopy ("make the unsent part a request of its own").
  2. Alternatively/additionally, gate the RESUME flag in ucp_proto_request_restart() on the operation id so it is only set for ops that can resume (PUT/GET/AM), avoiding the silent fall‑back to the reconfig stub.
  3. Hardening: make selection of the reconfig stub for an already‑started request log/abort instead of parking the request indefinitely, so this class of bug fails loudly instead of hanging CI for 18 minutes.

Related: PR #12322 (this PR); restart/failover groundwork in #12266 and #11940

🛡️ This comment had 1 potential secret(s) redacted (Hex High Entropy String). See request_id 35802c68-4593-441b-9b62-dfccfcf8343d in the triage console for the audit trail.

dmitrygx
dmitrygx previously approved these changes Nov 19, 2026

@dmitrygx dmitrygx 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.

good, apart small comment about moving new added function closer to similar ones

Comment thread src/ucp/rma/rma_send.c
} while (0)


ucs_status_t ucp_proto_put_bcopy_reset(ucp_request_t *req)

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.

minor: maybe move closer to

static ucs_status_t ucp_proto_put_offload_bcopy_progress(uct_pending_req_t *self)
.
so it won't require defining ucp_proto_put_bcopy_reset() in header file

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.

it's also the reset of put/am/bcopy in put_am.c, so it needs the declaration in rma.h wherever it is defined. it was in put_offload.c in 934fedd and moved to rma_send.c in 521cbaa so that put_am.c doesn't depend on the offload file; can move it back next to ucp_proto_put_offload_bcopy_progress() if you still prefer.

@tvegas1

tvegas1 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

ud/test_ucp_atomic32.fetch/2 hung forever ... because this PR's new request-restart logic re-selects a protocol with UCP_PROTO_SELECT_OP_FLAG_RESUME

not related to this PR: setting the resume flag in ucp_proto_request_restart() comes from 37352a2, and the PR doesn't change the proto, wireup or AMO code. a restarted AMO isn't reselected with resume either: ucp_proto_amo_sw_progress() packs the operand into req->send.amo.value through next_iter, so req->send.state.dt_iter stays at offset 0 and ucp_datatype_iter_is_begin() is true.

@svc-nvidia-pr-review

Copy link
Copy Markdown

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

Comment thread src/ucp/rma/rma_send.c
/* The offset counts posted fragments, whose data bcopy already copied out
* of the user buffer. Make the unsent part of a contig request a request
* of its own, so any protocol can restart it without resume support. */
if (dt_iter->dt_class == UCP_DATATYPE_CONTIG) {

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 the contig branch of ucp_proto_put_bcopy_reset: can we put this in a helper in datatype_iter.inl, next to ucp_datatype_iter_slice()? dt_iter internals are otherwise only written under src/ucp/dt, and the slice helper already does the same buffer + offset / length arithmetic.

@svc-nvidia-pr-review

Copy link
Copy Markdown

put/offload/zcopy and get/bcopy resets simply rewind the iterator (PUT/GET being idempotent); the offset-skipping approach here avoids re-sending the already-copied bytes. The code comment explains the mechanism but not this trade-off — worth a line in the PR description if it is not there already.

@svc-ucx

svc-ucx commented Nov 20, 2026

Copy link
Copy Markdown

🤖 CI Triage Agent — UCX PR (AddressSanitizer BlueField on worker 0) · commit aed18bd1

TL;DR: The ASAN gtest job failed on a LeakSanitizer report (68024 bytes in 17 allocations) — every leaked block belongs to the UCP worker/endpoint created by test_ucp_proto_mock_rcx_speed_change.rma_get, i.e. that test's endpoint was never fully torn down, which points at the request restart/resume path changed by PR #12322. Fix: make sure a partially-sent RMA request that is re-probed/restarted on an ep/rkey config change is completed and drops its ep reference, so ucp_ep_close can destroy the wireup lane.

Full analysis

Summary: make test (gtest, AddressSanitizer, BlueField/aarch64) exited with Error 1 because LeakSanitizer reported leaks: SUMMARY: AddressSanitizer: 68024 byte(s) leaked in 17 allocation(s).

Root cause: All leak stacks share the same origin — test_ucp_proto_mock_rcx_speed_change_rma_get_Test::init() → test_ucp_proto_mock::init()/connect() → ucp_worker_create / ucp_ep_create → ucp_wireup_init_lanes → ucp_wireup_ep_connect → uct_rc_mlx5_ep_t_new. The leaked objects are exactly the per-endpoint/per-iface UCT state of that test's sender:

  • uct_rc_mlx5_ep (320 B) plus its DEVX QP buffer (65536 B), devx_create_qp_common (56 B), DEVX obj (48 B);
  • the wireup proxy/stub ifaces (uct_stub_iface_open via ucp_wireup_ep_create, 832 B in 2 objects);
  • iface-level DEVX buffers: SRQ (uct_rc_mlx5_devx_init_rx_common), CQ buffer and dbrec page (uct_ib_mlx5_devx_create_cq, uct_ib_mlx5_add_page).

That combination means the UCP endpoint created in init() (specifically its wireup lane with the real rc_mlx5 UCT ep) was still alive at process exit — i.e. ucp_ep_close never completed/ucp_ep_destroy_internal never ran during ucp_test::cleanup() (entity::close_all_eps() gives up at a deadline and only does EXPECT_TRUE(m_close_ep_reqs.empty()), then entity::cleanup() drops the worker, leaking whatever the ep still held — test/gtest/ucp/ucp_test.cc:933-945, 1165-1168). The usual reason an ep close never completes is an outstanding send request still referencing the ep.

The leaking test is rcx_speed_change — the only mock test that mutates port speed mid-flight (set_port_speed()), forcing new ep/rkey configs and therefore re-selection/restart of in-flight RMA requests (test_port_speed, test/gtest/ucp/test_ucp_proto_mock.cc:4100-4149 on main; shifted to ~5026/5116 in the PR build). This is precisely the code path PR #12322 ("UCP/RMA: Fix restart of partially sent PUT requests", branch rndv_resume_probe) modifies, and the PR also grows test_ucp_proto_mock.cc by ~975 lines, so the failure is tied to this change rather than being a generic infra issue. Note the job log is truncated to the leak report, so the preceding gtest failure lines (e.g. "endpoints were not closed" / "request did not complete on time") are not visible; the leak signature itself is the evidence.

Implicated commit: [REDACTED:Hex High Entropy String] (PR #12322, branch rndv_resume_probe; author not shown in the log). Nearby related change on main: 6f2c2dd "UCP/GTEST: Fix expected rkey config count in port speed change test" (Alexey Rivkin).

File: test/gtest/ucp/test_ucp_proto_mock.cc:5116 (rcx_speed_change.rma_get in the PR build; :4142 on main) — leak is produced by the restart path reached from src/ucp/proto/proto_common.inl:99 (ucp_proto_request_restart_or_complete → ucp_proto_request_restart) and the RMA PUT/GET multi-lane resume logic touched by the PR.

Suggested fix:

  1. In the new restart/resume code, verify that a partially-sent request which is re-probed after an ep/rkey config change is either re-queued and eventually completed, or completed with an error — and that on restart it releases what it holds: ucp_proto_request_zcopy_clean() (dt_iter dereg), the uct_comp count, the rkey ref (UCP_REQUEST_FLAG_RKEY_INUSE) and the endpoint reference/pending-queue entry. A request leaked in the ep's pending queue keeps the lane alive and makes ucp_ep_close_nbx never complete, which is exactly what the leak set shows.
  2. Reproduce locally with the ASAN build: UCX_PROTO_ENABLE=y ASAN_OPTIONS=detect_leaks=1 ./test/gtest/gtest --gtest_filter='*rcx_speed_change*' and check for the gtest message "endpoints were not closed" / request %p did not complete on time preceding the leak dump.
  3. If the restart is intentionally asynchronous, add an explicit completion/cancel of the old (partially sent) attempt before switching protocols, and assert ucp_ep refcount is back to its baseline at ucp_ep_close.

Related: PR #12322 (the failing change). No existing issue found for this leak signature.

🛡️ This comment had 1 potential secret(s) redacted (Hex High Entropy String). See request_id 7a6f9b46-a3e2-40f1-9153-e014e53eff15 in the triage console for the audit trail.

@tvegas1
tvegas1 enabled auto-merge (squash) November 23, 2026 12:34
@tvegas1
tvegas1 merged commit a09542b into openucx:master Nov 23, 2026
190 checks passed
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.

4 participants