Skip to content

Commit 5f90368

Browse files
authored
Merge branch 'abetlen:main' into main
2 parents d4560af + ea3b56b commit 5f90368

63 files changed

Lines changed: 24671 additions & 1123 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/build-and-release.yaml‎

Lines changed: 106 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ jobs:
1414
os: [ubuntu-22.04, windows-2022, macos-14, macos-15]
1515

1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v6
1818
with:
1919
submodules: "recursive"
2020

2121
# Used to host cibuildwheel
22-
- uses: actions/setup-python@v5
22+
- uses: actions/setup-python@v6
2323
with:
2424
python-version: "3.9"
2525

@@ -42,59 +42,144 @@ jobs:
4242
shell: cmd
4343

4444
- name: Build wheels
45-
uses: pypa/cibuildwheel@v2.22.0
45+
uses: pypa/cibuildwheel@v3.4.1
4646
env:
47-
# disable repair
47+
# Keep repair disabled by default for non-Linux platforms in this job.
4848
CIBW_REPAIR_WHEEL_COMMAND: ""
49+
# Linux needs auditwheel repair so manylinux and musllinux wheels are
50+
# published with distinct platform tags instead of generic linux tags.
51+
CIBW_REPAIR_WHEEL_COMMAND_LINUX: "LD_LIBRARY_PATH=/project/llama_cpp/lib auditwheel repair -w {dest_dir} {wheel}"
52+
# cibuildwheel v3 defaults to manylinux_2_28 images whose current
53+
# GCC toolchain emits symbols newer than the policy allows.
54+
CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2014"
55+
# The release wheel is tagged py3-none, so one build per platform
56+
# covers all supported Python versions and avoids duplicate names.
57+
CIBW_BUILD_LINUX: "cp38-*"
58+
CIBW_BUILD_MACOS: "cp39-*"
59+
CIBW_BUILD_WINDOWS: "cp39-*"
60+
# Skip cibuildwheel's default i686 sidecar and keep Linux release
61+
# wheels on a portable x86_64 CPU baseline.
62+
CIBW_ARCHS_LINUX: "auto64"
63+
CIBW_ARCHS_WINDOWS: "AMD64"
64+
CIBW_ENVIRONMENT_LINUX: CMAKE_ARGS="-DGGML_NATIVE=off"
65+
# Keep macOS release wheels on a portable CPU baseline instead of
66+
# inheriting the hosted runner's native flags.
67+
CIBW_ENVIRONMENT_MACOS: CMAKE_ARGS="-DGGML_NATIVE=off"
4968
with:
5069
package-dir: .
5170
output-dir: wheelhouse
5271

53-
- uses: actions/upload-artifact@v4
72+
- uses: actions/upload-artifact@v7
5473
with:
5574
name: wheels-${{ matrix.os }}
5675
path: ./wheelhouse/*.whl
5776

5877
build_wheels_arm64:
5978
name: Build arm64 wheels
79+
runs-on: ubuntu-24.04-arm
80+
steps:
81+
- uses: actions/checkout@v6
82+
with:
83+
submodules: "recursive"
84+
85+
- name: Build wheels
86+
uses: pypa/cibuildwheel@v3.4.1
87+
env:
88+
CIBW_SKIP: "pp*"
89+
CIBW_REPAIR_WHEEL_COMMAND: "LD_LIBRARY_PATH=$PWD/llama_cpp/lib auditwheel repair -w {dest_dir} {wheel}"
90+
CIBW_ARCHS: "aarch64"
91+
# Keep this consistent with the x86_64 Linux release wheels.
92+
CIBW_MANYLINUX_AARCH64_IMAGE: "manylinux2014"
93+
# Keep native arm64 builds on a portable CPU baseline instead of
94+
# tuning wheels to the hosted runner.
95+
CIBW_ENVIRONMENT: CMAKE_ARGS="-DGGML_NATIVE=off"
96+
# The release wheel is tagged py3-none, so one build covers all
97+
# supported Python versions and avoids duplicate wheel names.
98+
CIBW_BUILD: "cp38-*"
99+
with:
100+
output-dir: wheelhouse
101+
102+
- name: Upload wheels as artifacts
103+
uses: actions/upload-artifact@v7
104+
with:
105+
name: wheels_arm64
106+
path: ./wheelhouse/*.whl
107+
108+
build_wheels_riscv64:
109+
name: Build riscv64 wheel
60110
runs-on: ubuntu-latest
61111
steps:
62-
- uses: actions/checkout@v4
112+
- uses: actions/checkout@v6
63113
with:
64114
submodules: "recursive"
65115

66116
- name: Set up QEMU
67-
uses: docker/setup-qemu-action@v3
117+
uses: docker/setup-qemu-action@v4
68118
with:
69-
platforms: linux/arm64
119+
platforms: linux/riscv64
70120

71121
- name: Build wheels
72-
uses: pypa/cibuildwheel@v2.22.0
122+
uses: pypa/cibuildwheel@v3.4.1
73123
env:
74124
CIBW_SKIP: "*musllinux* pp*"
75125
CIBW_REPAIR_WHEEL_COMMAND: ""
76-
CIBW_ARCHS: "aarch64"
77-
CIBW_ENVIRONMENT: CMAKE_ARGS="-DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_APPLE_SILICON_PROCESSOR=arm64 -DCMAKE_CROSSCOMPILING=ON"
78-
CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-*"
126+
CIBW_ARCHS: "riscv64"
127+
# Build riscv64 wheels against a conservative baseline instead of
128+
# enabling RVV-related extensions from the build container.
129+
CIBW_ENVIRONMENT: CMAKE_ARGS="-DGGML_NATIVE=off -DGGML_RVV=off -DGGML_RV_ZFH=off -DGGML_RV_ZVFH=off -DGGML_RV_ZICBOP=off -DGGML_RV_ZIHINTPAUSE=off"
130+
# The release wheel is tagged py3-none, so one riscv64 build is
131+
# enough and avoids duplicate same-name release artifacts.
132+
CIBW_BUILD: "cp310-*"
79133
with:
80134
output-dir: wheelhouse
81135

82136
- name: Upload wheels as artifacts
83-
uses: actions/upload-artifact@v4
137+
uses: actions/upload-artifact@v7
84138
with:
85-
name: wheels_arm64
139+
name: wheels_riscv64
140+
path: ./wheelhouse/*.whl
141+
142+
build_wheels_pyodide:
143+
name: Build Pyodide wheel
144+
runs-on: ubuntu-latest
145+
steps:
146+
- uses: actions/checkout@v6
147+
with:
148+
submodules: "recursive"
149+
150+
- uses: actions/setup-python@v6
151+
with:
152+
python-version: "3.12"
153+
154+
- name: Build wheel
155+
uses: pypa/cibuildwheel@v4.1.0
156+
env:
157+
CIBW_PLATFORM: "pyodide"
158+
CIBW_BUILD: "cp314-pyodide_wasm32"
159+
CIBW_BUILD_VERBOSITY: "1"
160+
CIBW_REPAIR_WHEEL_COMMAND: ""
161+
CIBW_BEFORE_TEST: "curl -L --fail --retry 3 -o /tmp/stories260K.gguf https://huggingface.co/ggml-org/models/resolve/main/tinyllamas/stories260K.gguf"
162+
CIBW_TEST_COMMAND: "python -c \"import llama_cpp.mtmd_cpp as mtmd; from llama_cpp import Llama; print('mtmd marker', mtmd.mtmd_default_marker().decode()); llm = Llama(model_path='/tmp/stories260K.gguf', n_ctx=64, n_batch=8, n_threads=1, verbose=False); print('loaded', llm.n_vocab(), llm.n_ctx()); print('generated', llm('Once upon a', max_tokens=1, temperature=0)['choices'][0]['text'])\""
163+
CMAKE_ARGS: "-DLLAMA_WASM_MEM64=OFF -DEMSCRIPTEN_SYSTEM_PROCESSOR=wasm32 -DGGML_NATIVE=OFF -DGGML_OPENMP=OFF -DGGML_METAL=OFF -DGGML_BLAS=OFF -DGGML_CUDA=OFF -DGGML_HIP=OFF -DGGML_VULKAN=OFF -DGGML_OPENCL=OFF -DGGML_RPC=OFF -DLLAMA_CURL=OFF -DLLAMA_BUILD_TESTS=OFF -DLLAMA_BUILD_EXAMPLES=OFF -DLLAMA_BUILD_TOOLS=OFF -DLLAMA_BUILD_SERVER=OFF"
164+
with:
165+
output-dir: wheelhouse
166+
167+
- name: Upload wheels as artifacts
168+
uses: actions/upload-artifact@v7
169+
with:
170+
name: wheels_pyodide
86171
path: ./wheelhouse/*.whl
87172

88173
build_sdist:
89174
name: Build source distribution
90175
runs-on: ubuntu-latest
91176

92177
steps:
93-
- uses: actions/checkout@v4
178+
- uses: actions/checkout@v6
94179
with:
95180
submodules: "recursive"
96181

97-
- uses: actions/setup-python@v5
182+
- uses: actions/setup-python@v6
98183
with:
99184
python-version: "3.9"
100185

@@ -122,23 +207,24 @@ jobs:
122207
run: |
123208
python -m build --sdist
124209
125-
- uses: actions/upload-artifact@v4
210+
- uses: actions/upload-artifact@v7
126211
with:
127212
name: sdist
128213
path: ./dist/*.tar.gz
129214

130215
release:
131216
name: Release
132-
needs: [build_wheels, build_wheels_arm64, build_sdist]
217+
needs: [build_wheels, build_wheels_arm64, build_wheels_riscv64, build_wheels_pyodide, build_sdist]
218+
if: startsWith(github.ref, 'refs/tags/')
133219
runs-on: ubuntu-latest
134220

135221
steps:
136-
- uses: actions/download-artifact@v4
222+
- uses: actions/download-artifact@v8
137223
with:
138224
merge-multiple: true
139225
path: dist
140226

141-
- uses: softprops/action-gh-release@v2
227+
- uses: softprops/action-gh-release@v3
142228
with:
143229
files: dist/*
144230
env:

‎.github/workflows/build-docker.yaml‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,35 @@ jobs:
1212
runs-on: ubuntu-22.04
1313
steps:
1414
- name: Checkout
15-
uses: actions/checkout@v4
15+
uses: actions/checkout@v6
1616
with:
1717
submodules: "recursive"
1818

19+
- name: Set image tag
20+
run: |
21+
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
22+
image_tag="${GITHUB_REF_NAME}"
23+
else
24+
image_tag="${GITHUB_REF_NAME//\//-}"
25+
fi
26+
echo "IMAGE_TAG=$image_tag" >> "$GITHUB_ENV"
27+
1928
- name: Set up QEMU
20-
uses: docker/setup-qemu-action@v3
29+
uses: docker/setup-qemu-action@v4
2130

2231
- name: Set up Docker Buildx
23-
uses: docker/setup-buildx-action@v3
32+
uses: docker/setup-buildx-action@v4
2433

2534
- name: Login to GitHub Container Registry
26-
uses: docker/login-action@v3
35+
uses: docker/login-action@v4
2736
with:
2837
registry: ghcr.io
2938
username: ${{ github.repository_owner }}
3039
password: ${{ secrets.GITHUB_TOKEN }}
3140

3241
- name: Build and push
3342
id: docker_build
34-
uses: docker/build-push-action@v6
43+
uses: docker/build-push-action@v7
3544
with:
3645
context: .
3746
file: "docker/simple/Dockerfile"
@@ -40,7 +49,7 @@ jobs:
4049
platforms: linux/amd64,linux/arm64
4150
tags: |
4251
ghcr.io/abetlen/llama-cpp-python:latest
43-
ghcr.io/abetlen/llama-cpp-python:${{ github.ref_name }}
52+
ghcr.io/abetlen/llama-cpp-python:${{ env.IMAGE_TAG }}
4453
build-args: |
4554
BUILDKIT_INLINE_CACHE=1
4655

0 commit comments

Comments
 (0)