Skip to content

Commit ab04906

Browse files
committed
musa: upgrade musa sdk to rc4.2.0 (#13)
* musa: upgrade musa sdk to 4.2.0 Signed-off-by: Xiaodong Ye <[email protected]> * musa: remove mudnn and apply wa for libmusa.so Signed-off-by: Xiaodong Ye <[email protected]> * musa: restore rc in docker image tag Signed-off-by: Xiaodong Ye <[email protected]> --------- Signed-off-by: Xiaodong Ye <[email protected]>
1 parent d5834bd commit ab04906

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ if(MUSAToolkit_FOUND)
160160
install(TARGETS ggml-musa
161161
RUNTIME_DEPENDENCIES
162162
DIRECTORIES ${MUSAToolkit_BIN_DIR} ${MUSAToolkit_LIBRARY_DIR}
163-
PRE_INCLUDE_REGEXES mudnn mublas musart musa
163+
PRE_INCLUDE_REGEXES mublas musart musa
164164
PRE_EXCLUDE_REGEXES ".*"
165165
RUNTIME DESTINATION ${OLLAMA_MUSA_INSTALL_DIR} COMPONENT MUSA
166166
LIBRARY DESTINATION ${OLLAMA_MUSA_INSTALL_DIR} COMPONENT MUSA

Dockerfile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ ARG ROCMVERSION=6.3.3
66
ARG JETPACK5VERSION=r35.4.1
77
ARG JETPACK6VERSION=r36.4.0
88
ARG CMAKEVERSION=3.31.2
9-
ARG MUSAVERSION=rc4.0.1
9+
ARG MUSAVERSION=rc4.2.0
10+
ARG UBUNTUVERSION=22.04
1011

1112
# We require gcc v10 minimum. v10.3 has regressions, so the rockylinux 8.5 AppStream has the latest compatible version
1213
FROM --platform=linux/amd64 rocm/dev-almalinux-8:${ROCMVERSION}-complete AS base-amd64
@@ -105,7 +106,7 @@ FROM scratch AS rocm
105106
COPY --from=rocm-6 dist/lib/ollama /lib/ollama
106107

107108
# Moore Threads (MUSA) build stages
108-
FROM mthreads/musa:${MUSAVERSION}-mudnn-devel-ubuntu22.04 AS musa-4
109+
FROM mthreads/musa:${MUSAVERSION}-devel-ubuntu${UBUNTUVERSION}-amd64 AS musa-4
109110
RUN apt-get update \
110111
&& apt-get install -y curl \
111112
&& apt-get clean \
@@ -119,6 +120,14 @@ RUN --mount=type=cache,target=/root/.ccache \
119120
cmake --preset 'MUSA 4' \
120121
&& cmake --build --parallel --preset 'MUSA 4' \
121122
&& cmake --install build --component MUSA --strip --parallel 8
123+
# TODO: Remove the following lines in next release
124+
RUN cd dist/lib/ollama/musa_v4 && \
125+
for f in libmusa.so.*; do \
126+
if [ -f "$f" ] && [[ "$f" =~ ^libmusa\.so\.[0-9]+$ ]]; then \
127+
ln -sf "$f" libmusa.so; \
128+
break; \
129+
fi; \
130+
done
122131

123132
FROM scratch AS musa
124133
COPY --from=musa-4 dist/lib/ollama/musa_v4 /lib/ollama/musa_v4
@@ -127,7 +136,7 @@ FROM ${FLAVOR} AS archive
127136
COPY --from=cpu dist/lib/ollama /lib/ollama
128137
COPY --from=build /bin/ollama /bin/ollama
129138

130-
FROM ubuntu:22.04
139+
FROM ubuntu:${UBUNTUVERSION}
131140
RUN apt-get update \
132141
&& apt-get install -y ca-certificates \
133142
&& apt-get clean \

ml/backend/ggml/ggml/src/ggml-musa/CMakeLists.txt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@ if (MUSAToolkit_FOUND)
3434
list(APPEND GGML_SOURCES_MUSA ${SRCS})
3535
file(GLOB SRCS "../ggml-cuda/template-instances/mmq*.cu")
3636
list(APPEND GGML_SOURCES_MUSA ${SRCS})
37-
file(GLOB SRCS "../ggml-musa/*.cu")
38-
list(APPEND GGML_SOURCES_MUSA ${SRCS})
37+
38+
if (GGML_MUSA_MUDNN_COPY)
39+
file(GLOB SRCS "../ggml-musa/*.cu")
40+
list(APPEND GGML_SOURCES_MUSA ${SRCS})
41+
add_compile_definitions(GGML_MUSA_MUDNN_COPY)
42+
endif()
3943

4044
if (GGML_CUDA_FA_ALL_QUANTS)
4145
file(GLOB SRCS "../ggml-cuda/template-instances/fattn-vec*.cu")
@@ -97,10 +101,16 @@ if (MUSAToolkit_FOUND)
97101
endif()
98102

99103
if (GGML_STATIC)
100-
# TODO: mudnn has not provided static libraries yet
101104
target_link_libraries(ggml-musa PRIVATE MUSA::musart_static MUSA::mublas_static)
105+
# TODO: mudnn has not provided static libraries yet
106+
# if (GGML_MUSA_MUDNN_COPY)
107+
# target_link_libraries(ggml-musa PRIVATE mudnn_static)
108+
# endif()
102109
else()
103-
target_link_libraries(ggml-musa PRIVATE MUSA::musart MUSA::mublas mudnn)
110+
target_link_libraries(ggml-musa PRIVATE MUSA::musart MUSA::mublas)
111+
if (GGML_MUSA_MUDNN_COPY)
112+
target_link_libraries(ggml-musa PRIVATE mudnn)
113+
endif()
104114
endif()
105115

106116
if (GGML_CUDA_NO_VMM)

0 commit comments

Comments
 (0)