What is a runtime, and what sits under my app?

5 min readMarkdown

A chat app does not run the model. It hands your text to a runtime, the runtime hands it to an engine, and the engine does the maths on your chip through a backend. Knowing which layer is which tells you where to look when something is slow or broken.

The layers

Read this from the top down. Each layer talks only to the one below it.

  1. Chat appThe window you type into. LM Studio, Jan, Open WebUI
  2. RuntimeLoads models, keeps them in memory, serves an API. Ollama, LM Studio's server
  3. EngineDoes the matrix maths, one token at a time. llama.cpp, MLX, BaseRT, vLLM
  4. BackendThe code path for your chip. Metal, CUDA, ROCm, Vulkan, CPU
  5. HardwareYour GPU, unified memory or CPU
Most of your speed is decided in the bottom three layers. Most of your convenience is decided in the top two.

The chat app is the interface. It keeps your conversations, formats messages and shows the answer as it streams.

Some chat apps bundle their own runtime. Others, such as Open WebUI, only talk to one you run separately. Which chat app should I use? covers the choice.

The runtime manages models. It downloads them, loads them into memory, unloads them when idle, and exposes an HTTP API so other programs can use them. That API is the How do I call a local model from code?.

The engine is the part that turns a prompt into tokensTokenA chunk of text, usually part of a word. Models read and write in tokens.Read more. It reads the model file, runs prefill and decode, and manages the KV cacheKV cacheSaved work from earlier tokens, so the model does not reread the whole conversation for every new token.Read more. Engine choice decides which file formats you can use and how fast they run.

The backend is the engine's code for one kind of chip. llama.cpp alone has backends for Metal, CUDA, ROCm, Vulkan and plain CPU.

Picking the wrong one, or getting the CPU fallback by accident, is the most common reason a model runs ten times slower than it should. Why is my GPU not being used? covers that failure.

A useful mental model

Sort every tool you meet into one of three groups. The groups overlap a little, but the split holds.

Convenience layers sit on top. Ollama and LM Studio find models, download them, pick sensible settings and keep a server running. They do not do the maths themselves.

Ollama runs its own engine built on llama.cpp's core library. LM Studio runs llama.cpp or MLXMLXApple's machine learning framework for Apple silicon.Read more, depending on the model file.

Engines sit underneath. llama.cpp runs on almost anything and reads GGUFGGUFThe single-file model format used by llama.cpp and the apps built on it.Read more files. MLX is Apple's framework and runs only on Apple silicon. You can run either directly from a terminal, with every setting exposed and nothing chosen for you.

BaseRT, from Base Compute, is a newer engine with its own .base format. It runs only on Apple silicon, NVIDIA's GB10 and AMD's Strix chips.

Serving systems are a separate category. vLLM and SGLang are built for many users at once on NVIDIA or AMD data-centre GPUs. They are engine and server in one, tuned for total throughput rather than one person's response time.

Rule of thumb

If you want an app, start at the top of the stack. If you want control, drop one layer down. If you want to serve a team, switch to a serving system.

The catch

Each layer you add hides settings from the one below. A convenience layer can pick a small context or the wrong backend, and you will not see it unless you look. How do I use Ollama? has the most common example.

Why the same model runs at different speeds

Load the same GGUF file in two apps and you can see a real gap in tokens per second. The model is identical. The engine underneath is not.

Four things differ between apps that look the same from the outside:

  • Engine build: Each app bundles its own copy of llama.cpp or MLX, from a different date. llama.cpp changes daily, and a newer build often carries faster kernels for your chip.
  • Backend: One app may use Vulkan on an AMD card while another uses ROCm. On a Mac, an MLX build of a model usually beats the GGUF build in llama.cpp.
  • Settings: GPU layers, context size, batch size, flash attention and KV cache type all change speed. Apps pick different defaults and some hide them.
  • Overhead: A runtime that reloads the model between requests, or rebuilds the prompt cache each turn, wastes time that has nothing to do with the maths.
Try it

Load one model in two apps you already have. Ask both the same question and compare the speed each one reports. If the gap is large, check which backend each app is using before you blame the app.

How do I make it faster? covers the settings in order of payoff. How do I benchmark my own setup? covers how to measure the gap properly.

Go deeperThat's enough

Where the layers blur

The four-layer picture is a simplification. LM Studio is a chat app, a runtime and a host for two engines in one window. vLLM is an engine and a server with no app at all. Ollama started as a wrapper around llama.cpp and now runs its own engine on top of llama.cpp's lower-level library, called ggml.

What stays true is the division of work. Something manages models, something does the maths, and something talks to the chip.

Why engines and formats travel together

An engine reads the format it was built for. llama.cpp reads GGUF. MLX reads its own safetensors layout. BaseRT reads .base. vLLM and SGLang read the original Hugging Face weightsWeightsThe full set of a model's parameters, stored in a file.Read more or GPU-specific quantized versions of them.

So "which runtime" and "which file" are one decision. vLLM's GGUF support is experimental, and an MLX file is useless on Windows. Where do I download models? covers where each format lives.

What the backend actually is

A backend is a set of kernels: small programs that multiply matrices on one kind of chip. CUDA kernels run on NVIDIA, Metal on Apple, ROCm on AMD. Vulkan runs on most GPUs from any vendor, usually a little slower than the vendor's own path.

The engine picks a backend when it is built or when it starts. A prebuilt download for the wrong backend runs on the CPU and says nothing about it.