Skip to content

Commit d7edc55

Browse files
authored
Merge branch 'master' into qwen2-vl
2 parents b24ab86 + 43041d2 commit d7edc55

File tree

201 files changed

+13898
-33249
lines changed

Some content is hidden

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

201 files changed

+13898
-33249
lines changed

.clang-tidy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ Checks: >
1717
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
1818
performance-*,
1919
portability-*,
20+
-portability-simd-intrinsics,
2021
misc-*,
2122
-misc-const-correctness,
2223
-misc-non-private-member-variables-in-classes,
2324
-misc-no-recursion,
25+
-misc-use-anonymous-namespace,
2426
FormatStyle: none

.devops/full.Dockerfile

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,36 @@ ARG UBUNTU_VERSION=22.04
33
FROM ubuntu:$UBUNTU_VERSION AS build
44

55
RUN apt-get update && \
6-
apt-get install -y build-essential python3 python3-pip git libcurl4-openssl-dev libgomp1
6+
apt-get install -y build-essential git cmake libcurl4-openssl-dev
7+
8+
WORKDIR /app
9+
10+
COPY . .
711

8-
COPY requirements.txt requirements.txt
9-
COPY requirements requirements
12+
RUN cmake -S . -B build -DGGML_BACKEND_DL=ON -DGGML_NATIVE=OFF -DGGML_CPU_ALL_VARIANTS=ON -DLLAMA_CURL=ON -DCMAKE_BUILD_TYPE=Release && \
13+
cmake --build build -j $(nproc) && \
14+
mkdir -p /app/lib && \
15+
find build -name "*.so" -exec cp {} /app/lib/ \;
1016

11-
RUN pip install --upgrade pip setuptools wheel \
12-
&& pip install -r requirements.txt
17+
FROM ubuntu:$UBUNTU_VERSION as runtime
1318

1419
WORKDIR /app
1520

16-
COPY . .
21+
RUN apt-get update && \
22+
apt-get install -y build-essential python3 python3-pip git libcurl4-openssl-dev libgomp1
1723

18-
ENV LLAMA_CURL=1
24+
COPY requirements.txt /app/requirements.txt
25+
COPY requirements /app/requirements
26+
COPY .devops/tools.sh /app/tools.sh
1927

28+
RUN pip install --upgrade pip setuptools wheel && \
29+
pip install -r /app/requirements.txt
2030

21-
RUN make -j$(nproc)
31+
COPY --from=build /app/build/bin/ /app/
32+
COPY --from=build /app/lib/ /app/
33+
COPY --from=build /app/convert_hf_to_gguf.py /app/
34+
COPY --from=build /app/gguf-py /app/gguf-py
2235

2336
ENV LC_ALL=C.utf8
2437

25-
ENTRYPOINT ["/app/.devops/tools.sh"]
38+
ENTRYPOINT ["/app/tools.sh"]

.devops/llama-cli.Dockerfile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,27 @@ ARG UBUNTU_VERSION=22.04
33
FROM ubuntu:$UBUNTU_VERSION AS build
44

55
RUN apt-get update && \
6-
apt-get install -y build-essential git
6+
apt-get install -y build-essential git cmake libcurl4-openssl-dev
77

88
WORKDIR /app
99

1010
COPY . .
1111

12-
RUN make -j$(nproc) llama-cli
12+
RUN cmake -S . -B build -DGGML_BACKEND_DL=ON -DGGML_NATIVE=OFF -DGGML_CPU_ALL_VARIANTS=ON -DLLAMA_CURL=ON -DCMAKE_BUILD_TYPE=Release && \
13+
cmake --build build -j $(nproc) && \
14+
mkdir -p /app/lib && \
15+
find build -name "*.so" -exec cp {} /app/lib/ \;
1316

1417
FROM ubuntu:$UBUNTU_VERSION AS runtime
1518

19+
WORKDIR /app
20+
1621
RUN apt-get update && \
17-
apt-get install -y libgomp1
22+
apt-get install -y libcurl4-openssl-dev libgomp1 curl
1823

19-
COPY --from=build /app/llama-cli /llama-cli
24+
COPY --from=build /app/build/bin/llama-cli /app/
25+
COPY --from=build /app/lib/ /app/
2026

2127
ENV LC_ALL=C.utf8
2228

23-
ENTRYPOINT [ "/llama-cli" ]
29+
ENTRYPOINT [ "/app/llama-cli" ]

.devops/llama-server.Dockerfile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,31 @@ ARG UBUNTU_VERSION=22.04
33
FROM ubuntu:$UBUNTU_VERSION AS build
44

55
RUN apt-get update && \
6-
apt-get install -y build-essential git libcurl4-openssl-dev
6+
apt-get install -y build-essential git cmake libcurl4-openssl-dev
77

88
WORKDIR /app
99

1010
COPY . .
1111

12-
ENV LLAMA_CURL=1
13-
14-
RUN make -j$(nproc) llama-server
12+
RUN cmake -S . -B build -DGGML_BACKEND_DL=ON -DGGML_NATIVE=OFF -DGGML_CPU_ALL_VARIANTS=ON -DLLAMA_CURL=ON -DCMAKE_BUILD_TYPE=Release && \
13+
cmake --build build -j $(nproc) && \
14+
mkdir -p /app/lib && \
15+
find build -name "*.so" -exec cp {} /app/lib/ \;
1516

1617
FROM ubuntu:$UBUNTU_VERSION AS runtime
1718

19+
WORKDIR /app
20+
1821
RUN apt-get update && \
1922
apt-get install -y libcurl4-openssl-dev libgomp1 curl
2023

21-
COPY --from=build /app/llama-server /llama-server
24+
COPY --from=build /app/build/bin/llama-server /app/
25+
COPY --from=build /app/lib/ /app/
2226

2327
ENV LC_ALL=C.utf8
2428
# Must be set to 0.0.0.0 so it can listen to requests from host machine
2529
ENV LLAMA_ARG_HOST=0.0.0.0
2630

2731
HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]
2832

29-
ENTRYPOINT [ "/llama-server" ]
33+
ENTRYPOINT [ "/app/llama-server" ]

.github/pull_request_template.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
2-
3-
- [x] I have read the [contributing guidelines](https://github.com/ggerganov/llama.cpp/blob/master/CONTRIBUTING.md)
4-
- Self-reported review complexity:
5-
- [ ] Low
6-
- [ ] Medium
7-
- [ ] High
1+
*Make sure to read the [contributing guidelines](https://github.com/ggerganov/llama.cpp/blob/master/CONTRIBUTING.md) before submitting a PR*

.github/workflows/build.yml

Lines changed: 45 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -160,66 +160,6 @@ jobs:
160160
path: llama-${{ steps.tag.outputs.name }}-bin-macos-x64.zip
161161
name: llama-bin-macos-x64.zip
162162

163-
ubuntu-focal-make:
164-
runs-on: ubuntu-20.04
165-
env:
166-
LLAMA_NODE_AVAILABLE: true
167-
LLAMA_PYTHON_AVAILABLE: true
168-
169-
steps:
170-
- name: Clone
171-
id: checkout
172-
uses: actions/checkout@v4
173-
174-
- name: Dependencies
175-
id: depends
176-
run: |
177-
sudo apt-get update
178-
sudo apt-get install build-essential gcc-8
179-
180-
- uses: actions/setup-node@v4
181-
with:
182-
node-version: "20"
183-
184-
- uses: actions/setup-python@v5
185-
with:
186-
python-version: "3.11"
187-
188-
- name: Build
189-
id: make_build
190-
env:
191-
LLAMA_FATAL_WARNINGS: 1
192-
run: |
193-
CC=gcc-8 make -j $(nproc)
194-
195-
- name: Test
196-
id: make_test
197-
run: |
198-
CC=gcc-8 make tests -j $(nproc)
199-
make test -j $(nproc)
200-
201-
ubuntu-focal-make-curl:
202-
runs-on: ubuntu-20.04
203-
204-
steps:
205-
- name: Clone
206-
id: checkout
207-
uses: actions/checkout@v4
208-
209-
- name: Dependencies
210-
id: depends
211-
run: |
212-
sudo apt-get update
213-
sudo apt-get install build-essential gcc-8 libcurl4-openssl-dev
214-
215-
- name: Build
216-
id: make_build
217-
env:
218-
LLAMA_FATAL_WARNINGS: 1
219-
LLAMA_CURL: 1
220-
run: |
221-
CC=gcc-8 make -j $(nproc)
222-
223163
ubuntu-latest-cmake:
224164
runs-on: ubuntu-latest
225165

@@ -517,36 +457,6 @@ jobs:
517457
cmake -DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DGGML_SYCL_F16=ON ..
518458
cmake --build . --config Release -j $(nproc)
519459
520-
# TODO: build with GGML_NO_METAL because test-backend-ops fail on "Apple Paravirtual device" and I don't know
521-
# how to debug it.
522-
# ref: https://github.com/ggerganov/llama.cpp/actions/runs/7131777249/job/19420981052#step:5:1124
523-
macOS-latest-make:
524-
runs-on: macos-latest
525-
526-
steps:
527-
- name: Clone
528-
id: checkout
529-
uses: actions/checkout@v4
530-
531-
- name: Dependencies
532-
id: depends
533-
continue-on-error: true
534-
run: |
535-
brew update
536-
537-
- name: Build
538-
id: make_build
539-
env:
540-
LLAMA_FATAL_WARNINGS: 1
541-
run: |
542-
GGML_NO_METAL=1 make -j $(sysctl -n hw.logicalcpu)
543-
544-
- name: Test
545-
id: make_test
546-
run: |
547-
GGML_NO_METAL=1 make tests -j $(sysctl -n hw.logicalcpu)
548-
GGML_NO_METAL=1 make test -j $(sysctl -n hw.logicalcpu)
549-
550460
# TODO: build with GGML_METAL=OFF because test-backend-ops fail on "Apple Paravirtual device" and I don't know
551461
# how to debug it.
552462
# ref: https://github.com/ggerganov/llama.cpp/actions/runs/7132125951/job/19422043567?pr=4359#step:5:6584
@@ -660,15 +570,26 @@ jobs:
660570
run: |
661571
brew update
662572
663-
- name: xcodebuild for swift package
664-
id: xcodebuild
573+
- name: Build llama.cpp with CMake
574+
id: cmake_build
665575
run: |
666-
xcodebuild -scheme llama -destination "${{ matrix.destination }}"
576+
sysctl -a
577+
mkdir build
578+
cd build
579+
cmake -G Xcode .. \
580+
-DGGML_METAL_USE_BF16=ON \
581+
-DGGML_METAL_EMBED_LIBRARY=ON \
582+
-DLLAMA_BUILD_EXAMPLES=OFF \
583+
-DLLAMA_BUILD_TESTS=OFF \
584+
-DLLAMA_BUILD_SERVER=OFF \
585+
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
586+
cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
587+
sudo cmake --install . --config Release
667588
668-
- name: Build Swift Example
669-
id: make_build_swift_example
589+
- name: xcodebuild for swift package
590+
id: xcodebuild
670591
run: |
671-
make swift
592+
xcodebuild -scheme llama-Package -destination "${{ matrix.destination }}"
672593
673594
windows-msys2:
674595
runs-on: windows-latest
@@ -695,21 +616,6 @@ jobs:
695616
mingw-w64-${{matrix.env}}-cmake
696617
mingw-w64-${{matrix.env}}-openblas
697618
698-
- name: Build using make
699-
shell: msys2 {0}
700-
run: |
701-
make -j $(nproc)
702-
703-
- name: Clean after building using make
704-
shell: msys2 {0}
705-
run: |
706-
make clean
707-
708-
- name: Build using make w/ OpenBLAS
709-
shell: msys2 {0}
710-
run: |
711-
make GGML_OPENBLAS=1 -j $(nproc)
712-
713619
- name: Build using CMake
714620
shell: msys2 {0}
715621
run: |
@@ -1121,6 +1027,11 @@ jobs:
11211027
run: |
11221028
& 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
11231029
1030+
- name: Install ccache
1031+
uses: hendrikmuhs/[email protected]
1032+
with:
1033+
key: ${{ github.job }}
1034+
11241035
- name: Build
11251036
id: cmake_build
11261037
run: |
@@ -1202,6 +1113,29 @@ jobs:
12021113
- name: Checkout code
12031114
uses: actions/checkout@v4
12041115

1116+
- name: Build
1117+
id: cmake_build
1118+
run: |
1119+
sysctl -a
1120+
mkdir build
1121+
cd build
1122+
cmake -G Xcode .. \
1123+
-DGGML_METAL_USE_BF16=ON \
1124+
-DGGML_METAL_EMBED_LIBRARY=ON \
1125+
-DLLAMA_BUILD_EXAMPLES=OFF \
1126+
-DLLAMA_BUILD_TESTS=OFF \
1127+
-DLLAMA_BUILD_SERVER=OFF \
1128+
-DCMAKE_SYSTEM_NAME=iOS \
1129+
-DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
1130+
-DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
1131+
cmake --build . --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
1132+
sudo cmake --install . --config Release
1133+
1134+
- name: xcodebuild for swift package
1135+
id: xcodebuild
1136+
run: |
1137+
xcodebuild -scheme llama-Package -destination 'generic/platform=iOS'
1138+
12051139
- name: Build Xcode project
12061140
run: xcodebuild -project examples/llama.swiftui/llama.swiftui.xcodeproj -scheme llama.swiftui -sdk iphoneos CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= -destination 'generic/platform=iOS' build
12071141

@@ -1229,32 +1163,13 @@ jobs:
12291163
12301164
./gradlew build --no-daemon
12311165
1232-
# freeBSD-latest:
1233-
# runs-on: macos-12
1234-
# steps:
1235-
# - name: Clone
1236-
# uses: actions/checkout@v4
1237-
#
1238-
# - name: Build
1239-
# uses: cross-platform-actions/[email protected]
1240-
# with:
1241-
# operating_system: freebsd
1242-
# version: '13.2'
1243-
# hypervisor: 'qemu'
1244-
# run: |
1245-
# sudo pkg update
1246-
# sudo pkg install -y gmake automake autoconf pkgconf llvm15 openblas
1247-
# gmake CC=/usr/local/bin/clang15 CXX=/usr/local/bin/clang++15 -j `sysctl -n hw.ncpu`
1248-
12491166
release:
12501167
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
12511168

12521169
runs-on: ubuntu-latest
12531170

12541171
needs:
1255-
- ubuntu-focal-make
12561172
- ubuntu-latest-cmake
1257-
- macOS-latest-make
12581173
- macOS-latest-cmake
12591174
- windows-latest-cmake
12601175
- windows-2019-cmake-cuda

0 commit comments

Comments
 (0)