From 65fd2aff525edab0c50bfa5be61d6ad50d4365ef Mon Sep 17 00:00:00 2001 From: Bruno Verachten Date: Wed, 11 Mar 2026 09:47:06 +0100 Subject: [PATCH 1/2] build(riscv64): add workflow for native riscv64 wheel build Add GitHub Actions workflow to build llama-cpp-python wheel natively on BananaPi F3 (SpacemiT K1, rv64imafdcv) self-hosted runners. Uses GGML_NATIVE=ON for automatic RVV detection. --- .github/workflows/build-riscv64.yml | 133 ++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 .github/workflows/build-riscv64.yml diff --git a/.github/workflows/build-riscv64.yml b/.github/workflows/build-riscv64.yml new file mode 100644 index 0000000000..b2a25a39e2 --- /dev/null +++ b/.github/workflows/build-riscv64.yml @@ -0,0 +1,133 @@ +name: Build riscv64 wheel + +on: + workflow_dispatch: + inputs: + release_tag: + description: 'Upstream release tag to build from (e.g. v0.3.16)' + required: false + type: string + schedule: + - cron: '0 2 * * 0' + +jobs: + build: + runs-on: [self-hosted, linux, riscv64] + timeout-minutes: 120 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.release_tag || github.ref }} + fetch-depth: 0 + submodules: recursive + + - name: Set up Python + run: | + python3 -m venv /tmp/build-venv + . /tmp/build-venv/bin/activate + pip install --upgrade pip scikit-build-core cmake + + - name: Build wheel + run: | + . /tmp/build-venv/bin/activate + pip wheel . --no-build-isolation --wheel-dir /tmp/wheels/ \ + -C cmake.args="-DGGML_NATIVE=ON;-DLLAMA_BUILD_SERVER=OFF" + + - name: Verify platform tag + run: | + ls /tmp/wheels/llama_cpp_python*.whl + for whl in /tmp/wheels/llama_cpp_python*.whl; do + if echo "$whl" | grep -q "linux_riscv64\|manylinux.*riscv64"; then + echo "OK: $whl" + else + echo "FAIL: $whl does not have riscv64 platform tag" + exit 1 + fi + done + + - name: Upload wheel artifact + uses: actions/upload-artifact@v4 + with: + name: wheel-riscv64 + path: /tmp/wheels/llama_cpp_python*.whl + retention-days: 90 + + - name: Cleanup + if: always() + run: rm -rf /tmp/build-venv /tmp/wheels + + release: + needs: build + runs-on: [self-hosted, linux, riscv64] + if: success() + env: + GH_REPO: ${{ github.repository }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Download wheel artifact + uses: actions/download-artifact@v4 + with: + name: wheel-riscv64 + path: /tmp/wheels/ + + - name: Get wheel info + id: wheel_info + run: | + WHL=$(ls /tmp/wheels/llama_cpp_python*.whl | head -1) + BASENAME=$(basename "$WHL") + VERSION=$(echo "$BASENAME" | sed 's/^[^-]*-\([^-]*\)-.*/\1/') + echo "whl_path=$WHL" >> "$GITHUB_OUTPUT" + echo "whl_name=$BASENAME" >> "$GITHUB_OUTPUT" + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + + - name: Generate checksums + run: | + cd /tmp/wheels + sha256sum *.whl > SHA256SUMS + + - name: Create or update release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + TAG="riscv64-v${{ steps.wheel_info.outputs.version }}" + TITLE="riscv64 wheel v${{ steps.wheel_info.outputs.version }}" + + gh release delete "$TAG" --yes 2>/dev/null || true + git tag -d "$TAG" 2>/dev/null || true + git push origin ":refs/tags/$TAG" 2>/dev/null || true + + gh release create "$TAG" \ + --title "$TITLE" \ + --notes "Prebuilt riscv64 wheel for $(uname -m) Linux. + + Built on: BananaPi F3 (SpacemiT K1, rv64imafdcv) + Python: $(python3 --version 2>&1) + Wheel: ${{ steps.wheel_info.outputs.whl_name }} + + Install: + \`\`\` + pip install llama-cpp-python --find-links https://github.com/gounthar/llama-cpp-python/releases/download/$TAG/ + \`\`\`" \ + /tmp/wheels/*.whl \ + /tmp/wheels/SHA256SUMS + + - name: Cleanup + if: always() + run: rm -rf /tmp/wheels + + notify-index: + needs: release + runs-on: ubuntu-latest + if: success() + steps: + - name: Trigger index update + env: + GH_TOKEN: ${{ secrets.DISPATCH_TOKEN }} + run: | + gh api repos/gounthar/riscv64-python-wheels/dispatches \ + -f event_type=fork-release-published \ + -f "client_payload[repo]=${{ github.repository }}" \ + -f "client_payload[tag]=${{ github.ref_name }}" From a6427f0c8c7a70e8128765def1f9310911c611fd Mon Sep 17 00:00:00 2001 From: Bruno Verachten Date: Sun, 19 Apr 2026 22:01:06 +0200 Subject: [PATCH 2/2] fix: pre-install numpy before no-build-isolation wheel build --- .github/workflows/build-riscv64.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-riscv64.yml b/.github/workflows/build-riscv64.yml index b2a25a39e2..651f8c65fe 100644 --- a/.github/workflows/build-riscv64.yml +++ b/.github/workflows/build-riscv64.yml @@ -27,6 +27,7 @@ jobs: python3 -m venv /tmp/build-venv . /tmp/build-venv/bin/activate pip install --upgrade pip scikit-build-core cmake + pip install "numpy>=1.20.0" - name: Build wheel run: | @@ -131,3 +132,4 @@ jobs: -f event_type=fork-release-published \ -f "client_payload[repo]=${{ github.repository }}" \ -f "client_payload[tag]=${{ github.ref_name }}" +