llama.cpp bench
Runs llama-bench from llama.cpp on a
GGUF model and prints how many tokens per second it processes a prompt of
n_prompt tokens (pp512) and generates n_gen tokens (tg128), each the
average of five runs, on the compute type the task runs on. Run it on the
compute type you mean to serve from: the numbers belong to that hardware.
The image is llama.cpp's CUDA 13 build, used as-is: its entrypoint is
llama.cpp's /app/tools.sh dispatcher, and the leading --bench argument runs
llama-bench with the rest. llama-bench prints its table to the task log and
has no option to write it to a file, so the numbers are read in the run's logs;
no later task can read them.
Inputs
| Input | Required | Default | Description |
|---|---|---|---|
model |
yes | — | Absolute path of the .gguf model file. |
n_prompt |
no | 512 |
Prompt tokens per prompt-processing test, llama-bench's own default. |
n_gen |
no | 128 |
Tokens per generation test, llama-bench's own default. |
Outputs
None. The results table is in the task's log.
Compute
GPU recommended. The image loads its CUDA backend and offloads every layer when the compute type has a GPU, and falls back to its CPU backend otherwise, so the task measures whichever compute type it runs on.
Example
Fetch a 4-bit GGUF model and benchmark it on a GPU:
name: llama.cpp bench example
compute_type: cpu-4
entry_point: main
blocks:
main:
tasks:
model:
name: Fetch model
uses: swaleio/hf-download
args:
repo: Qwen/Qwen2.5-0.5B-Instruct-GGUF
include: "qwen2.5-0.5b-instruct-q4_k_m.gguf"
dest: ${{env.WORKFLOW_STORAGE}}/gguf
bench:
name: Benchmark
uses: swaleio/llamacpp-bench
compute_type: a100-1
start_on:
- model
args:
model: ${{env.WORKFLOW_STORAGE}}/gguf/qwen2.5-0.5b-instruct-q4_k_m.gguf
The bench task's log holds the table of prompt-processing and generation
speeds.
For the workflow syntax these examples use, see the workflow definition reference in the Swale documentation.
Licensed under the MIT License.