CodeVetter
← All unpacks
CodeVetter · Repo Unpack evidence

ggml-org/llama.cpp

Scanned commit 7ab4ee7baa dated 2026-09-22 — last upstream commit. Generated by codevetter 1.12.0 on 2026-09-22.

github.com/ggml-org/llama.cpp ↗ · 3518 files · 41.5 MB

llama.cpp LLM inference in C/C++ ggml / ops / maintainer PRs%20sort%3Aupdated-desc) / dev stats / lib llama API / llama-server REST API Quick start A few options to get llama.cpp installed on your machine: - Visit https://llama.app and follow the instructions

Deep analysis by swe-2 via the devin CLI on 2026-09-22 (runtime not recorded) — every claim below links to its cited source files.

Overview

llama.cpp is a dependency-free C/C++ inference engine for LLMs and VLMs, built around the vendored ggml tensor library with pluggable hardware backends (CPU, CUDA, Metal, Vulkan, SYCL, RPC, and more). Its public surface is the C API in include/llama.h, consumed by a unified `llama` binary (app/llama.cpp) that dispatches subcommands like `serve`, `cli`, `quantize`, and `perplexity`. The flagship deliverable is llama-server: an OpenAI/Anthropic-compatible HTTP server with an embedded SvelteKit web UI, multi-slot continuous batching, a router mode that spawns child inference processes, MCP/tool-calling support, and multimodal input via the mtmd/CLIP library. Python tooling under conversion/, convert_hf_to_gguf.py and gguf-py handles Hugging Face to GGUF model conversion.

System map

The repo is a CMake C/C++ monorepo layered as: ggml/ (tensor ops + hardware backend plugins, statically registered or dlopen'd), src/ (libllama: GGUF model loading, vocab/tokenizers, KV-cache memory, compute graph builders per architecture, samplers, public C API in include/llama.h), common/ (llama-common utility lib: arg parsing, chat templates via a custom Jinja engine, sampling orchestration, HF downloading, subprocess helpers), tools/ (user-facing binaries incl. server, cli, mtmd multimodal, quantize, perplexity, bench), app/ (unified `llama` binary), and Python conversion tooling (conversion/, gguf-py/, convert_hf_to_gguf.py). Tests live in tests/ (CTest C++ binaries) and tools/server/tests (pytest). The web UI is a SvelteKit app in tools/ui embedded into the server binary at build time.

All 14 system map claims →

Feature catalog

User-facing surface splits into the `llama` unified binary subcommands, the llama-server HTTP API, the interactive `llama cli` chat client, offline analysis/conversion tools, and the embedded web UI. The server exposes OpenAI-compatible, Anthropic-compatible, Ollama-ish and legacy endpoints plus extras (rerank, infill, tokenize, slots save/load, LoRA hotswap, resumable streams, MCP tools). Feature scope for the server is deliberately bounded by tools/server/README-dev.md.

All 14 feature catalog claims →

Data flow

The canonical pipeline is: CLI args -> common_params (arg.cpp) -> model file resolution/download (download.cpp, hf-cache.cpp) -> GGUF parse + mmap via llama_model_loader -> per-arch llama_model subclass (tensors mapped into ggml backend buffers) -> llama_context with KV memory + graph builder -> llama_decode produces logits -> sampler chain produces tokens -> detokenize to text. In the server, HTTP JSON is tokenized into server_task objects flowing through server_queue -> server_slot -> a shared llama_batch -> llama_decode -> results streamed back as SSE.

All 13 data flow claims →

Behavior traces

Three flows traced end-to-end: (1) `llama serve` startup including router vs single-model branches, (2) an HTTP chat completion through tokenize -> task queue -> slot -> decode -> SSE, and (3) `llama cli` startup which spawns an embedded server thread and streams chat over loopback HTTP.

Testing signals

C++ tests live in tests/ and register with CTest via llama_build_and_test/llama_test helpers; coverage spans tokenizers (against models/ggml-vocab-*.gguf fixtures), grammars, chat templates/parsers, KV/recurrent state, samplers, quantization, and backend ops. The server has a parallel pytest suite (tools/server/tests) that spawns real llama-server processes, and the web UI has Vitest (unit/client/ui projects) plus Playwright e2e. CI runs ctest -L main and dedicated per-backend workflows.

Risk map

Biggest risks: server-side command execution features (exec_shell_command, MCP stdio subprocesses, router child spawning, CORS proxy) which are opt-in but powerful; unauthenticated-by-default HTTP API; remote content trust (HF downloads, remote presets, prebuilt UI assets); and a very large single-threaded decode loop in server-context.cpp (~5.5k lines) where a fatal error aborts all slots. GGML_ABORT/GGML_ASSERT turn many error paths into crashes rather than graceful failures.

All 13 risk map claims →

Extension points

Primary extension seams: new model architectures (conversion/ ModelBase.register + src/models/*.cpp + llama_model_mapping switch + gguf constants), new ggml backends (ggml_backend_reg_t + dlopen registry), new samplers (llama_sampler interface + common_sampler_init chain), new chat/tool parsers (common/parsers + PEG/jinja), new CLI args (common_arg table), new server endpoints (ctx_http.get/post + server_routes handlers), new built-in tools (server_tool subclasses), and new unified-binary subcommands (cmds[] table).

Contributor handoff

Read AGENTS.md first — it is strict: ASCII-only, concise comments, no new test files without maintainer approval, never commit/push/PR on the user's behalf, reuse existing infra. Build with cmake -B build && cmake --build build -j; run C++ tests via ctest and server tests via tools/server/tests/tests.sh. Key files to read before editing: common/arg.cpp (params), tools/server/README-dev.md (server feature scope), docs/development/HOWTO-add-model.md (arch additions), and the pimpl of whatever you touch (server_context_impl, llama_model subclasses).

Languages

LanguageFilesShare of source
C++75234%
TypeScript40718%
C38718%
Svelte32415%
Python22210%
Markdown124docs/config
YAML78docs/config
Shell733%

Start reading here

Probable source entrypoint: src/ — inferred from the directory tree and manifest, not the upstream docs.

Source roots

src/ (223 files) app/ (3 files)

Repository structure

Top-level pathFiles
ggml/1377
tools/1005
src/223
examples/197
models/102
conversion/94
common/93
tests/86

Docs found: AGENTS.mdCLAUDE.mdCONTRIBUTING.mdREADME.mddocs/android.mddocs/autoparser.mddocs/backend/BLIS.mddocs/backend/CANN.mddocs/backend/CUDA-FEDORA.mddocs/backend/ET.md

Package

pyproject.toml — pytorch v0.0.0, 8 declared dependencies.

torch{{{]pytest##

CI & config entrypoints

Structural health signals

Average score 6.5/10 across 96 analyzed source files; 50 hotspots surfaced.

These are deterministic review leads — size, churn, and structural signals — not proof of a bug in this project.

Recent history