Skip to content

Commit ec223e6

Browse files
committed
Merge branch 'master' into mradermacher
2 parents 053b786 + d01d112 commit ec223e6

Some content is hidden

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

84 files changed

+6514
-3842
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -839,12 +839,12 @@ jobs:
839839
-DGGML_CUDA=ON
840840
cmake --build build
841841
842-
windows-2019-cmake-cuda:
843-
runs-on: windows-2019
842+
windows-2022-cmake-cuda:
843+
runs-on: windows-2022
844844

845845
strategy:
846846
matrix:
847-
cuda: ['12.4', '11.7']
847+
cuda: ['12.4']
848848

849849
steps:
850850
- name: Clone
@@ -878,7 +878,7 @@ jobs:
878878
env:
879879
CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
880880
run: |
881-
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
881+
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
882882
cmake -S . -B build -G "Ninja Multi-Config" ^
883883
-DLLAMA_BUILD_SERVER=ON ^
884884
-DGGML_NATIVE=OFF ^

.github/workflows/release.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ jobs:
131131
include:
132132
- build: 'x64'
133133
os: ubuntu-22.04
134-
- build: 'arm64'
135-
os: ubuntu-22.04-arm
134+
# GGML_BACKEND_DL and GGML_CPU_ALL_VARIANTS are not currently supported on arm
135+
# - build: 'arm64'
136+
# os: ubuntu-22.04-arm
136137

137138
runs-on: ${{ matrix.os }}
138139

@@ -159,6 +160,9 @@ jobs:
159160
id: cmake_build
160161
run: |
161162
cmake -B build \
163+
-DGGML_BACKEND_DL=ON \
164+
-DGGML_NATIVE=OFF \
165+
-DGGML_CPU_ALL_VARIANTS=ON \
162166
-DLLAMA_FATAL_WARNINGS=ON \
163167
${{ env.CMAKE_ARGS }}
164168
cmake --build build --config Release -j $(nproc)
@@ -207,6 +211,9 @@ jobs:
207211
id: cmake_build
208212
run: |
209213
cmake -B build \
214+
-DGGML_BACKEND_DL=ON \
215+
-DGGML_NATIVE=OFF \
216+
-DGGML_CPU_ALL_VARIANTS=ON \
210217
-DGGML_VULKAN=ON \
211218
${{ env.CMAKE_ARGS }}
212219
cmake --build build --config Release -j $(nproc)
@@ -373,11 +380,11 @@ jobs:
373380
name: llama-bin-win-${{ matrix.backend }}-${{ matrix.arch }}.zip
374381

375382
windows-cuda:
376-
runs-on: windows-2019
383+
runs-on: windows-2022
377384

378385
strategy:
379386
matrix:
380-
cuda: ['12.4', '11.7']
387+
cuda: ['12.4']
381388

382389
steps:
383390
- name: Clone
@@ -405,7 +412,7 @@ jobs:
405412
id: cmake_build
406413
shell: cmd
407414
run: |
408-
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
415+
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
409416
cmake -S . -B build -G "Ninja Multi-Config" ^
410417
-DGGML_BACKEND_DL=ON ^
411418
-DGGML_NATIVE=OFF ^

.github/workflows/server.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ jobs:
180180
181181
182182
server-windows:
183-
runs-on: windows-2019
183+
runs-on: windows-2022
184184

185185
steps:
186186
- name: Clone

README.md

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
![llama](https://user-images.githubusercontent.com/1991296/230134379-7181e485-c521-4d23-a0d6-f7b3b61ba524.png)
44

55
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6+
[![Release](https://img.shields.io/github/v/release/ggml-org/llama.cpp)](https://github.com/ggml-org/llama.cpp/releases)
67
[![Server](https://github.com/ggml-org/llama.cpp/actions/workflows/server.yml/badge.svg)](https://github.com/ggml-org/llama.cpp/actions/workflows/server.yml)
78

89
[Roadmap](https://github.com/users/ggerganov/projects/7) / [Project status](https://github.com/ggml-org/llama.cpp/discussions/3471) / [Manifesto](https://github.com/ggml-org/llama.cpp/discussions/205) / [ggml](https://github.com/ggml-org/ggml)
@@ -28,6 +29,30 @@ Inference of Meta's [LLaMA](https://arxiv.org/abs/2302.13971) model (and others)
2829

2930
----
3031

32+
## Quick start
33+
34+
Getting started with llama.cpp is straightforward. Here are several ways to install it on your machine:
35+
36+
- Install `llama.cpp` using [brew, nix or winget](docs/install.md)
37+
- Run with Docker - see our [Docker documentation](docs/docker.md)
38+
- Download pre-built binaries from the [releases page](https://github.com/ggml-org/llama.cpp/releases)
39+
- Build from source by cloning this repository - check out [our build guide](docs/build.md)
40+
41+
Once installed, you'll need a model to work with. Head to the [Obtaining and quantizing models](#obtaining-and-quantizing-models) section to learn more.
42+
43+
Example command:
44+
45+
```sh
46+
# Use a local model file
47+
llama-cli -m my_model.gguf
48+
49+
# Or download and run a model directly from Hugging Face
50+
llama-cli -hf ggml-org/gemma-3-1b-it-GGUF
51+
52+
# Launch OpenAI-compatible API server
53+
llama-server -hf ggml-org/gemma-3-1b-it-GGUF
54+
```
55+
3156
## Description
3257

3358
The main goal of `llama.cpp` is to enable LLM inference with minimal setup and state-of-the-art performance on a wide
@@ -130,6 +155,7 @@ Instructions for adding support for new models: [HOWTO-add-model.md](docs/develo
130155
<details>
131156
<summary>Bindings</summary>
132157

158+
- Python: [ddh0/easy-llama](https://github.com/ddh0/easy-llama)
133159
- Python: [abetlen/llama-cpp-python](https://github.com/abetlen/llama-cpp-python)
134160
- Go: [go-skynet/go-llama.cpp](https://github.com/go-skynet/go-llama.cpp)
135161
- Node.js: [withcatai/node-llama-cpp](https://github.com/withcatai/node-llama-cpp)
@@ -229,6 +255,7 @@ Instructions for adding support for new models: [HOWTO-add-model.md](docs/develo
229255

230256
</details>
231257

258+
232259
## Supported backends
233260

234261
| Backend | Target devices |
@@ -245,24 +272,18 @@ Instructions for adding support for new models: [HOWTO-add-model.md](docs/develo
245272
| [OpenCL](docs/backend/OPENCL.md) | Adreno GPU |
246273
| [RPC](https://github.com/ggml-org/llama.cpp/tree/master/tools/rpc) | All |
247274

248-
## Building the project
249-
250-
The main product of this project is the `llama` library. Its C-style interface can be found in [include/llama.h](include/llama.h).
251-
The project also includes many example programs and tools using the `llama` library. The examples range from simple, minimal code snippets to sophisticated sub-projects such as an OpenAI-compatible HTTP server. Possible methods for obtaining the binaries:
252-
253-
- Clone this repository and build locally, see [how to build](docs/build.md)
254-
- On MacOS or Linux, install `llama.cpp` via [brew, flox or nix](docs/install.md)
255-
- Use a Docker image, see [documentation for Docker](docs/docker.md)
256-
- Download pre-built binaries from [releases](https://github.com/ggml-org/llama.cpp/releases)
257-
258275
## Obtaining and quantizing models
259276

260277
The [Hugging Face](https://huggingface.co) platform hosts a [number of LLMs](https://huggingface.co/models?library=gguf&sort=trending) compatible with `llama.cpp`:
261278

262279
- [Trending](https://huggingface.co/models?library=gguf&sort=trending)
263280
- [LLaMA](https://huggingface.co/models?sort=trending&search=llama+gguf)
264281

265-
You can either manually download the GGUF file or directly use any `llama.cpp`-compatible models from [Hugging Face](https://huggingface.co/) or other model hosting sites, such as [ModelScope](https://modelscope.cn/), by using this CLI argument: `-hf <user>/<model>[:quant]`.
282+
You can either manually download the GGUF file or directly use any `llama.cpp`-compatible models from [Hugging Face](https://huggingface.co/) or other model hosting sites, such as [ModelScope](https://modelscope.cn/), by using this CLI argument: `-hf <user>/<model>[:quant]`. For example:
283+
284+
```sh
285+
llama-cli -hf ggml-org/gemma-3-1b-it-GGUF
286+
```
266287

267288
By default, the CLI would download from Hugging Face, you can switch to other options with the environment variable `MODEL_ENDPOINT`. For example, you may opt to downloading model checkpoints from ModelScope or other model sharing communities by setting the environment variable, e.g. `MODEL_ENDPOINT=https://www.modelscope.cn/`.
268289

common/arg.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,9 +1348,9 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
13481348
));
13491349
add_opt(common_arg(
13501350
{"--prio"}, "N",
1351-
string_format("set process/thread priority : 0-normal, 1-medium, 2-high, 3-realtime (default: %d)\n", params.cpuparams.priority),
1351+
string_format("set process/thread priority : low(-1), normal(0), medium(1), high(2), realtime(3) (default: %d)\n", params.cpuparams.priority),
13521352
[](common_params & params, int prio) {
1353-
if (prio < 0 || prio > 3) {
1353+
if (prio < GGML_SCHED_PRIO_LOW || prio > GGML_SCHED_PRIO_REALTIME) {
13541354
throw std::invalid_argument("invalid value");
13551355
}
13561356
params.cpuparams.priority = (enum ggml_sched_priority) prio;
@@ -2869,6 +2869,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
28692869
"(default: deepseek)",
28702870
[](common_params & params, const std::string & value) {
28712871
/**/ if (value == "deepseek") { params.reasoning_format = COMMON_REASONING_FORMAT_DEEPSEEK; }
2872+
else if (value == "deepseek-legacy") { params.reasoning_format = COMMON_REASONING_FORMAT_DEEPSEEK_LEGACY; }
28722873
else if (value == "none") { params.reasoning_format = COMMON_REASONING_FORMAT_NONE; }
28732874
else { throw std::invalid_argument("invalid value"); }
28742875
}

common/chat-parser.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,10 @@ bool common_chat_msg_parser::try_parse_reasoning(const std::string & start_think
154154
if (!rest.empty()) {
155155
handle_reasoning(rest, /* closed */ !is_partial());
156156
}
157-
if (!syntax_.thinking_forced_open) {
158-
throw common_chat_msg_partial_exception(end_think);
159-
}
157+
// Allow unclosed thinking tags, for now (https://github.com/ggml-org/llama.cpp/issues/13812, https://github.com/ggml-org/llama.cpp/issues/13877)
158+
// if (!syntax_.thinking_forced_open) {
159+
// throw common_chat_msg_partial_exception(end_think);
160+
// }
160161
return true;
161162
}
162163
}

common/chat.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ json common_chat_msg::to_json_oaicompat() const
8282

8383
std::vector<common_chat_msg_diff> common_chat_msg_diff::compute_diffs(const common_chat_msg & previous_msg, const common_chat_msg & new_msg) {
8484
std::vector<common_chat_msg_diff> diffs;
85-
// if (previous_msg.reasoning_content != current.reasoning_content) {
86-
// auto & diff = diffs.emplace_back();
87-
// diff.reasoning_content_delta = string_diff(previous_msg.reasoning_content, current.reasoning_content);
88-
// }
85+
if (previous_msg.reasoning_content != new_msg.reasoning_content) {
86+
auto & diff = diffs.emplace_back();
87+
diff.reasoning_content_delta = string_diff(previous_msg.reasoning_content, new_msg.reasoning_content);
88+
}
8989
if (previous_msg.content != new_msg.content) {
9090
auto & diff = diffs.emplace_back();
9191
diff.content_delta = string_diff(previous_msg.content, new_msg.content);
@@ -385,9 +385,9 @@ json common_chat_tools_to_json_oaicompat(const std::vector<common_chat_tool> & t
385385

386386
template <> json common_chat_msg_diff_to_json_oaicompat(const common_chat_msg_diff & diff) {
387387
json delta = json::object();
388-
// if (!diff.reasoning_content_delta.empty()) {
389-
// delta["reasoning_content"] = msg.reasoning_content;
390-
// }
388+
if (!diff.reasoning_content_delta.empty()) {
389+
delta["reasoning_content"] = diff.reasoning_content_delta;
390+
}
391391
if (!diff.content_delta.empty()) {
392392
delta["content"] = diff.content_delta;
393393
}
@@ -598,6 +598,7 @@ const char * common_reasoning_format_name(common_reasoning_format format) {
598598
switch (format) {
599599
case COMMON_REASONING_FORMAT_NONE: return "none";
600600
case COMMON_REASONING_FORMAT_DEEPSEEK: return "deepseek";
601+
case COMMON_REASONING_FORMAT_DEEPSEEK_LEGACY: return "deepseek-legacy";
601602
default:
602603
throw std::runtime_error("Unknown reasoning format");
603604
}

common/chat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct common_chat_msg {
7070
};
7171

7272
struct common_chat_msg_diff {
73-
// std::string reasoning_content_delta;
73+
std::string reasoning_content_delta;
7474
std::string content_delta;
7575
size_t tool_call_index = std::string::npos;
7676
common_chat_tool_call tool_call_delta;

common/common.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ bool set_process_priority(enum ggml_sched_priority prio) {
203203

204204
DWORD p = NORMAL_PRIORITY_CLASS;
205205
switch (prio) {
206+
case GGML_SCHED_PRIO_LOW: p = BELOW_NORMAL_PRIORITY_CLASS; break;
206207
case GGML_SCHED_PRIO_NORMAL: p = NORMAL_PRIORITY_CLASS; break;
207208
case GGML_SCHED_PRIO_MEDIUM: p = ABOVE_NORMAL_PRIORITY_CLASS; break;
208209
case GGML_SCHED_PRIO_HIGH: p = HIGH_PRIORITY_CLASS; break;
@@ -228,6 +229,7 @@ bool set_process_priority(enum ggml_sched_priority prio) {
228229

229230
int p = 0;
230231
switch (prio) {
232+
case GGML_SCHED_PRIO_LOW: p = 5; break;
231233
case GGML_SCHED_PRIO_NORMAL: p = 0; break;
232234
case GGML_SCHED_PRIO_MEDIUM: p = -5; break;
233235
case GGML_SCHED_PRIO_HIGH: p = -10; break;

common/common.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ struct common_params_vocoder {
215215

216216
enum common_reasoning_format {
217217
COMMON_REASONING_FORMAT_NONE,
218-
COMMON_REASONING_FORMAT_DEEPSEEK, // Extract thinking tag contents and return as `message.reasoning_content`
218+
COMMON_REASONING_FORMAT_DEEPSEEK_LEGACY, // Extract thinking tag contents and return as `message.reasoning_content`, or leave inline in <think> tags in stream mode
219+
COMMON_REASONING_FORMAT_DEEPSEEK, // Extract thinking tag contents and return as `message.reasoning_content`, including in streaming deltas.
219220
};
220221

221222
struct common_params {

0 commit comments

Comments
 (0)