llama.cpp is plain C/C++: your program calls the llama.cpp library, which loads a GGUF model file and builds a ggml compute graph for each step of inference. ggml then runs that graph on a backend. On the CPU it uses SIMD kernels written in C/C++; on an NVIDIA GPU it runs CUDA kernels that nvcc compiled when llama.cpp was built; on Apple silicon it runs kernels written in Metal Shading Language. With a GPU backend, layers that are not offloaded to the GPU still run on the CPU.
Showing the Metal (Apple silicon) backend: 9 stages, 8 steps.
Your program
Framework core
Model file
Kernel
Compiler
Hardware
The selected path, step by step
Your program calls llama.cpp library: The program calls the llama.cpp library, which is plain C/C++ with no other dependencies.
llama.cpp library loads GGUF model file: The library reads the model's weights and metadata from a GGUF file.
llama.cpp library builds ggml compute graph: For each step of generation, llama.cpp describes the computation as a ggml graph.
ggml compute graph runs layers on ggml CPU backend: With the CPU backend the whole graph runs here. With a GPU backend, the layers not offloaded to the GPU still run here; --n-gpu-layers controls the split.
ggml compute graph offloads layers to ggml Metal backend: On macOS builds Metal is on by default, and the offloaded layers are computed by the Metal backend. --n-gpu-layers 0 turns GPU inference off.
ggml CPU backend runs on CPU: The C/C++ kernels run on the CPU's cores using its SIMD instructions.
ggml Metal backend kernels written in Metal kernels (MSL): The Metal backend's operations are llama.cpp's own kernels in Metal Shading Language.
Metal kernels (MSL) run on Apple silicon GPU: Through Apple's Metal framework the kernels run on the Apple silicon GPU.
Which language does the work
There is no Python on this path. The library, the model loader and ggml are C and C++, and the language of the innermost loops depends on the backend: C/C++ with SIMD instructions on the CPU, CUDA C++ on NVIDIA GPUs, and Metal Shading Language on Apple GPUs.
The GPU kernels are written for each backend and kept in the llama.cpp repository. CUDA kernels are compiled by NVIDIA's nvcc when llama.cpp itself is built, by default for the GPU in the build machine. That is a different arrangement from torch.compile, where TorchInductor generates new kernels while your program runs.
CPU and GPU together
With the CUDA or Metal backend, the GPU only runs the layers offloaded to it, which the --n-gpu-layers (-ngl) option controls. The rest of the model runs on the CPU backend, which is how llama.cpp runs models larger than the GPU's memory.
Every stage
Your program
application
A program that runs a model: llama.cpp's own command-line tool or OpenAI-compatible server, or your own code linked against the library.
With the CPU backend the whole graph runs here. With a GPU backend, the layers not offloaded to the GPU still run here; --n-gpu-layers controls the split.
Documented paths for running a GGUF model with llama.cpp on three of its backends: the CPU, CUDA on an NVIDIA GPU, and Metal on Apple silicon. Other backends (Vulkan, HIP, SYCL, OpenCL and more), multi-GPU and RPC setups, and how a model is converted to GGUF are out of scope. The same ggml graph can run on any backend the build enables; this page shows three of them.
How this page is checked
Every stage and step above quotes the source that supports it. The quotes were checked against the llama.cpp README and build guide, the GGUF specification, Hugging Face's Introduction to ggml, and llama.cpp's CUDA and Metal kernel sources (master branch) on 2026-11-11. The data is a versioned JSON file under the same CC BY 4.0 license as the dataset. Found something wrong or out of date? Open an issue with the better source.