Sub topic 9
Why Memory Bandwidth Matters
This chapter assumes you can estimate weight memory from parameter count and bits per weight, and that you know the difference between VRAM, system RAM and unified memory. It explains why the speed of the link between memory and processor often sets how fast a local model generates text.
What memory bandwidth is
Memory bandwidth is the amount of data that can move between memory and the processor each second. It is quoted in gigabytes per second (GB/s). It is not the same as memory capacity, which is how much data the memory can hold.
A useful picture is a warehouse and a loading dock. Capacity is the size of the warehouse. Bandwidth is how many pallets the dock can move per second. A huge warehouse with a narrow dock still ships slowly.
Bandwidth depends on two things:
- The width of the memory bus, which is how many bits move in each transfer.
- The transfer rate of the memory chips.
Multiplying them gives peak bandwidth. Real code usually reaches 60 to 90 percent of the quoted peak, so treat the figure on a spec sheet as a ceiling.
Typical bandwidth by memory tier
The memory tiers from the previous chapter differ greatly in bandwidth. The figures below are rounded, typical values. Check the spec sheet for your exact part.
| Memory type | Typical bandwidth | Notes |
|---|---|---|
| Dual-channel DDR4-3200 system RAM | about 50 GB/s | Common on older desktops |
| Dual-channel DDR5-5600 system RAM | about 90 GB/s | Common on current desktops |
| Apple M-series unified memory (base chips) | about 100 to 120 GB/s | Shared by CPU and GPU |
| Apple M-series unified memory (Max-class chips) | about 400 to 550 GB/s | Wider bus |
| Mid-range GPU VRAM | about 300 to 500 GB/s | GDDR6 |
| High-end GPU VRAM | about 900 to 1800 GB/s | GDDR6X, GDDR7 or HBM |
| NVMe SSD | about 3 to 7 GB/s | Storage, not memory |
The last row matters. If a model does not fit in memory and the runtime must page weights from disk on every token, bandwidth falls by one to two orders of magnitude and generation becomes unusably slow.
Why generation is bandwidth-bound
A language model generates one token at a time. To produce each token, the processor must use every weight in the model (for a dense model). The weights are far too large to stay in the processor's small on-chip caches, so they stream from memory for every token.
For each token, the work looks like this:
- Read the weights of a layer from memory.
- Multiply them by a small vector of activations for the current token.
- Pass the result to the next layer.
Step 2 does very little arithmetic per byte read. Each weight is used for roughly one multiply and one add. Modern processors can do far more arithmetic per second than memory can supply data. The compute units therefore sit idle, waiting for weights to arrive.
This is what "memory-bound" means: the limiting resource is the data supply, not the arithmetic. The practical result is that two machines with equal compute but different bandwidth will generate at very different speeds, and two machines with equal bandwidth will generate at similar speeds even if one has much faster compute.
The bandwidth ceiling formula
Each generated token reads about the whole model once. The fastest possible rate is then the bandwidth divided by the model size:
tokens per second ≤ bandwidth (GB/s) / model size (GB)Here is the same calculation in code:
def decode_ceiling_tokens_per_s(bandwidth_gb_s, model_file_gb):
# Each generated token reads roughly all weights once,
# so bandwidth divided by model size is an upper bound.
return bandwidth_gb_s / model_file_gb
print(decode_ceiling_tokens_per_s(bandwidth_gb_s=100, model_file_gb=4.9))This prints about 20.4. A Q4KM file of an 8B model is roughly 4.9 GB. On a machine with 100 GB/s of bandwidth, the ceiling is about 20 tokens per second. Real speed will be lower, often 60 to 80 percent of the ceiling, because of cache effects, KV cache reads, scheduling overhead and imperfect bandwidth use.
A worked comparison
Take the same 4.9 GB model on three machines:
| Machine | Bandwidth | Ceiling (tokens/s) |
|---|---|---|
| Desktop with DDR5 | 90 GB/s | about 18 |
| Laptop with base unified memory | 120 GB/s | about 24 |
| GPU with 450 GB/s VRAM | 450 GB/s | about 92 |
The same model is about five times faster on the GPU, mainly because of bandwidth. The GPU's compute advantage is much larger than five times, but compute is not what limits this workload.
The same formula explains quantisation speed-ups
The ceiling formula depends on file size, so smaller files generate faster. Quantising a 16-bit model to 4 bits shrinks the file by about 3.3 times (about 16 GB to about 4.9 GB for an 8B model). Tokens per second rise by a similar factor when bandwidth is the limit.
This is a second benefit of quantisation, beyond fitting in memory. It also explains why a larger model at a heavy quantisation can be slower than a smaller model at light quantisation only when the file sizes say so: always compare file sizes, not parameter counts.
What the formula leaves out
The ceiling is an upper bound. Several effects push real speed below it:
- KV cache reads. Each token also reads the KV cache, which grows with context length. At long contexts, this read can become a meaningful share of memory traffic.
- Dequantisation work. Quantised weights must be converted to usable numbers on the fly. Some formats cost more compute than others, and on weak processors this can become the bottleneck.
- Imperfect bandwidth use. Achieved bandwidth is below the peak on the spec sheet.
- Other overhead. Sampling, kernel launches and data transfers between devices add time.
A ceiling that is 50 percent too optimistic is normal. Use the formula to compare options and rule out impossible expectations, then measure.
Edge cases and common mistakes
Mixing up capacity and bandwidth
A machine with 64 GB of DDR5 can hold a 40 GB model, but at about 90 GB/s the ceiling is only about 2 tokens per second. A GPU with 24 GB of VRAM cannot hold that model, but a smaller model that fits will run many times faster. Capacity decides whether a model runs. Bandwidth decides how fast.
Using parameter count instead of file size
The formula uses bytes read per token. Use the actual GGUF file size, or compute weight memory from parameters and bits per weight. Using "8B" as if it meant 8 GB gives a wrong answer by a factor of about 1.6 at 4-bit.
Multi-GPU and split setups
When a model is split across two memory pools, each token needs data from both. The slower pool often dominates, because the processor must wait for its share. Adding a second GPU mainly adds capacity, and it speeds up generation only if each GPU reads its own half of the weights in parallel. The next chapters cover splitting between GPU and CPU.
Prompt processing is different
The ceiling applies to token generation. Prompt processing handles many tokens at once, so each weight read is reused across many tokens, and compute becomes the limit. The next chapter covers that difference.
Batching
A server that handles several requests at once can reuse each weight read for several tokens. Total throughput rises, though each user's speed does not. The single-user ceiling above is the relevant number for a personal machine.
Summary of the working model
- Capacity determines whether the model fits. Bandwidth determines how fast it generates.
- Each generated token streams roughly all weights from memory, so generation is memory-bound.
- Tokens per second is at most bandwidth divided by model file size.
- Smaller files from quantisation raise the ceiling in proportion to the size reduction.
- Real speed is usually well under the ceiling. Measure it with a benchmark.
Exercise
A model file is 8.5 GB. You can run it on a desktop with 80 GB/s of system RAM bandwidth, or on a GPU with 360 GB/s of VRAM bandwidth that has enough VRAM to hold it. What is the generation ceiling on each, and roughly how much faster is the GPU? If you measure 6 tokens per second on the desktop, what fraction of its ceiling is that?
Show answer
Desktop: 80 / 8.5 ≈ 9.4 tokens per second. GPU: 360 / 8.5 ≈ 42.4 tokens per second. The GPU is about 4.5 times faster, which equals the bandwidth ratio (360 / 80). Measured 6 tokens per second is 6 / 9.4 ≈ 64 percent of the ceiling, a typical result.
Exercise
Why does a GPU with ten times the compute of your CPU generate tokens only a few times faster, when both hold the whole model in their own memory?
Show answer
Token generation does little arithmetic per byte of weights read, so it is limited by memory bandwidth, not compute. The speed-up follows the bandwidth ratio between the two memories, not the compute ratio.