LLM inference in C/C++
manifesto / ggml / ops / maintainer PRs / compile times / lib llama API / llama-server REST API
This fork adds inference support for the internally developed
Spark2_5ForCausalLM model. The following commands build llama.cpp, convert a
local Hugging Face checkpoint to GGUF, and run it on CPU or an NVIDIA GPU.
For an NVIDIA CUDA build:
cmake -B build -DGGML_CUDA=ON
cmake --build build --config Release -j 8
For a CPU-only build, use -DGGML_CUDA=OFF instead. The CUDA build also
contains the CPU backend, so the same binaries can be used for both examples
below.
Install the Python conversion dependencies:
python -m pip install -r requirements.txt
The Spark2_5 checkpoint stores its tokenizer under v8_2_token. The converter
expects the tokenizer files next to config.json and the model .safetensors
files, so copy them to the checkpoint root before conversion:
mkdir -p models
cp /path/to/spark2_5-hf/v8_2_token/{tokenizer.json,tokenizer_config.json,merges.txt} \
/path/to/spark2_5-hf/
python convert_hf_to_gguf.py /path/to/spark2_5-hf \
--outfile models/spark2_5-1.7b-bf16.gguf \
--outtype bf16
CPU:
./build/bin/llama-completion \
-m models/spark2_5-1.7b-bf16.gguf \
-ngl 0 -t 16 -c 1024 \
-cnv -st --jinja --simple-io --no-display-prompt \
-p '请用三句话解释什么是计算图。' \
-n 96 --temp 0 --seed 1
NVIDIA GPU (GPU 0):
CUDA_VISIBLE_DEVICES=0 ./build/bin/llama-completion \
-m models/spark2_5-1.7b-bf16.gguf \
-ngl 99 -t 16 -c 1024 \
-cnv -st --jinja --simple-io --no-display-prompt \
-p '请用三句话解释什么是计算图。' \
-n 96 --temp 0 --seed 1
-ngl 99 offloads all Spark2_5 layers to the selected GPU. Use an integer for
-ngl; values such as all are not accepted by llama-bench.
./build/bin/test-llama-archs -a spark2_5
CUDA_VISIBLE_DEVICES=0 ./build/bin/llama-bench \
-m models/spark2_5-1.7b-bf16.gguf \
-ngl 99 -p 32 -n 8
The architecture test should report OK for the CPU and CUDA backends. A
Roundtrip: SKIP result is expected because model-saver roundtrip support is
currently disabled for Spark2_5.
The main goal of llama.cpp is to enable LLM (and VLM) inference with minimal setup and state-of-the-art performance on
a wide range of hardware - locally and in the cloud.
The llama.cpp project is build on top of the ggml library.
| Backend | Target devices |
|---|---|
| BLAS | All |
| BLIS | All |
| CANN | Ascend NPU |
| CUDA | Nvidia GPU |
| HIP | AMD GPU |
| Hexagon [In Progress] | Snapdragon |
| IBM zDNN | IBM Z & LinuxONE |
| MUSA | Moore Threads GPU |
| Metal | Apple Silicon |
| OpenCL | Adreno GPU |
| OpenVINO [In Progress] | Intel CPUs, GPUs, and NPUs |
| RPC | All |
| SYCL | Intel GPU |
| VirtGPU | VirtGPU APIR |
| Vulkan | GPU |
| WebGPU | All |
| ZenDNN | AMD CPU |
llama.cpp repo and merge PRs into the master branchllama-server - MIT license(top 30 of 445)
C++
55.6%
C
15.8%
Python
7.2%
Cuda
5.5%
TypeScript
4.3%
Svelte
2.3%
HTML
2.2%
Metal
1.4%
Jinja
1.3%
LLM inference in C/C++
manifesto / ggml / ops / maintainer PRs / compile times / lib llama API / llama-server REST API
This fork adds inference support for the internally developed
Spark2_5ForCausalLM model. The following commands build llama.cpp, convert a
local Hugging Face checkpoint to GGUF, and run it on CPU or an NVIDIA GPU.
For an NVIDIA CUDA build:
cmake -B build -DGGML_CUDA=ON
cmake --build build --config Release -j 8
For a CPU-only build, use -DGGML_CUDA=OFF instead. The CUDA build also
contains the CPU backend, so the same binaries can be used for both examples
below.
Install the Python conversion dependencies:
python -m pip install -r requirements.txt
The Spark2_5 checkpoint stores its tokenizer under v8_2_token. The converter
expects the tokenizer files next to config.json and the model .safetensors
files, so copy them to the checkpoint root before conversion:
mkdir -p models
cp /path/to/spark2_5-hf/v8_2_token/{tokenizer.json,tokenizer_config.json,merges.txt} \
/path/to/spark2_5-hf/
python convert_hf_to_gguf.py /path/to/spark2_5-hf \
--outfile models/spark2_5-1.7b-bf16.gguf \
--outtype bf16
CPU:
./build/bin/llama-completion \
-m models/spark2_5-1.7b-bf16.gguf \
-ngl 0 -t 16 -c 1024 \
-cnv -st --jinja --simple-io --no-display-prompt \
-p '请用三句话解释什么是计算图。' \
-n 96 --temp 0 --seed 1
NVIDIA GPU (GPU 0):
CUDA_VISIBLE_DEVICES=0 ./build/bin/llama-completion \
-m models/spark2_5-1.7b-bf16.gguf \
-ngl 99 -t 16 -c 1024 \
-cnv -st --jinja --simple-io --no-display-prompt \
-p '请用三句话解释什么是计算图。' \
-n 96 --temp 0 --seed 1
-ngl 99 offloads all Spark2_5 layers to the selected GPU. Use an integer for
-ngl; values such as all are not accepted by llama-bench.
./build/bin/test-llama-archs -a spark2_5
CUDA_VISIBLE_DEVICES=0 ./build/bin/llama-bench \
-m models/spark2_5-1.7b-bf16.gguf \
-ngl 99 -p 32 -n 8
The architecture test should report OK for the CPU and CUDA backends. A
Roundtrip: SKIP result is expected because model-saver roundtrip support is
currently disabled for Spark2_5.
The main goal of llama.cpp is to enable LLM (and VLM) inference with minimal setup and state-of-the-art performance on
a wide range of hardware - locally and in the cloud.
The llama.cpp project is build on top of the ggml library.
| Backend | Target devices |
|---|---|
| BLAS | All |
| BLIS | All |
| CANN | Ascend NPU |
| CUDA | Nvidia GPU |
| HIP | AMD GPU |
| Hexagon [In Progress] | Snapdragon |
| IBM zDNN | IBM Z & LinuxONE |
| MUSA | Moore Threads GPU |
| Metal | Apple Silicon |
| OpenCL | Adreno GPU |
| OpenVINO [In Progress] | Intel CPUs, GPUs, and NPUs |
| RPC | All |
| SYCL | Intel GPU |
| VirtGPU | VirtGPU APIR |
| Vulkan | GPU |
| WebGPU | All |
| ZenDNN | AMD CPU |
llama.cpp repo and merge PRs into the master branchllama-server - MIT license(top 30 of 445)
C++
55.6%
C
15.8%
Python
7.2%
Cuda
5.5%
TypeScript
4.3%
Svelte
2.3%
HTML
2.2%
Metal
1.4%
Jinja
1.3%