LLM inference in C/C++
ggml / ops / maintainer PRs / dev stats / lib llama API / llama-server REST API
OBSOLETE (2026-11-01). The two patches described below were retired. Plain upstream
a91eab67reuses the cross-turn KV cache on hybrid models exactly as this branch did (Qwen3.6 MTP, Ornith, Flash-Next, and a 187K-token prompt: 16-30 prompt tokens re-evaluated per follow-up turn on both), so production now runs unpatched upstream. This branch is kept as history only. Its final state is taggedarchive/kintsugi-final-20261101, and the two commits are preserved as patch files in the forge repo (docs/history/kintsugi/, ADR-0019). Experiments live on branches off plain upstream, e.g.feature/clover-draft-self-r3. Do not base new work on this branch.
A working fork of upstream ggml-org/llama.cpp, maintained for Tohil, a self-hosted
inference host (AMD Strix Halo, Ryzen AI Max+ 395, gfx1151, 128 GB unified memory).
Branch kintsugi (merged 2026-10-23; tree identical to rebase/upstream-20261022) —
upstream master at 7170cad4d (2026-10-22) plus two patches (below). The pre-rebase history
(based on upstream 458681e1d, 2026-09-01) is the merge's first parent, so
git show edfb0e840:README.md has the long-form notes.
- Kintsugi — cross-turn KV cache reuse for hybrid/recurrent architectures
(
tools/server/server-context.cpp,common/common.{h,cpp}). Lets hybrid/recurrent models (Qwen3.5/3.6 MoE, qwen4exp, ...) reuse cache across conversation turns instead of re-prefilling the whole conversation: a dedicated generation-end checkpoint per turn, preferred on restore, a GPU sync after partial-state restore, and checkpoints preserved across a forced position reset. Production, stable. - MTP checkpoint loss past EOG (ggml-org/llama.cpp#28049).
A speculative-decode round that ended generation never saved a Kintsugi checkpoint, so
the next turn re-prefilled the entire answer just generated. Not specific to one model:
it hits any hybrid/recurrent model served with
--spec-type draft-mtp. The fix shares onesave_generation_checkpoint()between the plain and speculative paths and forces the existing restore-and-replay path when an EOG lands mid-batch.
- The qwen4exp MTP patch set was dropped, not ported. Upstream merged qwen4exp MTP
itself (#29761), so the 11 earlier community-PR commits (NextN head, converter, the
detached-head loader, the follow-up correctness fixes) are obsolete. The detached MTP
head GGUF (
mtp-*.ggufvia--spec-draft-model) loads unchanged on upstream. --no-mmapno longer exists. Upstream removed--mmap/--no-mmap/--mlock/--direct-ioin favor of--load-mode {auto,none,mmap,mlock,mmap+mlock}(#28334).--no-mmapbecomes--load-mode none. Builds from September 2026 onward already accept both spellings; builds from this rebase reject the old one.preserve_reasoningis on by default for templates that support it (--no-reasoning-preserveto turn off).
ROCm build (TheRock 10.1, gfx1151), 262144 context, --spec-type draft-mtp --spec-draft-n-max 3, q8_0 KV, vision projector attached, 8 long multi-turn exchanges:
previous kintsugi build |
this branch | |
|---|---|---|
cache reuse by turn 8 (cache_n) |
~5,070 | ~5,070 |
| new prompt tokens per turn | 24-35 | 24-35 |
| decode | 16-18 t/s | 30-37 t/s |
| image question | correct | correct |
No aborts, faults, or checkpoint-restore loops. Decode is roughly doubled; the cause was not isolated (upstream's ROCm and qwen4exp kernel work since September is the likely source).
GGML_CUDA_ENABLE_UNIFIED_MEMORY=ONis not needed on this true-APU host and, combined with HIP graph capture (any--spec-type draft-mtpconfig), causes a hardHSA_STATUS_ERROR_MEMORY_FAULTink_get_rows_float. It — not HIP graphs alone — was the real trigger behind the oldGGML_CUDA_DISABLE_GRAPHS=1requirement, which is therefore unnecessary.GGML_HIP_UMAis a no-op CMake variable. A 90 GB model at full 262144 context loads on plainhipMalloc.- Run
--parallel 1for anything serving one long conversation at full context:--parallel Nsplits the configured context across N slots.
The full original write-up (diagnosis history, the 231K-token depth soak, the EOG-fix
analysis) is in this README at commit edfb0e840 (the previous kintsugi tip).
A few options to get llama.cpp installed on your machine:
# curl
curl -LsSf https://llama.app/install.sh | sh
# powershell
irm https://llama.app/install.ps1 | iex- Visit https://llama.app and follow the instructions
- Run with Docker - see our Docker documentation
- Download pre-built binaries from the releases page
- Build from source by cloning this repository - check out our build guide
Once installed:
# Download and run a model directly from Hugging Face
llama cli -hf ggml-org/Qwen3.5-0.8B-GGUF
# Launch OpenAI-compatible API server
llama serve -hf ggml-org/Qwen3.5-0.8B-GGUF
VLM session with llama cli
|
Built-in web UI against llama serve
|
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.
- Plain C/C++ implementation without any dependencies
- Apple silicon is a first-class citizen - optimized via ARM NEON, Accelerate and Metal frameworks
- AVX, AVX2, AVX512 and AMX support for x86 architectures
- RVV, ZVFH, ZFH, ZICBOP and ZIHINTPAUSE support for RISC-V architectures
- 1.5-bit, 2-bit, 3-bit, 4-bit, 5-bit, 6-bit, and 8-bit integer quantization for faster inference and reduced memory use
- Custom CUDA kernels for running LLMs on NVIDIA GPUs (support for AMD GPUs via HIP and Moore Threads GPUs via MUSA)
- Vulkan and SYCL backend support
- CPU+GPU hybrid inference to partially accelerate models larger than the total VRAM capacity
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 | 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 |
- How to build
- Running on Docker
- Build on Android
- Multi-GPU usage
- Performance troubleshooting
- GGML tips & tricks
- XCFramework
- Completions
- Models
- Release process
- Contributors can open PRs
- Collaborators will be invited based on contributions
- Maintainers can push to branches in the
llama.cpprepo and merge PRs into themasterbranch - Any help with managing issues, PRs and projects is very appreciated!
- Read the CONTRIBUTING.md for more information
- yhirose/cpp-httplib - Single-header HTTP server, used by
llama-server- MIT license - nothings/stb - Single-header image format decoder, used by multimodal subsystem - Public domain
- nlohmann/json - Single-header JSON library, used by various tools/examples - MIT License
- mackron/miniaudio - Single-header audio format decoder, used by multimodal subsystem - Public domain
- sheredom/subprocess.h - Single-header process launching solution for C and C++ - Public domain

