Skip to content

Commit 2513645

Browse files
authored
musa: support new arch mp_31 and update doc (#12296)
Signed-off-by: Xiaodong Ye <[email protected]>
1 parent 8acdacb commit 2513645

File tree

3 files changed

+37
-13
lines changed

3 files changed

+37
-13
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ ifdef GGML_MUSA
836836
else
837837
MUSA_PATH ?= /opt/musa
838838
endif
839-
MUSA_ARCHITECTURES ?= 21;22
839+
MUSA_ARCHITECTURES ?= 21;22;31
840840

841841
MK_CPPFLAGS += -DGGML_USE_MUSA -DGGML_USE_CUDA
842842
MK_LDFLAGS += -L$(MUSA_PATH)/lib -Wl,-rpath=$(MUSA_PATH)/lib

docs/build.md

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -197,28 +197,52 @@ The following compilation options are also available to tweak performance:
197197

198198
## MUSA
199199

200-
This provides GPU acceleration using the MUSA cores of your Moore Threads MTT GPU. Make sure to have the MUSA SDK installed. You can download it from here: [MUSA SDK](https://developer.mthreads.com/sdk/download/musa).
200+
This provides GPU acceleration using a Moore Threads GPU. Make sure to have the [MUSA SDK](https://developer.mthreads.com/musa/musa-sdk) installed.
201201

202-
- Using `CMake`:
202+
#### Download directly from Moore Threads
203203

204-
```bash
205-
cmake -B build -DGGML_MUSA=ON
206-
cmake --build build --config Release
207-
```
204+
You may find the official downloads here: [Moore Threads developer site](https://developer.mthreads.com/sdk/download/musa).
208205

209-
For static build:
206+
### Compilation
210207

211-
```bash
208+
```bash
209+
cmake -B build -DGGML_MUSA=ON
210+
cmake --build build --config Release
211+
```
212+
213+
#### Override Compute Capability Specifications
214+
215+
By default, all supported compute capabilities are enabled. To customize this behavior, you can specify the `MUSA_ARCHITECTURES` option in the CMake command:
216+
217+
```bash
218+
cmake -B build -DGGML_MUSA=ON -DMUSA_ARCHITECTURES="21"
219+
```
220+
221+
This configuration enables only compute capability `2.1` (MTT S80) during compilation, which can help reduce compilation time.
222+
223+
#### Compilation options
224+
225+
Most of the compilation options available for CUDA should also be available for MUSA, though they haven't been thoroughly tested yet.
226+
227+
- For static builds, add `-DBUILD_SHARED_LIBS=OFF` and `-DCMAKE_POSITION_INDEPENDENT_CODE=ON`:
228+
```
212229
cmake -B build -DGGML_MUSA=ON \
213230
-DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON
214231
cmake --build build --config Release
215232
```
216233

217-
The environment variable [`MUSA_VISIBLE_DEVICES`](https://docs.mthreads.com/musa-sdk/musa-sdk-doc-online/programming_guide/Z%E9%99%84%E5%BD%95/) can be used to specify which GPU(s) will be used.
234+
### Runtime MUSA environmental variables
218235

219-
The environment variable `GGML_CUDA_ENABLE_UNIFIED_MEMORY=1` can be used to enable unified memory in Linux. This allows swapping to system RAM instead of crashing when the GPU VRAM is exhausted.
236+
You may set the [musa environmental variables](https://docs.mthreads.com/musa-sdk/musa-sdk-doc-online/programming_guide/Z%E9%99%84%E5%BD%95/) at runtime.
220237

221-
Most of the compilation options available for CUDA should also be available for MUSA, though they haven't been thoroughly tested yet.
238+
```bash
239+
# Use `MUSA_VISIBLE_DEVICES` to hide the first compute device.
240+
MUSA_VISIBLE_DEVICES="-0" ./build/bin/llama-server --model /srv/models/llama.gguf
241+
```
242+
243+
### Unified Memory
244+
245+
The environment variable `GGML_CUDA_ENABLE_UNIFIED_MEMORY=1` can be used to enable unified memory in Linux. This allows swapping to system RAM instead of crashing when the GPU VRAM is exhausted.
222246

223247
## HIP
224248

ggml/src/ggml-musa/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ if (MUSAToolkit_FOUND)
2121
message(STATUS "MUSA Toolkit found")
2222

2323
if (NOT DEFINED MUSA_ARCHITECTURES)
24-
set(MUSA_ARCHITECTURES "21;22")
24+
set(MUSA_ARCHITECTURES "21;22;31")
2525
endif()
2626
message(STATUS "Using MUSA architectures: ${MUSA_ARCHITECTURES}")
2727

0 commit comments

Comments
 (0)