diff --git a/.github/variables.env b/.github/variables.env index 263bf21d7bf8..2e09bd13f2ba 100644 --- a/.github/variables.env +++ b/.github/variables.env @@ -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 @@ -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 diff --git a/.github/workflows/build-spacemit-mtmd.yml b/.github/workflows/build-spacemit-mtmd.yml index 5663d728b490..c53d9d31c09c 100644 --- a/.github/workflows/build-spacemit-mtmd.yml +++ b/.github/workflows/build-spacemit-mtmd.yml @@ -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 \ @@ -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 \ diff --git a/VERSION_NUMBER b/VERSION_NUMBER index 1a030947e832..0ea3a944b399 100644 --- a/VERSION_NUMBER +++ b/VERSION_NUMBER @@ -1 +1 @@ -0.1.9 +0.2.0 diff --git a/docs/build-riscv64-spacemit.md b/docs/build-riscv64-spacemit.md index 7a9a1f3ad4ed..a021e45210db 100644 --- a/docs/build-riscv64-spacemit.md +++ b/docs/build-riscv64-spacemit.md @@ -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 \ diff --git a/docs/spacemit-mtmd.md b/docs/spacemit-mtmd.md index cb91735da452..2efd6cc4bc22 100644 --- a/docs/spacemit-mtmd.md +++ b/docs/spacemit-mtmd.md @@ -11,6 +11,8 @@ 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 @@ -18,18 +20,25 @@ 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 \ diff --git a/tools/smt-mtmd/CMakeLists.txt b/tools/smt-mtmd/CMakeLists.txt index 6bc5fed0436a..c36b828d455b 100644 --- a/tools/smt-mtmd/CMakeLists.txt +++ b/tools/smt-mtmd/CMakeLists.txt @@ -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()