Skip to content
Open
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c5bc473
DOCS/MUSA: Define UCX MUSA provider design
superleo Oct 9, 2026
4d26217
UCS/MEMORY: Add MUSA memory type contract
superleo Oct 9, 2026
09f719a
UCT/BUILD: Add optional MUSA module detection
superleo Oct 9, 2026
02cefad
UCT/MUSA: Add MUSA memory domain and copy transport
superleo Oct 9, 2026
cb94498
DOCS/MUSA: Record implementation and validation plan
superleo Oct 9, 2026
e9e9f7b
UCS/MUSA: Preserve runtime detection errors
superleo Oct 9, 2026
939deda
UCT/MUSA: Add compact MUSA capability provider
superleo Oct 10, 2026
b180dae
Merge remote-tracking branch 'origin/master' into feat/musa_support
superleo Oct 15, 2026
5b3a01d
UCM/MUSA: Publish allocation events
superleo Oct 16, 2026
4180e72
UCT/MUSA: Replace the stub transport with musa_copy
superleo Oct 16, 2026
f9bcec2
TEST/MUSA: Follow the base header path
superleo Oct 16, 2026
87e3b03
UCT/MUSA: Add memory registration to musa_copy md
superleo Oct 16, 2026
1ea92e7
UCT/MUSA: Publish MUSA PCI devices and cap musa_copy resources
superleo Oct 16, 2026
7ef53c1
UCT/MUSA: Validate registration and PCI metadata
superleo Oct 16, 2026
7e627d0
BUILD: Fix MUSA configure checks
superleo Oct 16, 2026
e575e96
Merge remote-tracking branch 'origin/master' into feat/musa_support
superleo Oct 29, 2026
171799b
MUSA: Fix memory detection and copy paths
superleo Oct 29, 2026
b7b3ce7
MUSA: Fix review feedback for copy paths
superleo Oct 29, 2026
c71f28b
TEST/MUSA: Use global managed memory attachment
superleo Oct 30, 2026
aabae58
MUSA: Re-detect allocations through UCP
superleo Oct 30, 2026
765171e
MUSA: Fix configure fallback and device restore
superleo Oct 30, 2026
40dd086
MUSA: Add asynchronous copy progress and hooks
superleo Oct 31, 2026
283f7e4
MUSA: Address review feedback and enable gtest buffers
superleo Oct 31, 2026
e91befa
MUSA: Complete allocation hooks and review fixes
superleo Oct 31, 2026
db52c5a
MUSA: Align hook and device cache paths
superleo Nov 1, 2026
268026a
MUSA: Fix review issues in copy and build paths
superleo Nov 1, 2026
260dbb4
MUSA: Resolve remaining review findings
superleo Nov 1, 2026
35d82c6
MUSA: Fix remaining review findings
superleo Nov 1, 2026
9fb1f39
MUSA: Harden memory queries and review failure paths
superleo Nov 2, 2026
e797e0d
MUSA: Fix SDK compatibility and flush polling
superleo Nov 2, 2026
7515f80
MUSA: Decouple async/pool API detection from sync _v2 API
superleo Nov 3, 2026
6d7b017
UCT/MUSA: Reject unknown system device lookups
superleo Nov 3, 2026
e386e24
UCT/MUSA: Dispatch copy completions after restoring the device
superleo Nov 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codespellrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[codespell]
skip = ./test/gtest/common,./src/ucs/datastruct/sglib.h,./docs/doxygen/Architecture*,./docs/doxygen/header.tex.in,./src/ucm/ptmalloc286,./config/m4/ax_prog_doxygen.m4,./VENV/*,./ltmain.sh,./configure,./config.guess,./config.sub,./.git,./depcomp,./libtool,./config/m4/libtool.m4
ignore-words-list = hsa,inout,scoll,warmup,pullrequest,shft
ignore-words-list = hsa,inout,scoll,warmup,pullrequest,shft,renderd
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ Zihao Zhao <zizhao@nvidia.com>
lzhang2 <cherry.zhang@intel.com>
michaelzli <michaelzli@tencent.com>
shasson5 <103439971+shasson5@users.noreply.github.com>
superleo <xlei.boll@gmail.com>
wehy <18174858434@163.com>
ybenabou <ybenabou@nvidia.com>
yuanwu <yuan.wu@intel.com>
Expand Down
190 changes: 190 additions & 0 deletions config/m4/musa.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
#
# Copyright (C) MThreads 2026. ALL RIGHTS RESERVED.
# See file LICENSE for terms.
#

AC_DEFUN([UCX_CHECK_MUSA],[
AS_IF([test "x$musa_checked" != "xyes"], [
AC_ARG_WITH([musa],
[AS_HELP_STRING([--with-musa=(DIR)],
[Enable MUSA support (default is guess).])],
[],
[with_musa=guess])

musa_happy=no
MUSA_CPPFLAGS=""
MUSA_LDFLAGS=""
MUSA_LIBS=""
MUSA_RPATH=""
MUSA_ROOT=""

AS_IF([test "x$with_musa" = "xno"], [
AC_MSG_NOTICE([MUSA support was explicitly disabled])
], [
AS_IF([test "x$with_musa" = "xyes" ||
test "x$with_musa" = "xguess"], [
AS_IF([test -d /usr/local/musa],
Comment thread
superleo marked this conversation as resolved.
Resolved
[MUSA_ROOT=/usr/local/musa])
Comment thread
superleo marked this conversation as resolved.
Resolved
], [
MUSA_ROOT="$with_musa"
])

AS_IF([test -n "$MUSA_ROOT"], [
MUSA_CPPFLAGS="-I$MUSA_ROOT/include"
MUSA_LDFLAGS="-L$MUSA_ROOT/lib -L$MUSA_ROOT/lib64"
MUSA_RPATH="-rpath $MUSA_ROOT/lib --enable-new-dtags -rpath $MUSA_ROOT/lib64"
Comment thread
superleo marked this conversation as resolved.
Resolved
])
MUSA_LIBS="-lmusart -lmusa"

musa_happy=yes
save_CPPFLAGS="$CPPFLAGS"
save_LDFLAGS="$LDFLAGS"
save_LIBS="$LIBS"

CPPFLAGS="$MUSA_CPPFLAGS $CPPFLAGS"
LDFLAGS="$MUSA_LDFLAGS $LDFLAGS"
LIBS="$MUSA_LIBS $LIBS"

AC_CHECK_HEADERS([musa_runtime_api.h],
Comment thread
superleo marked this conversation as resolved.
Resolved
[],
[musa_happy=no])
AC_CHECK_HEADERS([musa.h],
[],
[musa_happy=no])

AS_IF([test "x$musa_happy" = "xyes"], [
AC_CHECK_LIB([musart], [musaGetDeviceCount],
[],
[musa_happy=no])
])
AS_IF([test "x$musa_happy" = "xyes"], [
AC_CHECK_LIB([musa], [muMemGetAddressRange],
[],
[musa_happy=no])
])
AS_IF([test "x$musa_happy" = "xyes"], [
AC_CHECK_DECLS(
[MU_MEM_RANGE_HANDLE_TYPE_DMA_BUF_FD],
[AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <musa.h>]],
[[int fd = -1;
return (int)muMemGetHandleForAddressRange(
&fd, 0, 0,
MU_MEM_RANGE_HANDLE_TYPE_DMA_BUF_FD,
0);]])],
[AC_DEFINE(
[HAVE_MUSA_DMABUF], [1],
[MUSA supports DMA-BUF export])],
[])],
[],
[[#include <musa.h>]])
])
AS_IF([test "x$musa_happy" = "xyes"], [
AC_LINK_IFELSE(
Comment thread
superleo marked this conversation as resolved.
Resolved
[AC_LANG_PROGRAM(
[[#include <stddef.h>
#include <musa.h>
#include <musa_runtime_api.h>]],
[[int count = 0;
int device = 0;
void *address = 0;
MUdeviceptr base = 0;
size_t size = 0;
size_t pitch = 0;
musaMemPool_t runtime_pool = 0;
musaStream_t runtime_stream = 0;
musaEvent_t event = 0;
char pci_bus_id[64];
MUmemoryPool driver_pool = 0;
MUstream driver_stream = 0;
unsigned memory_type = 0;
unsigned is_managed = 0;
musaGetDeviceCount(&count);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

musaMalloc is missing from this link program, even though it is the one allocation call both musa_copy_md.c and musamem.c use. Given AC_CHECK_LIB([musart], [musaGetDeviceCount]) and AC_CHECK_LIB([musa], [muMemGetAddressRange]) above already prove both libraries link, pls either add musaMalloc or trim this 60-line program — as written it enumerates the API surface and will need an edit for every new call site.

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.

musaMalloc is in the link probe now. The probe structure was also reworked (mandatory vs. optional symbols) — see the separate thread about the single large probe. @svc-nvidia-pr-review

musaGetDevice(&device);
musaSetDevice(device);
musaDeviceGetPCIBusId(pci_bus_id,
sizeof(pci_bus_id),
device);
muPointerGetAttribute(
&memory_type,
MU_POINTER_ATTRIBUTE_MEMORY_TYPE,
(MUdeviceptr)address);
muPointerGetAttribute(
&is_managed, MU_POINTER_ATTRIBUTE_IS_MANAGED,
(MUdeviceptr)address);
muPointerGetAttribute(
&device, MU_POINTER_ATTRIBUTE_DEVICE_ORDINAL,
(MUdeviceptr)address);
musaGetErrorString(musaSuccess);
musaGetLastError();
muMemGetAddressRange(&base, &size,
(MUdeviceptr)address);
musaMalloc(&address, size);
musaFree(address);
musaMallocManaged(&address, size, 0);
musaMallocPitch(&address, &pitch, size, 1);
musaMallocAsync(&address, size, runtime_stream);
musaMallocFromPoolAsync(&address, size,
runtime_pool,
runtime_stream);
musaHostRegister(address, size, 0);
musaHostUnregister(address);
musaStreamCreateWithFlags(&runtime_stream, 0);
musaEventCreateWithFlags(&event, 0);
musaMemcpy(address, address, size,
musaMemcpyDeviceToDevice);
musaMemcpyAsync(address, address, size,
musaMemcpyDeviceToDevice,
runtime_stream);
musaEventRecord(event, runtime_stream);
musaEventQuery(event);
if (muEventQuery((MUevent)event) ==
MUSA_ERROR_NOT_READY) {
count = 0;
}
musaEventDestroy(event);
musaStreamSynchronize(runtime_stream);
musaStreamDestroy(runtime_stream);
musaFree(address);
musaFreeAsync(address, runtime_stream);
musaFreeHost(address);
muMemAlloc_v2(&base, size);
muMemAllocPitch_v2(&base, &pitch, size, 1, 1);
muMemAllocManaged(&base, size, 0);
muMemAllocAsync(&base, size, driver_stream);
muMemAllocFromPoolAsync(&base, size,
driver_pool,
driver_stream);
muMemFreeAsync(base, driver_stream);
muMemFree_v2(base);
muMemFree(base);
return count < 0;]])],
[],
[musa_happy=no])
])

CPPFLAGS="$save_CPPFLAGS"
LDFLAGS="$save_LDFLAGS"
LIBS="$save_LIBS"

AS_IF([test "x$musa_happy" = "xyes"], [
AC_DEFINE([HAVE_MUSA], [1], [Enable MUSA support])
AC_SUBST([MUSA_CPPFLAGS])
AC_SUBST([MUSA_LDFLAGS])
AC_SUBST([MUSA_LIBS])
AC_SUBST([MUSA_RPATH])
AC_SUBST([MUSA_ROOT])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

MUSA_ROOT is substituted but not referenced in any Makefile.am, and MUSA_LDFLAGS only adds -L. Do we need -rpath $(MUSA_ROOT)/lib{,64} in the module LDFLAGS (as ze does), otherwise libuct_musa.so will not find libmusart unless LD_LIBRARY_PATH/ld.so.conf is set?

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 prefer no rpath: verified that the built libuct_musa.so /libucm_musa.so carry no RUNPATH and load fine both via the system loader configuration and via an explicit LD_LIBRARY_PATH. Since the SDK location can differ between build and deployment hosts, baking the build-time path into the modules seemed more likely to cause problems than to fix them.

], [
AS_IF([test "x$with_musa" != "xguess"], [
AC_MSG_ERROR([MUSA support was requested but MUSA headers and libraries were not found])
], [
AC_MSG_WARN([MUSA headers and libraries not found])
])
])
])

musa_checked=yes
AM_CONDITIONAL([HAVE_MUSA], [test "x$musa_happy" = "xyes"])
])
])
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ AS_IF([test "x$with_docs_only" = xyes],
AM_CONDITIONAL([HAVE_LCOV], [false])
AM_CONDITIONAL([HAVE_ZE], [false])
AM_CONDITIONAL([HAVE_GAUDI], [false])
AM_CONDITIONAL([HAVE_MUSA], [false])
AM_CONDITIONAL([HAVE_GDA], [false])
],
[
Expand All @@ -295,6 +296,7 @@ AS_IF([test "x$with_docs_only" = xyes],
m4_include([config/m4/cuda.m4])
m4_include([config/m4/verbs.m4])
m4_include([config/m4/rocm.m4])
m4_include([config/m4/musa.m4])
m4_include([config/m4/ze.m4])
m4_include([config/m4/gdrcopy.m4])
m4_include([config/m4/mad.m4])
Expand Down
1 change: 1 addition & 0 deletions src/ucm/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ is `api/ucm.h`; everything else is internal.
`reloc.c` (ELF relocation walking), `log.c`, `sys.c`, `khash_safe.h`.
- `cuda/` — `cudamem` hooks for `cudaMalloc`/`cudaFree` and friends. Built
as a module; emits `MEM_TYPE_ALLOC`/`FREE` events.
- `musa/` — `musamem` hooks for `musaMalloc`/`musaFree`.
- `rocm/` — analogous hooks for `hipMalloc`/`hipFree`.
- `ze/` — Intel Level Zero allocations.
- `ptmalloc286/` — third-party allocator, only built when in-tree malloc
Expand Down
2 changes: 1 addition & 1 deletion src/ucm/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# See file LICENSE for terms.
#

SUBDIRS = . cuda rocm ze
SUBDIRS = . cuda musa rocm ze
Comment thread
superleo marked this conversation as resolved.
Resolved

lib_LTLIBRARIES = libucm.la
libucm_ladir = $(includedir)/ucm
Expand Down
1 change: 1 addition & 0 deletions src/ucm/api/ucm.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ typedef struct ucm_global_config {
double bistro_grace_duration; /* Grace duration for bistro patching
* in seconds */
uint64_t rocm_hook_modes; /* Bitmap of allowed rocm hooks modes */
uint64_t musa_hook_modes; /* Bitmap of allowed musa hooks modes */
} ucm_global_config_t;


Expand Down
1 change: 1 addition & 0 deletions src/ucm/configure.m4
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ LDFLAGS="$SAVE_LDFLAGS"

ucm_modules=""
m4_include([src/ucm/cuda/configure.m4])
m4_include([src/ucm/musa/configure.m4])
m4_include([src/ucm/rocm/configure.m4])
m4_include([src/ucm/ze/configure.m4])
AC_DEFINE_UNQUOTED([ucm_MODULES], ["${ucm_modules}"], [UCM loadable modules])
Expand Down
20 changes: 20 additions & 0 deletions src/ucm/musa/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Copyright (C) MThreads 2026. ALL RIGHTS RESERVED.
# See file LICENSE for terms.
#

if HAVE_MUSA
module_LTLIBRARIES = libucm_musa.la
libucm_musa_la_CPPFLAGS = $(BASE_CPPFLAGS) $(MUSA_CPPFLAGS)
libucm_musa_la_CFLAGS = $(BASE_CFLAGS) $(MUSA_CFLAGS) $(LT_CFLAGS)
libucm_musa_la_LIBADD = ../libucm.la $(MUSA_LIBS)
libucm_musa_la_LDFLAGS = $(UCM_MODULE_LDFLAGS) \
$(patsubst %, -Xlinker %, $(MUSA_LDFLAGS)) \
-version-info $(SOVERSION) $(UCX_LT_RELEASE) \
$(patsubst %, -Xlinker %, $(MUSA_RPATH))

libucm_musa_la_SOURCES = \
musamem.c

include $(top_srcdir)/config/module.am
endif
9 changes: 9 additions & 0 deletions src/ucm/musa/configure.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# Copyright (C) MThreads 2026. ALL RIGHTS RESERVED.
# See file LICENSE for terms.
#

UCX_CHECK_MUSA
AS_IF([test "x$musa_happy" = "xyes"],
[ucm_modules="${ucm_modules}:musa"])
AC_CONFIG_FILES([src/ucm/musa/Makefile])
Loading