Lesson 30.4 · 4 of 8 · 5 min read · Reviewed 24 Nov 2026
Hardware: memory, GPUs and throughput
By the end, you can
- Size hardware for local inference.
- Understand what drives throughput and latency.
Memory first
total memory ~ weights (30.2) + KV cache + runtime overhead
KV cache grows with: context length x concurrent requests x model size
A model that fits with one short chat can run out of memory with 20 users and long documents.
Speed
| Metric | What it means | Driven by |
|---|---|---|
| Time to first token | Wait before text appears | Prompt length, compute, queueing |
| Tokens per second (per user) | How fast text streams | Memory bandwidth, model size, precision |
| Throughput (all users) | Total tokens per second served | Batching, GPU count, memory for KV cache |
Generating each tokenToken: The unit a model reads and writes: a word, part of a word, a space or a symbol, mapped to an integer id. means reading the weights from memory, so bandwidth often matters more than raw compute for single-user speed.
Hardware options
| Option | Good for |
|---|---|
| Laptop with lots of unified memory | Developers, small models, offline tools |
| Single consumer GPU | 7B to 14B models at 4-bit, small teams |
| Data-centre GPUs | Larger models, many users |
| Multiple GPUs | Models too big for one, or more throughput |
Measure, then buy
Benchmark your real prompts (lengths and concurrency) on rented hardware before buying. Compare cost per million tokens and per finished task against API options (chapter 71).
Key points
- Memory is the first limit: the weights plus the KV cache must fit in GPU (or unified) memory.
- Generation speed is often limited by memory bandwidth, not raw compute.
- Throughput (tokens per second across users) and latency (time per user) trade off through batching.
- Measure time to first token and tokens per second on your real prompts.
Benchmark tokens per second on your machine
Measure time to first token and tokens per second for your own prompts and hardware.
You will have: A small results table: prompt length, context size, time to first token and tokens per second, for two precisions.
Steps
- Pick two prompts you really use: one short, one long (a few thousand tokens).
- Load the same model at two precisions, for example a 4-bit and an 8-bit file.
- For each prompt and file, stream the reply and record the time to the first token and the tokens per second; most runners also print these in their logs.
- Repeat each run three times and keep the median.
- Note the memory in use during the long prompt, and whether anything else on the machine slowed down.
Done when
- The table has 2 prompts x 2 precisions, each a median of 3 runs.
- Time to first token is higher for the long prompt.
- You can say which precision you would ship, and why, in one sentence.
Docs: llama.cpp (GitHub) · vLLM documentation