Skip to content

Commit 3970042

Browse files
committed
Merge branch 'master' into xsn/server_separate_pos_tokens
2 parents de8956a + 518329b commit 3970042

File tree

31 files changed

+690
-551
lines changed

31 files changed

+690
-551
lines changed

.github/actions/windows-setup-curl/action.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ inputs:
55
description: 'CURL version'
66
required: false
77
default: '8.6.0_6'
8+
architecture:
9+
description: 'Architecture of the libcurl to download'
10+
required: false
11+
default: 'win64'
812
outputs:
913
curl_path:
1014
description: "Path to the downloaded libcurl"
@@ -18,8 +22,9 @@ runs:
1822
shell: powershell
1923
env:
2024
CURL_VERSION: ${{ inputs.curl_version }}
25+
ARCHITECTURE: ${{ inputs.architecture }}
2126
run: |
22-
curl.exe -o $env:RUNNER_TEMP/curl.zip -L "https://curl.se/windows/dl-${env:CURL_VERSION}/curl-${env:CURL_VERSION}-win64-mingw.zip"
27+
curl.exe -o $env:RUNNER_TEMP/curl.zip -L "https://curl.se/windows/dl-${env:CURL_VERSION}/curl-${env:CURL_VERSION}-${env:ARCHITECTURE}-mingw.zip"
2328
mkdir $env:RUNNER_TEMP/libcurl
2429
tar.exe -xvf $env:RUNNER_TEMP/curl.zip --strip-components=1 -C $env:RUNNER_TEMP/libcurl
2530
echo "curl_path=$env:RUNNER_TEMP/libcurl" >> $env:GITHUB_OUTPUT

.github/workflows/build-linux-cross.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,94 @@ jobs:
140140
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH
141141
142142
cmake --build build --config Release -j $(nproc)
143+
144+
ubuntu-24-ppc64el-cpu-cross:
145+
runs-on: ubuntu-24.04
146+
147+
steps:
148+
- uses: actions/checkout@v4
149+
- name: Setup PowerPC64le
150+
run: |
151+
sudo dpkg --add-architecture ppc64el
152+
153+
# Add arch-specific repositories for non-amd64 architectures
154+
cat << EOF | sudo tee /etc/apt/sources.list.d/ppc64el-ports.list
155+
deb [arch=ppc64el] http://ports.ubuntu.com/ubuntu-ports/ noble main universe
156+
deb [arch=ppc64el] http://ports.ubuntu.com/ubuntu-ports/ noble-updates main universe
157+
deb [arch=ppc64el] http://ports.ubuntu.com/ubuntu-ports/ noble-security main universe
158+
deb [arch=ppc64el] http://ports.ubuntu.com/ubuntu-ports/ noble-backports main universe
159+
EOF
160+
161+
sudo apt-get update || true ;# Prevent failure due to missing URLs.
162+
163+
sudo apt-get install -y --no-install-recommends \
164+
build-essential \
165+
gcc-14-powerpc64le-linux-gnu \
166+
g++-14-powerpc64le-linux-gnu \
167+
libcurl4-openssl-dev:ppc64el
168+
169+
- name: Build
170+
run: |
171+
cmake -B build -DCMAKE_BUILD_TYPE=Release \
172+
-DGGML_OPENMP=OFF \
173+
-DLLAMA_BUILD_EXAMPLES=ON \
174+
-DLLAMA_BUILD_TOOLS=ON \
175+
-DLLAMA_BUILD_TESTS=OFF \
176+
-DCMAKE_SYSTEM_NAME=Linux \
177+
-DCMAKE_SYSTEM_PROCESSOR=ppc64 \
178+
-DCMAKE_C_COMPILER=powerpc64le-linux-gnu-gcc-14 \
179+
-DCMAKE_CXX_COMPILER=powerpc64le-linux-gnu-g++-14 \
180+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
181+
-DCMAKE_FIND_ROOT_PATH=/usr/lib/powerpc64le-linux-gnu \
182+
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
183+
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
184+
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH
185+
186+
cmake --build build --config Release -j $(nproc)
187+
188+
ubuntu-24-ppc64el-vulkan-cross:
189+
runs-on: ubuntu-24.04
190+
191+
steps:
192+
- uses: actions/checkout@v4
193+
- name: Setup PowerPC64le
194+
run: |
195+
sudo dpkg --add-architecture ppc64el
196+
197+
# Add arch-specific repositories for non-amd64 architectures
198+
cat << EOF | sudo tee /etc/apt/sources.list.d/ppc64el-ports.list
199+
deb [arch=ppc64el] http://ports.ubuntu.com/ubuntu-ports/ noble main universe
200+
deb [arch=ppc64el] http://ports.ubuntu.com/ubuntu-ports/ noble-updates main universe
201+
deb [arch=ppc64el] http://ports.ubuntu.com/ubuntu-ports/ noble-security main universe
202+
deb [arch=ppc64el] http://ports.ubuntu.com/ubuntu-ports/ noble-backports main universe
203+
EOF
204+
205+
sudo apt-get update || true ;# Prevent failure due to missing URLs.
206+
207+
sudo apt-get install -y --no-install-recommends \
208+
build-essential \
209+
glslc \
210+
gcc-14-powerpc64le-linux-gnu \
211+
g++-14-powerpc64le-linux-gnu \
212+
libvulkan-dev:ppc64el \
213+
libcurl4-openssl-dev:ppc64el
214+
215+
- name: Build
216+
run: |
217+
cmake -B build -DCMAKE_BUILD_TYPE=Release \
218+
-DGGML_VULKAN=ON \
219+
-DGGML_OPENMP=OFF \
220+
-DLLAMA_BUILD_EXAMPLES=ON \
221+
-DLLAMA_BUILD_TOOLS=ON \
222+
-DLLAMA_BUILD_TESTS=OFF \
223+
-DCMAKE_SYSTEM_NAME=Linux \
224+
-DCMAKE_SYSTEM_PROCESSOR=ppc64 \
225+
-DCMAKE_C_COMPILER=powerpc64le-linux-gnu-gcc-14 \
226+
-DCMAKE_CXX_COMPILER=powerpc64le-linux-gnu-g++-14 \
227+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
228+
-DCMAKE_FIND_ROOT_PATH=/usr/lib/powerpc64le-linux-gnu \
229+
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
230+
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
231+
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH
232+
233+
cmake --build build --config Release -j $(nproc)

.github/workflows/release.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,19 @@ jobs:
238238
matrix:
239239
include:
240240
- build: 'cpu-x64'
241+
arch: 'x64'
241242
defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/x64-windows-llvm.cmake -DGGML_NATIVE=OFF -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DGGML_OPENMP=OFF'
242243
#- build: 'openblas-x64'
244+
# arch: 'x64'
243245
# defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/x64-windows-llvm.cmake -DGGML_NATIVE=OFF -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DGGML_OPENMP=OFF -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS="$env:RUNNER_TEMP/openblas/include" -DBLAS_LIBRARIES="$env:RUNNER_TEMP/openblas/lib/openblas.lib"'
244246
- build: 'vulkan-x64'
247+
arch: 'x64'
245248
defines: '-DGGML_NATIVE=OFF -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DGGML_VULKAN=ON'
246249
- build: 'cpu-arm64'
250+
arch: 'arm64'
247251
defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DGGML_NATIVE=OFF'
248252
- build: 'opencl-adreno-arm64'
253+
arch: 'arm64'
249254
defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DCMAKE_PREFIX_PATH="$env:RUNNER_TEMP/opencl-arm64-release" -DGGML_OPENCL=ON -DGGML_OPENCL_USE_ADRENO_KERNELS=ON'
250255

251256
steps:
@@ -312,6 +317,8 @@ jobs:
312317
- name: libCURL
313318
id: get_libcurl
314319
uses: ./.github/actions/windows-setup-curl
320+
with:
321+
architecture: ${{ matrix.arch == 'x64' && 'win64' || 'win64a' }}
315322

316323
- name: Build
317324
id: cmake_build
@@ -339,7 +346,7 @@ jobs:
339346
env:
340347
CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
341348
run: |
342-
Copy-Item $env:CURL_PATH\bin\libcurl-x64.dll .\build\bin\Release\libcurl-x64.dll
349+
Copy-Item $env:CURL_PATH\bin\libcurl-${{ matrix.arch }}.dll .\build\bin\Release\
343350
7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip .\build\bin\Release\*
344351
345352
- name: Upload artifacts

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,4 +572,11 @@ automatically. For example:
572572
$ echo "source ~/.llama-completion.bash" >> ~/.bashrc
573573
```
574574
575-
## References
575+
## Dependencies
576+
577+
- [yhirose/cpp-httplib](https://github.com/yhirose/cpp-httplib) - Single-header HTTP server, used by `llama-server` - MIT license
578+
- [stb-image](https://github.com/nothings/stb) - Single-header image format decoder, used by multimodal subsystem - Public domain
579+
- [nlohmann/json](https://github.com/nlohmann/json) - Single-header JSON library, used by various tools/examples - MIT License
580+
- [minja](https://github.com/google/minja) - Minimal Jinja parser in C++, used by various tools/examples - MIT License
581+
- [linenoise.cpp](./tools/run/linenoise.cpp/linenoise.cpp) - C++ library that provides readline-like line editing capabilities, used by `llama-run` - BSD 2-Clause License
582+
- [curl](https://curl.se/) - Client-side URL transfer library, used by various tools/examples - [CURL License](https://curl.se/docs/copyright.html)

common/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ if (LLAMA_LLGUIDANCE)
121121

122122
ExternalProject_Add(llguidance_ext
123123
GIT_REPOSITORY https://github.com/guidance-ai/llguidance
124-
# v0.7.19 (+ fancy-regex build fix):
125-
GIT_TAG b59f98f85269892a7de3d3641ad155366f13daa6
124+
# v0.7.20 (+ fix to build on GCC 15):
125+
GIT_TAG b5b8b64dba11c4e4ee6b1d1450d3a3ae279891e8
126126
PREFIX ${CMAKE_BINARY_DIR}/llguidance
127127
SOURCE_DIR ${LLGUIDANCE_SRC}
128128
BUILD_IN_SOURCE TRUE

common/arg.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2585,7 +2585,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
25852585
[](common_params & params, int value) {
25862586
params.n_junk = value;
25872587
}
2588-
).set_examples({LLAMA_EXAMPLE_PASSKEY}));
2588+
).set_examples({LLAMA_EXAMPLE_PASSKEY, LLAMA_EXAMPLE_PARALLEL}));
25892589
add_opt(common_arg(
25902590
{"--pos"}, "N",
25912591
string_format("position of the passkey in the junk text (default: %d)", params.i_pos),
@@ -2648,7 +2648,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
26482648
[](common_params & params) {
26492649
params.is_pp_shared = true;
26502650
}
2651-
).set_examples({LLAMA_EXAMPLE_BENCH}));
2651+
).set_examples({LLAMA_EXAMPLE_BENCH, LLAMA_EXAMPLE_PARALLEL}));
26522652
add_opt(common_arg(
26532653
{"-npp"}, "n0,n1,...",
26542654
"number of prompt tokens",

common/minja/chat-template.hpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
#include <chrono>
1414
#include <cstddef>
1515
#include <cstdio>
16+
#include <ctime>
1617
#include <exception>
1718
#include <iomanip>
1819
#include <memory>
1920
#include <sstream>
21+
#include <stdexcept>
2022
#include <string>
2123
#include <vector>
2224

@@ -393,8 +395,8 @@ class chat_template {
393395

394396
for (const auto & message_ : adjusted_messages) {
395397
auto message = message_;
396-
if (!message.contains("role") || !message.contains("content")) {
397-
throw std::runtime_error("message must have 'role' and 'content' fields: " + message.dump());
398+
if (!message.contains("role") || (!message.contains("content") && !message.contains("tool_calls"))) {
399+
throw std::runtime_error("message must have 'role' and one of 'content' or 'tool_calls' fields: " + message.dump());
398400
}
399401
std::string role = message.at("role");
400402

@@ -415,7 +417,6 @@ class chat_template {
415417
}
416418
}
417419
if (polyfill_tool_calls) {
418-
auto content = message.at("content");
419420
auto tool_calls = json::array();
420421
for (const auto & tool_call : message.at("tool_calls")) {
421422
if (tool_call.at("type") != "function") {
@@ -434,8 +435,11 @@ class chat_template {
434435
auto obj = json {
435436
{"tool_calls", tool_calls},
436437
};
437-
if (!content.is_null() && !content.empty()) {
438-
obj["content"] = content;
438+
if (message.contains("content")) {
439+
auto content = message.at("content");
440+
if (!content.is_null() && !content.empty()) {
441+
obj["content"] = content;
442+
}
439443
}
440444
message["content"] = obj.dump(2);
441445
message.erase("tool_calls");

0 commit comments

Comments
 (0)