Lesson 30.3 · 3 of 8 · 5 min read · Reviewed 24 Nov 2026
Inference servers and runtimes
By the end, you can
- Name the main local inference runtimes and servers.
- Pick one for a use case.
Two kinds of tool
| Local and desktop runtimes | Production inference servers | |
|---|---|---|
| Examples | llama.cpp, Ollama, desktop model apps | vLLM and similar GPU servers |
| Runs on | Laptops, CPUs, consumer GPUs, Apple silicon | Data-centre GPUs |
| Strength | Easy setup, quantized models, offline use | High throughput, batching, many users |
| Typical use | Development, personal tools, edge | Shared services and products |
Features to look for
- Continuous batching: mixes many requests on the GPU for throughputThroughput: How much work a system completes per unit of time, such as requests per second or tokens per minute..
- KV cacheKV cache: Stored attention keys and values for tokens already processed, so they are not recomputed for each new token. management: fits more concurrent requests in memory.
- Prefix caching: reuses shared prompt prefixes, like prompt cachingPrompt caching: Reusing the processed form of a repeated prompt prefix across requests, which cuts cost and latency. on Claude (70.1).
- Structured outputStructured outputs: Making a model return data that matches a defined schema, such as JSON with required fields and types. and tool callingTool use: Letting a model call functions you define, by returning a structured request your code executes.: constrains output to a schema.
- Chat templates: applies the model’s template for you (28.3).
- Metrics: tokens per second, queue length, latencyLatency: The time from sending a request until you get the response, or until the first token arrives when streaming. for monitoring (chapter 67).
API compatibility
Many local servers offer an HTTP API that common client libraries already speak. That makes it easy to point an app at a local model in development. Keep your own thin wrapper so switching between a local model and Claude is configuration, not code.
Start small
For a prototype, a desktop runtime with a 4-bit model is enough. Move to a GPU server when you have real concurrency and measured needs.
Key points
- Runtimes load a model and generate tokens; servers wrap them in an HTTP API for apps.
- Desktop-friendly tools (llama.cpp, Ollama and similar) make it easy to run quantized models on laptops.
- High-throughput servers (vLLM and similar) batch many requests efficiently on GPUs.
- Many expose an API shape that clients already understand, which eases switching.
Serve a quantized model on localhost
Run an open model behind a local HTTP API and call it from a script.
You will have: A running local server and a short script that sends one chat request and prints the reply and the time it took.
Steps
- Install Ollama, or download a llama.cpp release, following its official instructions for your system.
- Pull or download one small model at 4-bit, and write down its exact name, tag or file name.
- Start the server (Ollama runs one in the background; for llama.cpp run llama-server -m <file> --port 8080), bound to localhost only.
- Send one chat request from a script with the standard library or curl, and print the reply and the elapsed time.
- Put the base URL and model name in environment variables, so the same script can later point at a cloud model.
Done when
- A request to localhost returns a reply from the model.
- The script prints the elapsed time for one request.
- The URL and model name come from environment variables, not from the code.