Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/variables.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SPACEMIT_TOOLCHAIN_URL=https://github.com/spacemit-com/toolchain/releases/download/v1.1.2/spacemit-toolchain-linux-glibc-x86_64-v1.1.2.tar.xz
SPACEMIT_ORT_URL=https://github.com/spacemit-com/onnxruntime/releases/download/2.0.6/spacemit-ort.riscv64.2.0.6.tar.gz
SPACEMIT_SPERT_URL=https://github.com/spacemit-com/spine-runtime/releases/download/0.6.1/spine-runtime.riscv64.0.6.1.tar.gz
SPACEMIT_SPERT_URL=https://github.com/spacemit-com/spine-runtime/releases/download/0.6.3/spine-runtime.riscv64.0.6.3.tar.gz
SPACEMIT_MTMD_PACKAGE_PREFIX=spacemit-llama.cpp.riscv64
SPACEMIT_TOOLCHAIN_ARCHIVE=.cache/spacemit-toolchain.tar.xz
SPACEMIT_ORT_ARCHIVE=.cache/spacemit-ort.tar.gz
Expand All @@ -9,7 +9,7 @@ SPACEMIT_TOOLCHAIN_DIR=spacemit_toolchain
SPACEMIT_SPERT_DIR=spacemit_spert
SPACEMIT_TOOLCHAIN_OHOS_URL=https://github.com/spacemit-com/toolchain/releases/download/oh-20260630/spacemit-toolchain-linux-musl-x86_64-oh-20260630.tar.xz
SPACEMIT_ORT_OHOS_URL=https://github.com/spacemit-com/onnxruntime/releases/download/2.0.6/spacemit-ort.riscv64.ohos.2.0.6.tar.gz
SPACEMIT_SPERT_OHOS_URL=https://github.com/spacemit-com/spine-runtime/releases/download/0.6.1/spine-runtime.riscv64.ohos.0.6.1.tar.gz
SPACEMIT_SPERT_OHOS_URL=https://github.com/spacemit-com/spine-runtime/releases/download/0.6.3/spine-runtime.riscv64.ohos.0.6.3.tar.gz
SPACEMIT_MTMD_OHOS_PACKAGE_PREFIX=spacemit-llama.cpp.riscv64.ohos
SPACEMIT_TOOLCHAIN_OHOS_ARCHIVE=.cache/spacemit-toolchain-ohos.tar.xz
SPACEMIT_ORT_OHOS_ARCHIVE=.cache/spacemit-ort-ohos.tar.gz
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-spacemit-mtmd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ jobs:
rm -rf build/CMakeCache.txt
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DGGML_CPU_RISCV64_SPACEMIT=ON \
-DGGML_SPACEMIT=ON \
-DGGML_CPU_REPACK=OFF \
-DGGML_OPENMP=OFF \
-DLLAMA_CURL=OFF \
Expand Down Expand Up @@ -527,7 +527,7 @@ jobs:
rm -f build-ohos/tools/ui/llama-ui-embed-host
cmake -B build-ohos \
-DCMAKE_BUILD_TYPE=Release \
-DGGML_CPU_RISCV64_SPACEMIT=ON \
-DGGML_SPACEMIT=ON \
-DGGML_CPU_REPACK=OFF \
-DGGML_OPENMP=OFF \
-DLLAMA_CURL=OFF \
Expand Down
2 changes: 1 addition & 1 deletion VERSION_NUMBER
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.9
0.2.0
23 changes: 21 additions & 2 deletions docs/build-riscv64-spacemit.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,31 @@ wget https://github.com/spacemit-com/toolchain/releases/download/v1.2.4/spacemit
~~~

2. Build
Below is the build script: it requires utilizing RISC-V vector instructions for acceleration. Ensure the `GGML_CPU_RISCV64_SPACEMIT` compilation option is enabled. The currently supported optimization version is `RISCV64_SPACEMIT_IME1` and `RISCV64_SPACEMIT_IME2`, corresponding to the `RISCV64_SPACEMIT_IME_SPEC` compilation option. Compiler configurations are defined in the `riscv64-spacemit-linux-gnu-gcc.cmake` file. Please ensure you have installed the RISC-V compiler and set the environment variable via `export RISCV_ROOT_PATH={your_compiler_path}`.
Below is the build script: it requires utilizing RISC-V vector instructions for acceleration.

The SpacemiT backend is enabled with **`-DGGML_SPACEMIT=ON`** (the standalone `ggml-spacemit`
backend, `ggml/src/ggml-spacemit`). It consumes the `spine-runtime` (spert) release package as a
prebuilt dependency, so `SPERT_DIR` must point at the extracted release tree (containing `include/`
and `lib/`), for example:

```bash
wget https://github.com/spacemit-com/spine-runtime/releases/download/0.6.3/spine-runtime.riscv64.0.6.3.tar.gz
tar xzf spine-runtime.riscv64.0.6.3.tar.gz
export SPERT_DIR=${PWD}/spine-runtime.riscv64.0.6.3
```

The backend detects the IME (`.vmadot`) instructions your compiler supports and sets
`RISCV64_SPACEMIT_IME_SPEC` (`RISCV64_SPACEMIT_IME1` / `RISCV64_SPACEMIT_IME2`) automatically.
`-DGGML_CPU_RISCV64_SPACEMIT` is the legacy in-CPU path and is deprecated: when `GGML_SPACEMIT=ON`
is set, it is disabled automatically (do not enable both). Compiler configurations are defined in
the `riscv64-spacemit-linux-gnu-gcc.cmake` file. Please ensure you have installed the RISC-V compiler
and set the environment variable via `export RISCV_ROOT_PATH={your_compiler_path}`.
```bash

cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DGGML_CPU_RISCV64_SPACEMIT=ON \
-DGGML_SPACEMIT=ON \
-DSPERT_DIR=${SPERT_DIR} \
-DGGML_CPU_REPACK=OFF \
-DLLAMA_OPENSSL=OFF \
-DGGML_RVV=ON \
Expand Down
11 changes: 10 additions & 1 deletion docs/spacemit-mtmd.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,34 @@ To build with SMT support, you need:

- the SpacemiT RISC-V toolchain
- `RISCV_ROOT_PATH` pointing to that toolchain
- the SpacemiT spine-runtime (spert) package unpacked locally
- `SPERT_DIR` pointing to the unpacked spine-runtime directory
- the SpacemiT ORT package unpacked locally
- `SPACEMIT_ORT_DIR` pointing to the unpacked ORT directory

Download and unpack the required packages:

```bash
wget https://github.com/spacemit-com/toolchain/releases/download/v1.1.2/spacemit-toolchain-linux-glibc-x86_64-v1.1.2.tar.xz
wget https://github.com/spacemit-com/spine-runtime/releases/download/0.6.3/spine-runtime.riscv64.0.6.3.tar.gz
wget https://github.com/spacemit-com/onnxruntime/releases/download/2.0.2/spacemit-ort.riscv64.2.0.2.tar.gz
```

The SpacemiT backend itself is enabled with `-DGGML_SPACEMIT=ON` (the standalone
`ggml-spacemit` backend). `-DGGML_CPU_RISCV64_SPACEMIT` is the legacy in-CPU path and is
deprecated: when `GGML_SPACEMIT=ON` is set it is disabled automatically, so do not enable both.

Then build:

```bash
export RISCV_ROOT_PATH=/path/to/spacemit_toolchain
export SPERT_DIR=/path/to/spine-runtime
export SPACEMIT_ORT_DIR=/path/to/spacemit-ort

cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DGGML_CPU_RISCV64_SPACEMIT=ON \
-DGGML_SPACEMIT=ON \
-DSPERT_DIR=${SPERT_DIR} \
-DGGML_CPU_REPACK=OFF \
-DGGML_OPENMP=OFF \
-DLLAMA_CURL=OFF \
Expand Down
20 changes: 11 additions & 9 deletions tools/smt-mtmd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,16 @@ if(LLAMA_SERVER_SMT_MTMD)
if(CMAKE_DL_LIBS)
target_link_libraries(${TARGET} PRIVATE ${CMAKE_DL_LIBS})
endif()
if(CMAKE_SYSTEM_PROCESSOR MATCHES "riscv" AND GGML_CPU_RISCV64_SPACEMIT)
get_target_property(QWEN3_TTS_RISCV_OPTIONS ggml-cpu COMPILE_OPTIONS)
if(QWEN3_TTS_RISCV_OPTIONS)
list(FILTER QWEN3_TTS_RISCV_OPTIONS INCLUDE REGEX "^-m(arch|abi)=")
set_source_files_properties(
smt/qwen3-tts/qwen3_tts_talker.cpp
PROPERTIES COMPILE_OPTIONS "${QWEN3_TTS_RISCV_OPTIONS}"
)
endif()
if(CMAKE_SYSTEM_PROCESSOR MATCHES "riscv" AND (GGML_SPACEMIT OR GGML_CPU_RISCV64_SPACEMIT))
# qwen3_tts_talker.cpp enables its RVV kernels behind
# `#if defined(__riscv_vector) && defined(__riscv_zvfh)`, so it needs an explicit
# -march/-mabi: ggml-cpu's ARCH_FLAGS and ggml-spacemit's SPACEMIT_MARCH are both
# target-PRIVATE (they do not propagate to targets that link them), and the OHOS
# toolchain intentionally leaves -march/-mabi unset globally. Without this the file
# silently falls back to its scalar dot_f16/f16_gemv path.
set_source_files_properties(
smt/qwen3-tts/qwen3_tts_talker.cpp
PROPERTIES COMPILE_OPTIONS "-march=rv64gcv_zfh_zvfh_zba_zicbop;-mabi=lp64d"
)
endif()
endif()
Loading