Skip to content

[MUSA]Feat: musa support - #12107

Open
superleo wants to merge 39 commits into
openucx:masterfrom
superleo:feat/musa_support
Open

superleo wants to merge 39 commits into
openucx:masterfrom
superleo:feat/musa_support

Conversation

@superleo

@superleo superleo commented Oct 16, 2026 •

Copy link
Copy Markdown

What?

Add initial MUSA support to UCX .

The series includes:

  • a stable UCS_MEMORY_TYPE_MUSA memory type and musa name;
  • MUSA capability reporting through UCP context queries;
  • UCM hooks for musaMalloc and musaFree;
  • MUSA memory detection and registration in the UCT MUSA MD;
  • MUSA host registration and DMA-BUF capability reporting;
  • PCI BDF and UCX system-device topology mapping;
  • the musa_copy staging transport for local MUSA/host transfers;
  • IB peer-memory and DMA-BUF integration for direct GPU RDMA;
  • default musa transport selection through musa_copy;
  • build, configure, and focused contract tests.

The MUSA component no longer exposes a zero-capability stub TL. The copy path is provided by musa_copy, while large-message direct RDMA remains selected through the IB transports when available.

Why?

NIXL requires UCX to distinguish MUSA device allocations from host memory and to select a real transport path for MUSA buffers. Without this support, MUSA allocations can be classified as host memory, the wrong protocol can be
selected, or the worker can select a zero-capability MUSA interface and abort.

This series provides the minimum UCX-side support needed to identify MUSA memory and use either local staging or the existing IB direct-RDMA path.

How?

The implementation is intentionally limited to ordinary MUSA device allocations.

Supported paths:

  • MUSA device memory detection;
  • MUSA device and host memory registration;
  • MUSA/host staging through musa_copy;
  • IB peer-memory or DMA-BUF registration when the platform supports it;
  • UCP PUT/GET combinations covered by the provider contract.

Managed memory, VMM allocations, IPC-specific paths, heterogeneous devices, and provider-specific direct-RDMA extensions are not claimed as complete features.

Test:

The MUSA test bed /S5000 demonstrated:

  • single-node RMA matrix: 8/8 passed;
  • two-node RMA matrix: 7/7 passed;
  • D-D, H-D, D-H, and H-H PUT/GET coverage;
  • cross-process and cross-node rkey exchange;
  • direct-RDMA evidence from mt_peermem counters;
  • DMA-BUF export evidence;
  • byte-level validation and matching FNV-1a checksums.

@svc-ucx

svc-ucx commented Oct 16, 2026

Copy link
Copy Markdown

🤖 CI Triage Agent — UCX PR (Codestyle AUTHORS file update check) · commit 7ef53c12

TL;DR: The "AUTHORS file check" failed because PR #12107's author (superleo <xlei.boll@gmail.com>) is not listed in the AUTHORS file; the fix is to run ./contrib/authors_update.sh locally and commit the resulting one-line AUTHORS update.

Full analysis

Summary: Codestyle stage "AUTHORS file check" exited with code 1 — git diff --exit-code detected an uncommitted modification to AUTHORS after contrib/authors_update.sh ran.

Root cause: The pipeline step computes base_revision=[REDACTED:Hex High Entropy String], head_revision=[REDACTED:Hex High Entropy String] and runs ./contrib/authors_update.sh <base>..<head>, then asserts the working tree is clean. The script found a commit author not present in AUTHORS:

Names:
++ superleo <xlei.boll@gmail.com>

and inserted superleo <xlei.boll@gmail.com> after line 150 (shasson5 ...), so git diff --exit-code reported the diff and returned 1. This is not a flake or infra issue — it's the intended guard (contrib/authors_update.sh:36-38 adds the entry when neither the email nor the name matches an existing line; AUTHORS:148-153 confirms no superleo/xlei.boll entry exists).

Implicated commit: [REDACTED:Hex High Entropy String] (PR #12107, branch feat/musa_support, author superleo <xlei.boll@gmail.com>) — a missing AUTHORS entry, not a regression in CI tooling.

File: AUTHORS:150 (insertion point) — check driven by contrib/authors_update.sh:18-46

Suggested fix: On the feat/musa_support branch, run:

./contrib/authors_update.sh <upstream-base>..HEAD
git add AUTHORS && git commit --amend --no-edit   # or a separate "AUTHORS: add superleo" commit

which adds superleo <xlei.boll@gmail.com> to the alphabetical lower-case block of AUTHORS, then force-push. Note the script matches names case-insensitively and by substring, so if the contributor is already listed under a different display name, instead make the commit author identity consistent with the existing AUTHORS entry (e.g. via git commit --amend --author=...) rather than adding a duplicate line.

Related: PR #12107 (openucx/ucx); no existing issue found for this failure signature — it is a per-PR onboarding step, expected for every first-time contributor.

🛡️ This comment had 1 potential secret(s) redacted (Hex High Entropy String). See request_id abcc4e10-a0e4-40d3-84d2-c6d5fd660c79 in the triage console for the audit trail.

@superleo

Copy link
Copy Markdown
Author

hi @yosefe @shamisp @tonycurtis @brminich @hoopoepg This patch contains three logical areas: MUSA memory type/UCM integration, UCT MUSA and musa_copy support, and IB direct-RDMA/DMA-BUF integration.

Would you prefer to review this as one dependent commit series, or should we split it into three PRs before review?

@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

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

Comment thread src/ucm/musa/musamem.c Resolved
Comment thread src/uct/musa/base/musa_base.c Resolved
Comment thread src/uct/musa/base/musa_base.c Resolved
Comment thread src/uct/musa/base/musa_base.c Resolved
Comment thread src/uct/musa/base/musa_base.c Resolved
Comment thread test/gtest/uct/test_musa_contract.cc Resolved
Comment thread test/gtest/Makefile.am Resolved
Comment thread src/ucm/Makefile.am Resolved
Comment thread config/m4/musa.m4 Resolved
@svc-nvidia-pr-review

Copy link
Copy Markdown

This is ~1.8k added lines in a single PR; pls split it (e.g. memory type + ucm hooks, uct base/md, musa_copy transport + tests) so each part can be reviewed on its own.

How is the MUSA build validated? There is no buildlib/tools/builds.sh entry or CI job that configures --with-musa, so nothing compiles this code (ZE added a dedicated build mode for exactly this).

Mode: REQUEST_CHANGES

Residual coverage gaps:

  • mem_buffer (test/gtest/common/mem_buffer.cc) has no MUSA support, so no UCT p2p (uct_p2p_rma) or UCP mem-type test ever exercises musa_copy put/get; the only new functional tests are the UCM hook test and a managed-memory rejection test.
  • musa is not in UCT_MD_INSTANTIATE_TEST_CASE, so the generic test_md suite (reg/dereg, mem_query, dmabuf) does not run against the new MD.
  • UCP_MEM_IS_GPU/UCP_DEVICE_MEM_TYPES in src/ucp/core/ucp_mm.h and the ucp_rndv_frag_default_* tables were not extended for UCS_MEMORY_TYPE_MUSA, so rendezvous pipeline selection treats MUSA as non-GPU memory — worth confirming that is intentional for this first version.

@superleo

Copy link
Copy Markdown
Author

Tested provider capabilities

Memory-type and pointer contract

The integration test confirmed that:

  • MUSA device allocations are recognized as MUSA memory rather than host memory when allocated after ucp_init/UCX memory hooks are installed;
  • host pointers cannot be registered as VRAM;
  • device pointers cannot be registered as DRAM;
  • invalid device IDs and invalid device pointers are rejected;
  • zero-length, overflowed and out-of-range descriptors are rejected;
  • subranges and multiple descriptors are handled correctly;
  • descriptor boundaries may be deliberately unaligned without corrupting adjacent ranges.

A critical implementation contract was identified: on a memtype-cache miss, the current UCX path assumes host memory instead of taking the MUSA detection slow path. Consequently, MUSA buffers must be allocated after the UCX context and its memory hooks exist. This is now enforced by the NIXL driver ordering and documented for integrators.

MUSA transport and data correctness

The provider passed 17/17 hardware scenarios covering:

  • host-host, device-device, host-device and device-host;
  • 1 B, 4 KiB, 64 KiB, 1 MiB and 64 MiB transfers;
  • repeated transfer and registration cycles;
  • eight and 64 descriptors;
  • multiple visible devices and non-default device IDs;
  • WRITE plus active-message notification;
  • READ-back verification;
  • ordered deregistration and remote metadata invalidation;
  • caller and background progress modes;
  • bounded peer-exit failure.

The transfer data uses non-zero patterns that encode peer, operation, descriptor index and offset. Both receiver-side notification validation and sender-side READ-back validation are byte-exact.

Progress and error handling

The caller-progress path was exercised without a backend progress thread. The target side periodically calls getNotifs() while waiting for the sender’s completion marker, and the request owner polls getXferStatus(). This demonstrates the intended UCX worker-progress contract when progress is owned by the caller.

Peer-exit testing produced a bounded failure rather than an infinite wait. The NIXL layer exposes this as NIXL_ERR_REMOTE_DISCONNECT; the existing explicit restore test validates the required invalidate-and-reload workflow.

Resource behavior

A 1,000-cycle register/transfer/release/deregister test completed with stable device memory and a process RSS plateau. The observed RSS plateau is attributed to UCX pools rather than an unbounded leak, but it is material for multi-process deployments and should be included in capacity planning.

@svc-nvidia-pr-review

Copy link
Copy Markdown

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

Comment thread src/uct/musa/base/musa_base.c Resolved
Comment thread src/uct/musa/base/musa_base.c Resolved
Comment thread src/uct/musa/base/musa_base.c Resolved
Comment thread src/uct/musa/musa_copy/musa_copy_ep.c Resolved
Comment thread src/uct/musa/musa_copy/musa_copy_md.c Resolved
@svc-nvidia-pr-review

Copy link
Copy Markdown

Suggested mode: REQUEST_CHANGES, empty review body (the two blockers are build breaks).

Checked and not reported: ucm_musamem_scan_regions_cb() prot/path condition looks inverted at first glance, but it matches cudamem.c/rocmmem.c exactly (regions with no access permissions are intentionally included) — not a bug.

Checked and not reported: Appending UCS_MEMORY_TYPE_MUSA before UCS_MEMORY_TYPE_LAST keeps all existing on-wire values (same as the gaudi addition); UCS_STATIC_ASSERT(UCS_MEMORY_TYPE_LAST <= 255) still holds.

Checked and not reported: Duplicate UCX_CHECK_MUSA/AM_CONDITIONAL([HAVE_MUSA]) expansion from both src/ucm/musa and src/uct/musa mirrors cuda.m4; mem_buffer.cc switches all have default:, so the new memory type does not break the gtest build.

Checked and not reported: Repeated uct_ib_check_gpudirect_driver() calls for MUSA are harmless (it returns early once the bit is set).

Residual coverage gap: mem_buffer still has no MUSA allocator, so uct_p2p_rma/UCP mem-type tests never exercise musa_copy put/get; musa is also absent from UCT_MD_INSTANTIATE_TEST_CASE, so generic test_md (reg/dereg, mem_query, dmabuf) does not run against the new MD.

Residual coverage gap: uct_musa_base_has_dmabuf() is compile-time only — there is no runtime/driver check and no DMABUF=try style config knob like cuda_copy, so dmabuf_mem_types may advertise support that always fails at runtime.

@svc-ucx

svc-ucx commented Oct 29, 2026

Copy link
Copy Markdown

🤖 CI Triage Agent — UCX PR (AddressSanitizer roce on worker 0) · commit 171799b8

TL;DR: The ASan "roce on worker 0" job did not fail on any test or compile error — the Azure agent was shut down mid-build ("The agent has received a shutdown signal"), cancelling the ./contrib/test_jenkins.sh step while it was still compiling gtest objects; just re-run the pipeline.

Full analysis

Summary: Build 141575, job "AddressSanitizer roce on worker 0", was cancelled by the CI agent during the gtest compilation phase of ./contrib/test_jenkins.sh; no UCX test ever ran.

Root cause: Infrastructure, not code. The log shows uninterrupted compiler activity from 13:16:14 through 13:30:43 (largest gap between consecutive lines is only ~10 s, e.g. ucp/test_ucp_wireup.cc at 13:30:19 → ucp/test_ucp_request.cc at 13:30:23 → shutdown at 13:30:33), so the job was making steady progress and was not hung. At 13:30:33 Azure DevOps logged ##[error]The agent has received a shutdown signal. This can happen when the agent service is stopped, or a manually started agent is canceled., immediately followed by ##[error]The Operation will be canceled... and ##[error]The operation was canceled. The last application work in flight was g++ ... -o ucp/gtest-test_ucp_wakeup.o ucp/test_ucp_wakeup.cc — a normal compile, with zero warnings or errors anywhere in the captured log (-Werror builds were all succeeding, every mv -f ... .Tpo ... .Po completed cleanly). Typical triggers for this message are the agent VM being reclaimed/preempted/restarted, or the run being superseded (e.g. a new push to feat/musa_support auto-cancelling the previous PR run via a poll trigger).

Implicated commit: none — commit [REDACTED:Hex High Entropy String] (PR #12107) is not implicated; the failure is agent-side cancellation.

File: n/a (last compiled unit: test/gtest/ucp/test_ucp_wakeup.cc; step: contrib/test_jenkins.sh)

Suggested fix: Re-run the "AddressSanitizer roce on worker 0" job — no code change is warranted. If it reproduces on this PR, check agent-pool health/preemption for that worker rather than UCX code. Secondary observation (not the failure, but it widens the window for such cancellations): the ASan configuration spends ~14.5 minutes of the job purely compiling test/gtest objects at -O3 -g -fsanitize=address; enabling ccache for the ASan row or lowering optimization to -O1 for gtest sources would shorten the exposure and speed recovery.

Related: contrib/test_jenkins.sh recent changes 217e877 (Alexey Rivkin, AZP/TESTS: do not run test_rma_cuda/test_ucp_rkey_destroy) and 390a30e (Alexey Rivkin, AZP/TESTS: build once per GPU test row and share the tree with the workers) — reviewed and unrelated to this cancellation. No matching issue/PR found for the agent shutdown signature.

🛡️ This comment had 1 potential secret(s) redacted (Hex High Entropy String). See request_id 5ea41712-a5c2-4fef-b0e5-bf4128967e39 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 src/ucm/musa/musamem.c Resolved
Comment thread src/ucm/musa/musamem.c Resolved
Comment thread src/uct/musa/base/musa_base.c Resolved
Comment thread src/uct/musa/base/musa_base.c Resolved
@iyastreb

Copy link
Copy Markdown
Contributor

Do you have CLA signed?

@superleo

Copy link
Copy Markdown
Author

Do you have CLA signed?

hi @iyastreb , the contributor guidance currently points to openucx.org/license, but the URL is not reachable now.

@svc-nvidia-pr-review

Copy link
Copy Markdown

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

Comment thread src/uct/musa/base/musa_base.c Resolved
Comment thread src/ucm/musa/musamem.c Resolved
Comment thread src/uct/musa/base/musa_base.c Resolved
Comment thread src/uct/musa/base/musa_base.c Resolved
Comment thread src/ucm/musa/musamem.c
ucm_reloc_patch_t *patch;
ucs_status_t status = UCS_OK;

if (!(events & (UCM_EVENT_MEM_TYPE_ALLOC | UCM_EVENT_MEM_TYPE_FREE))) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hooks cannot be disabled: cudamem.c/rocmmem.c gate installation on ucm_global_opts.cuda_hook_modes/rocm_hook_modes (and support bistro); the MUSA installer ignores configuration entirely. Can we gate this on a hook-mode option so the MUSA hooks can be disabled by configuration?

@svc-nvidia-pr-review

Copy link
Copy Markdown

Residual coverage gap (new): nothing exercises the multi-GPU path — uct_musa_base_copy() returns UCS_ERR_UNSUPPORTED for device-to-device across different devices while musa_copy caps itself to one iface, so a cross-GPU copy surfaces as an error from put_zcopy rather than a fallback; worth confirming that is intended.

@svc-nvidia-pr-review

Copy link
Copy Markdown

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

Comment thread config/m4/musa.m4 Resolved
Comment thread src/uct/musa/base/musa_base.c Resolved
return UCS_ERR_UNSUPPORTED;
}

return uct_musa_base_query_pointer(address, length, info);

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 a memtype-cache miss (the usual case for plain host buffers — the cache only tracks GPU allocations) every copy falls through to uct_musa_base_query_pointer(), so each put/get costs two musaPointerGetAttributes() plus muMemGetAddressRange()/musaGetDevice()/musaSetDevice(). cuda_copy treats UCS_ERR_NO_ELEM as host without any runtime call (uct_cuda_copy_get_mem_type()); can we do the same here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@svc-nvidia-pr-review This was implemented as suggested, but a later safety review found that a memtype-cache miss must not be classified as host memory in this TL: unlike cuda_copy, whose every copy is issued through the driver, the host-to-host path here is a CPU memcpy(), so a device pointer misclassified as host would crash the process when the hooks are disabled or bypassed. The upcoming change keeps the essence of this suggestion — the miss path no longer calls musaSetDevice()/muMemGetAddressRange(), and a cache hit still short-circuits — but adds one lightweight muPointerGetAttribute()-based classification on a miss. See the blocking thread on the same function for details.

Comment thread src/uct/musa/base/musa_base.c Resolved
Comment thread src/ucm/musa/musamem.c Resolved
Comment thread src/uct/musa/configure.m4 Resolved
Comment thread src/uct/musa/musa_copy/musa_copy_md.c Resolved
@svc-nvidia-pr-review

Copy link
Copy Markdown

Residual coverage gap: nothing exercises uct_musa_base_mem_query()'s dmabuf path or uct_musa_base_copy() itself; the two new UCT tests only cover pure helpers (musa_utils.h) and managed-memory rejection.

Residual coverage gap: uct_musa_base_get_sys_dev() is re-queried per mem_query (no device→sys_dev cache like uct_cuda_get_sys_dev()), and no test covers the musaDeviceGetPCIBusId → topo mapping on real hardware.

@svc-nvidia-pr-review

Copy link
Copy Markdown

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

Comment thread src/ucm/musa/musamem.c Resolved
Comment thread src/ucm/musa/musamem.c Resolved
Comment thread src/uct/musa/base/musa_base.c Resolved
return UCS_ERR_UNSUPPORTED;
}

return uct_musa_base_query_pointer(address, length, info);

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 a memtype-cache miss (UCS_ERR_NO_ELEM, i.e. every plain host buffer) this falls back to the full pointer query — musaPointerGetAttributes + musaGetDevice/musaSetDevice/restore + muMemGetAddressRange — on each put/get. uct_cuda_copy_get_mem_type() assumes host memory for NO_ELEM and issues the copy directly; can we do the same to keep the data path free of driver calls?

Comment thread src/uct/musa/Makefile.am Resolved
Comment thread src/uct/musa/base/musa_base.c Resolved
@svc-nvidia-pr-review

Copy link
Copy Markdown

Residual coverage gap: nothing exercises uct_musa_copy_iface_t creation/iface_query/is_reachable_v2 or the musa%u device-name parsing path; the iface is only reachable through a real UCP run, and musa_copy is absent from every p2p/UCP mem-type suite.

Residual coverage gap: uct_musa_base_copy()'s musaSetDevice/restore logic is untested, including the case where musaGetDevice() fails and the thread's current device is left changed.

@svc-ucx

svc-ucx commented Oct 30, 2026

Copy link
Copy Markdown

🤖 CI Triage Agent — UCX PR (Tests new on worker 0) · commit 765171ed

TL;DR: The gtest binary aborted on a debug assertion in the registration cache — rcache.c:396 Assertion '!(region->flags & UCS_RCACHE_REGION_FLAG_PGTABLE)' failed — hit from ucp_mem_unmap() in tcp/test_ucp_rma.put_nonblocking/2 <...user_memh>, i.e. a parent rcache region's refcount reached 0 while the page-table reference was still held (a lost/extra reference, not a MUSA problem). Fix is in the rcache/user-memh refcount accounting (ucs_rcache_region_put_unsafe / ucs_rcache_lookup_unsafe update refcount non-atomically while other paths use atomics); re-run to confirm it's the known-flaky master path before touching the PR.

Full analysis

Summary: Azure job "Tests new on worker 0" (build 141739) failed with make: *** [Makefile:5063: test] Aborted (core dumped) after the gtest tcp/test_ucp_rma.put_nonblocking/2 <tcp,cuda_copy,rocm_copy/user_memh> tripped a UCS assertion during ucp_mem_unmap().

Root cause: Evidence from the log backtrace:

  • ucs_mem_region_destroy_internal() – src/ucs/memory/rcache.c:396
  • ← ucs_rcache_region_put_unsafe() – src/ucs/memory/rcache.inl:128
  • ← ucp_memh_put_rcache() – src/ucp/core/ucp_mm.c:441
  • ← ucp_memh_cleanup() / ucp_mem_unmap() – src/ucp/core/ucp_mm.c:470, 1291
  • ← test_ucp_memheap::test_xfer() – test/gtest/ucp/test_ucp_memheap.cc:120

A cached region is created with region->refcount = 2; /* Page-table + user */ (rcache.c:1028). ucs_rcache_region_put_unsafe() destroys the region the moment the refcount hits 0 and asserts the region is no longer in the page table. The assert firing means the user-memh's parent rcache region dropped to refcount 0 while still inserted in the page table — i.e. one reference was lost (a missed hold/get or an extra put) on the ucp_mem_map()/user-memh path. A concrete defect consistent with this symptom: the "unsafe" inlines used by UCP mutate the refcount non-atomically — region->refcount++ in ucs_rcache_lookup_unsafe() (rcache.inl:103, executed under a shared read lock) and --region->refcount in ucs_rcache_region_put_unsafe() (rcache.inl:127) — whereas the invalidate/evict/hold paths use ucs_atomic_add32/ucs_atomic_fsub32 (rcache.c:450, 1055). A lost update between those produces exactly "refcount 0 while PGTABLE flag set".

This is not plausibly caused by the PR under test: the failing case is pure host memory over TCP with SW RMA emulation; the MUSA additions in this branch are an extra UCS_MEMORY_TYPE_MUSA enum/TL that is not built or exercised here (src/ucs/memory/memory_type.h:49, memory_type.c:28). The merge base does contain a fresh change to exactly this code path: cfe1cf5c "UCP/RMA: Add AM-based software emulation protocol for SGL put (#11943)" (Michal Shalev, 2026-10-28, two days before this run), which touched src/ucp/rma/put_am.c and test/gtest/ucp/test_ucp_rma.cc — the TCP put emulation and the user_memh RMA variants.

Implicated commit: unknown (not the PR head 765171e); suspect in merge base: cfe1cf5c — "UCP/RMA: Add AM-based software emulation protocol for SGL put (#11943)", Michal Shalev

File: src/ucs/memory/rcache.c:396 (assert), with the refcount handling at src/ucs/memory/rcache.inl:103,127 and src/ucp/core/ucp_mm.c:441,470 (ucp_memh_put_rcache / ucp_memh_cleanup)

Suggested fix:

  1. Re-run the job to establish whether it reproduces; if it does not, it is master flakiness and should not block PR [MUSA]Feat: musa support #12107.
  2. Make the rcache refcount updates uniform: use ucs_atomic_add32() in ucs_rcache_lookup_unsafe() and ucs_atomic_fsub32() in ucs_rcache_region_put_unsafe() (src/ucs/memory/rcache.inl:103,127) so they cannot race with the atomic hold/put_internal paths.
  3. Add a diagnostic assert in ucp_memh_put_rcache() (ucp_mm.c:441) that the region is still page-table resident and refcount > 1 before the put, so the imbalance is caught at the offending put rather than at destroy time.
  4. To reproduce locally: UCX_TLS=tcp ./gtest --gtest_filter='tcp/test_ucp_rma.put_nonblocking/2' with UCX_LOG_LEVEL=trace (rcache "hold/put/destroy" traces identify the unbalanced reference).

Related: PR #12107 (branch under test, feat/musa_support); suspicious merge-base change PR #11943; similar rcache-refcount discussions in PR #11958 and PR #12150.

@svc-nvidia-pr-review

Copy link
Copy Markdown

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

Comment thread src/ucm/musa/musamem.c Resolved
Comment thread src/uct/musa/musa_copy/musa_copy_ep.c Resolved
Comment thread src/uct/musa/base/musa_base.c Resolved
Comment thread src/uct/musa/base/musa_base.c Resolved
Comment thread src/uct/musa/base/musa_base.c Resolved
@svc-nvidia-pr-review

Copy link
Copy Markdown

Coverage gap: nothing exercises the flush path with a completion (uct_musa_copy_iface_flush(comp != NULL)) or the event mpool/musaEventQuery progress loop; musa_copy is absent from UCT_TEST_TLS, so test_flush.cc/test_zcopy_comp.cc never run against it.

test/gtest/uct/test_musa_copy.cc

Coverage gap: test_musa_copy.cc allocates UCS_MEMORY_TYPE_MUSA through mapped_buffer, which hits the default: arm of mem_buffer::allocate() and raises UCS_TEST_SKIP_R, so the one functional transport test can never execute even on MUSA hardware.

@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

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

* "domain:bus:slot.function" string (no per-attribute query). */
err = musaDeviceGetPCIBusId(pci_bus_id, sizeof(pci_bus_id), (int)device);
if (err != musaSuccess) {
ucs_debug("musaDeviceGetPCIBusId(device=%u) failed: %s", device,

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 use the NULL-safe helper added just above, so a runtime returning NULL does not reach the format string.

Suggested change
ucs_debug("musaDeviceGetPCIBusId(device=%u) failed: %s", device,
ucs_debug("musaDeviceGetPCIBusId(device=%u) failed: %s", device,
uct_musa_error_string(err));

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed.Current code uses:uct_musa_error_string(err) instead of calling musaGetErrorString(err) directly

return;
}

if (uct_musa_base_status(musaEventDestroy(event_desc->event),

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: double warning - uct_musa_base_status() already prints "musaEventDestroy failed: " at warn level, so this adds a second line for one event. pls fold the device into the operation string instead (same pattern at the musaSetDevice/musaStreamDestroy calls in the iface cleanup).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

"musaGetDevice");
}

ucs_status_t uct_musa_base_set_device(int device)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

why not switch the device with muCtxPushCurrent()/muCtxPopCurrent() and issue the copies with the driver API, like cuda_copy does? The data path here uses musaSetDevice()/musaMemcpyAsync()/musaStreamSynchronize(), which consume and overwrite the application's runtime last-error - exactly the property uct_musa_md_mem_reg() and uct_musa_base_query_copy_pointer() take care to preserve.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@svc-nvidia-pr-review . We kept the runtime API here: the streams (musaStreamCreateWithFlags) and buffers (musaMalloc/musaMallocManaged) are runtime-created, and muCtxPushCurrent() does not change the runtime's current device, so runtime async copies still need musaSetDevice(). Moving to driver copies would require primary-context push/pop infrastructure, driver streams, and reworking host registration in musa_copy_md — a cross-module change we'd rather do as a separate follow-up.

On last-error: it is only affected on failure, and the error is returned to the caller. On success it is untouched, which we now check in test_musa_copy.data_path_preserves_runtime_error (poison last-error, then put_zcopy + flush).

will follow up with the driver-API variant if that's preferred.

@svc-nvidia-pr-review

Copy link
Copy Markdown

Residual coverage gap: the runtime-API data path is only covered by test_musa_copy_md.host_registration_preserves_runtime_error, which exercises mem_reg/detect_memory_type; nothing checks that a put_zcopy/flush sequence leaves musaPeekAtLastError() untouched.

Residual coverage gap: uct_musa_copy_event_desc_cleanup() returns without destroying the event if musaSetDevice() fails, leaking a MUSA event; this teardown-with-failing-runtime path is not simulated by any test.

Residual coverage gap: musa_hooks.cc relies on the MUSA driver exposing device allocations as /dev/mtgpu mappings in /proc/self/maps for test_existing_musaMalloc_is_reported; that assumption is only verifiable on real hardware.

Signed-off-by: superleo <xlei.boll@gmail.com>
@svc-nvidia-pr-review

Copy link
Copy Markdown

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

Comment thread src/ucs/config/ucm_opts.c Outdated

{"MUSA_HOOK_MODE",
#if UCM_BISTRO_HOOKS
UCM_MMAP_HOOK_BISTRO_STR "," UCM_MMAP_HOOK_RELOC_STR,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

why is the default both bistro and reloc, unlike CUDA_HOOK_MODE?
ucm_musamem_install() installs bistro on the driver table and reloc on the runtime table, so a single musaMalloc() looks like it would dispatch two MEM_TYPE_ALLOC events - one from the runtime hook and one from the muMemAlloc* call the runtime makes internally (rocm can default to both because both modes hook the same single table).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

Comment thread src/uct/musa/base/musa_base.c Outdated
unsigned i;

uct_musa_base_sys_dev_status =
uct_musa_base_get_device_count(&uct_musa_base_num_devices);

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 pass a local variable here; uct_musa_base_get_device_count() already writes uct_musa_base_num_devices into the out-param, so this assigns the global to itself.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

@svc-nvidia-pr-review

Copy link
Copy Markdown

Residual coverage gap: nothing exercises the hook-mode combination above - musa_hooks.cc only checks the last recorded event per type, so a duplicate MEM_TYPE_ALLOC/FREE per allocation would pass unnoticed even on MUSA hardware.

Residual coverage gap: HAVE_MUSA_MEM_ALLOC_V2 is referenced only by musamem.c hook definitions, which do not need the SDK declarations; no test or build job covers the "older SDK" path where that define is absent.

Signed-off-by: superleo <xlei.boll@gmail.com>
@svc-nvidia-pr-review

Copy link
Copy Markdown

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

Comment thread src/uct/musa/musa_copy/musa_copy_md.c Resolved
Comment thread src/ucs/config/ucm_opts.c
@@ -104,6 +104,21 @@ static ucs_config_field_t ucm_global_config_table[] = {
,ucs_offsetof(ucm_global_config_t, rocm_hook_modes),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

New MUSA_HOOK_MODE entry with UCM_MMAP_HOOK_BISTRO_STR default: ucm_musa_runtime_funcs is installed only with UCM_MMAP_HOOK_RELOC, and ucm_install_hooks() returns early when the mode is not in the bitmap, so with this default the runtime hooks (musaMalloc/musaFree/...) are never installed. rocm, whose installer also uses both modes, defaults to bistro,reloc. Is bistro on the driver symbols enough to catch runtime allocations here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

Comment thread config/m4/musa.m4
AC_SUBST([MUSA_ROOT])
], [
AS_IF([test "x$with_musa" != "xguess"], [
AC_MSG_ERROR([MUSA support was requested but MUSA headers and libraries were not found])

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: when the headers are found but one mandatory symbol is missing, the big mandatory AC_LINK_IFELSE fails without printing anything and this message still says headers and libraries were not found. pls add AC_MSG_CHECKING/AC_MSG_RESULT around that check so the real cause is visible.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

@svc-nvidia-pr-review

Copy link
Copy Markdown

Residual coverage gap: mem_buffer::get_device()/set_device()/get_device_count() use #if HAVE_CUDA ... #elif HAVE_MUSA, and scoped_cuda_device/check_and_restore_device_context() are CUDA-only, so in a CUDA+MUSA build the new completions_run_on_application_device test switches the MUSA device without any scoped restore or failure report.

Residual coverage gap: nothing in buildlib/tools/builds.sh or contrib/test_jenkins.sh configures --with-musa, so neither the new sources nor the newly instantiated UCT_TEST_GPU_MEM_TYPE_TLS suites compile or run in CI.

Residual coverage gap: test_md.mem_type_detect_mds now asserts exact alloc_length/base_address for UCS_MEMORY_TYPE_MUSA, and test_musa_copy_md.mem_query_preserves_allocation_for_overrun assumes muMemGetAddressRange() returns exactly the requested size; neither assumption is validated anywhere.

@svc-ucx

svc-ucx commented Nov 22, 2026

Copy link
Copy Markdown

🤖 CI Triage Agent — UCX PR (Codestyle commit title) · commit 5bdb26b6

TL;DR: The "Codestyle (commit title)" check failed because PR #12107 contains a commit titled Update src/uct/musa/musa_copy/musa_copy_md.c (a GitHub web-editor default message) which lacks the required MODULE: Description prefix; reword/squash that commit and force-push.

Full analysis

Summary: Azure Pipelines build 146850, job "commit title", exited with code 1 after the commit-title linter rejected one of the 37 commits in the PR.

Summary of evidence: The Bash step output lists every commit title; all 36 others pass (Good commit title: 'MUSA: ...'), and exactly one fails:

Bad commit title: 'Update src/uct/musa/musa_copy/musa_copy_md.c'
...
##[error]Bash exited with code '1'.

No build, hang, or timeout is involved — the step ran for ~0.2 s and failed deterministically on a title-format rule.

Root cause: UCX CI enforces the commit-title convention <MODULE>[/<SUBMODULE>]: <Capitalized description> (e.g. UCT/MUSA: ..., MUSA: ...). The commit in question was created through the GitHub web editor, which auto-generates the title Update <path>. It has no module prefix and no descriptive subject, so the linter flags it and the step exits non-zero, failing the whole Codestyle job. This is a PR hygiene failure, not a product/code defect — nothing in the UCX tree or CI configuration is broken.

Implicated commit: The offending commit is the one titled Update src/uct/musa/musa_copy/musa_copy_md.c on branch feat/musa_support (PR head [REDACTED:Hex High Entropy String], merge commit 350e3c0e0). Author is the PR submitter; no upstream commit is at fault.

File: The failing check is the Codestyle "commit title" Bash step in the PR pipeline (buildlib/ AZP PR definition); the commit itself touches src/uct/musa/musa_copy/musa_copy_md.c.

Suggested fix: Reword the bad commit so it matches the convention, then force-push:

git rebase -i [REDACTED:Hex High Entropy String]
# mark the "Update src/uct/musa/musa_copy/musa_copy_md.c" commit as `reword`
# new title e.g.: "UCT/MUSA: Fix musa_copy md registration path"
git push --force-with-lease origin feat/musa_support

Since this branch already carries 37 incremental "Address review feedback" commits, the cleaner option is to squash the whole series into a few logically-scoped commits (UCS/MEMORY:, UCM/MUSA:, UCT/MUSA:, TEST/MUSA:, DOCS/MUSA:), which both fixes this check and makes the PR reviewable. Going forward, avoid committing via the GitHub web editor, as it always produces Update <path> titles that this check rejects.

Related: PR #12107 (openucx/ucx) — no existing issue tracks this; the failure is specific to this branch's commit history.

🛡️ This comment had 1 potential secret(s) redacted (Hex High Entropy String). See request_id 207f9132-8f4c-43d7-9b2b-9e6d60243d4a 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 src/uct/musa/musa_copy/musa_copy_md.c Resolved
Comment thread src/uct/musa/base/musa_base.c Resolved
@svc-nvidia-pr-review

Copy link
Copy Markdown

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

Comment thread src/ucs/config/ucm_opts.c

{"MUSA_HOOK_MODE",
#if UCM_BISTRO_HOOKS
UCM_MMAP_HOOK_BISTRO_STR,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

With the default bistro, is ucm_musa_runtime_funcs ever installed? ucm_musamem_install() passes the runtime table only with UCM_MMAP_HOOK_RELOC, and ucm_install_hooks() silently returns UCS_OK when the mode bit is off, so musaMalloc/musaFree/musaMallocManaged/musaFreeHost get no hook by default (and the "installed partially" warning does not fire). ROCM_HOOK_MODE uses both modes for the same reason.

Suggested change:

   UCM_MMAP_HOOK_BISTRO_STR "," UCM_MMAP_HOOK_RELOC_STR,

return UCS_INPROGRESS;
}

flush = ucs_malloc(sizeof(*flush), "musa_copy_flush");

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 take the flush descriptor from an mpool instead of ucs_malloc()? uct_cuda_iface_t keeps a flush_mpool for exactly this, and iface_flush(comp != NULL) is on the UCP flush path.

/* Priority 10 matches cuda_util.c and rocm_base.c, so a GPU name replaces
* the bus-id label in ucx_info and the transport tables. */
ucs_snprintf_safe(device_name, sizeof(device_name), "GPU%u", device);
status = ucs_topo_sys_device_set_name(sys_dev, device_name, 10);

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 use a named constant for the name priority (cuda has UCT_CUDA_SYS_DEVICE_NAME_PRIORITY); the literal 10 right after char device_name[10] reads like a buffer length.

@svc-nvidia-pr-review

Copy link
Copy Markdown

Residual coverage gap: build_musa() only configures when /usr/local/musa/include/musa_runtime_api.h exists, which is false in every current CI container, and build_for_tests() is gated the same way — so the new sources, the HAVE_MUSA gtest files, and the newly instantiated UCT_TEST_GPU_MEM_TYPE_TLS suites still compile/run nowhere in CI.

Residual coverage gap: nothing covers the hook-mode selection above: musa_hooks.cc records only the last event per type, so a missing (or duplicated) runtime hook would not be distinguished from the driver-hook event.

Residual coverage gap: uct_musa_base_sys_devices is allocated once and never freed; harmless at process exit, but it means the musaDeviceGetPCIBusId → ucs_topo mapping is also never re-validated after init_sys_devs(), and no test exercises it.

@svc-ucx

svc-ucx commented Nov 22, 2026

Copy link
Copy Markdown

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

TL;DR: The gtest run on the BlueField ASan job failed because LeakSanitizer reported 68 KB in 17 allocations all belonging to test_ucp_proto_mock_rcx_speed_change.rma_get — a mocked rc_mlx5 UCT iface (devx CQ/SRQ), its QP/ep and the devx UAR are never released after the simulated port-speed-change reconfiguration. The leak is in master code recently added by the GET path-bandwidth balancing work (#12387), not in PR #12107 (MUSA support), so the PR should be rebased/re-run while the leak is fixed in the RMA/worker reconfiguration path.

Full analysis

Summary: make test in the AddressSanitizer BlueField job exited with Error 1 after SUMMARY: AddressSanitizer: 68024 byte(s) leaked in 17 allocation(s); every leak stack belongs to test_ucp_proto_mock_rcx_speed_change_rma_get (test/gtest/ucp/test_ucp_proto_mock.cc:5216).

Root cause: All leaked blocks are UCT/mlx5 resources created for that single test case:

  • iface-level objects created from ucp_worker_create → ucp_worker_add_resource_ifaces → ucp_worker_iface_open → mocked iface_open_mock → uct_ib_mlx5_devx_create_cq (ib_mlx5_dv.c:695/704) and uct_rc_mlx5_devx_init_rx_common (rc_mlx5_devx.c:233) — i.e. a CQ + SRQ of one mocked rc_mlx5 interface;
  • ep-level objects created from ucp_ep_create → ucp_wireup_init_lanes → ucp_wireup_ep_connect → uct_rc_mlx5_iface_create_qp (65536 B QP buffer, rc_mlx5 ep, and the uct_stub_iface_open wireup proxy);
  • the MD's devx UAR from uct_ib_mlx5_devx_alloc_uar (ib_mlx5.c:601).

The UCP context/worker structures themselves are not in the leak list (only 17 blocks), so this is not a wholesale "entity never destroyed" case: a specific iface/lane that is replaced when the test injects IBV_EVENT_DEVICE_SPEED_CHANGE (set_port_speed() → ucp_worker_iface_ep_event_cb → ucp_worker_iface_path_bw_progress → ucp_worker_ep_path_bw_update, src/ucp/core/ucp_worker.c:1077-1160) is discarded/re-created without the old UCT ep + iface ever being closed. Only the rma_get variant leaks (rma_put, which shares the same fixture, does not appear in the report), which points at the newly added GET balancing that copies the PUT samples onto the GET lanes (src/ucp/core/ucp_worker.c:1119-1124) and therefore triggers the extra endpoint/rkey reconfiguration exercised by the new rma_get test.

Implicated commit: [REDACTED:Hex High Entropy String] — "UCP/RMA: Balance GET by the path bandwidth samples of PUT (#12387)", dmitrygx, 2026-11-21 (landed ~22 h before this build; it added both test_ucp_proto_mock_rcx_speed_change.rma_get and the GET-from-PUT sample propagation in ucp_worker.c). Related preceding work: 4748c2a (#12362), 48795b8 (#12334). Nothing in the tested branch feat/musa_support touches UCP RMA or IB/mlx5.

File: test/gtest/ucp/test_ucp_proto_mock.cc:5216 (failing test) / src/ucp/core/ucp_worker.c:1119-1124 and 1077-1160 (speed-change reconfiguration path that leaks the UCT ep/iface)

Suggested fix:

  1. This failure is not caused by PR [MUSA]Feat: musa support #12107 — rebase on current master and re-run the BlueField ASan job; it should not gate the MUSA PR.
  2. Fix the leak in the speed-change reconfiguration path: when ucp_worker_ep_path_bw_update() causes a new ep config/lane layout, make sure the superseded lanes are routed through the discard mechanism and that ucp_worker_destroy() drains (or force-destroys) all discarded UCT endpoints and closes the corresponding ucp_worker_iface_t (ucp_worker_uct_iface_close, ucp_worker.c:1205) before the context/MD is released. A quick way to confirm: run test_ucp_proto_mock_rcx_speed_change.rma_get alone under ASAN_OPTIONS=detect_leaks=1 and compare with rma_put; if the leak only appears for GET, guard/short-circuit the GET sample copy at ucp_worker.c:1123-1124 and verify the leak disappears.
  3. If a fix is not immediate, temporarily disable rma_get (or mark it skipped under ASan) so the ASan BlueField pipeline is not red for every unrelated PR.

Related: #12387 (implicated), #12384, #12362, #12334, #12107 (this PR, unrelated to the leak)

🛡️ This comment had 1 potential secret(s) redacted (Hex High Entropy String). See request_id 80d4484e-480a-48f9-a977-9d219b023a9b in the triage console for the audit trail.

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.

5 participants