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. Here you will see why generating text is usually limited by how fast memory can be read, not by how fast the chip can calculate.
What memory bandwidth is
Memory bandwidth is the amount of data a processor can read from memory each second. It is quoted in GB/s. Capacity tells you whether a model fits. Bandwidth tells you how quickly the processor can get at it.
The two numbers are independent. A machine can have a lot of memory that is slow, or a small amount that is fast.
| Memory type | Typical bandwidth (approximate) |
|---|---|
| Dual-channel DDR5 system RAM | 60 to 100 GB/s |
| Unified memory on a laptop-class chip | 100 to 400 GB/s |
| Unified memory on a high-end workstation chip | 400 to 800 GB/s |
| Consumer GPU VRAM | 300 to 1000+ GB/s |
These figures vary by exact model. Check the specification of your own hardware.
Why generation waits on memory
To produce one token, the model runs a forward pass. That pass uses essentially every weight once. The weights are far too large to stay in the processor's small on-chip caches, so they are streamed from memory for every token.
Each weight is used in only a few arithmetic operations. The processor finishes those quickly and then waits for the next weights to arrive. The work is bound by memory, not by compute.
A ceiling from bandwidth
If every token reads about the whole model, then the time per token is at least the model size divided by the bandwidth. Turn that around and you get a ceiling on speed:
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 4.9 GB model on a 100 GB/s memory system cannot generate faster than roughly 20 tokens per second. Real speed is lower, because of overheads and because the KV cache is also read.
What this tells you
- A smaller file generates faster on the same hardware. Halving the bits per weight roughly doubles the ceiling.
- Faster memory raises the ceiling in direct proportion.
- A chip with more compute but the same bandwidth will generate at about the same speed.
- Where the weights live decides which bandwidth applies. Weights in VRAM use the GPU's bandwidth. Weights in system RAM use the much lower RAM bandwidth.
Common errors
- Comparing machines by compute alone, such as core counts or TFLOPS, when predicting generation speed.
- Using the parameter count instead of the file size in the ceiling formula. Use the size of the quantised file.
- Treating the ceiling as the expected speed.
Exercise
A quantised model file is 8 GB. Your GPU has 400 GB/s of memory bandwidth and the whole model sits in VRAM. What is the generation ceiling in tokens per second? What happens to the ceiling if you switch to a 4 GB file of the same model?
Show answer
400 / 8 = 50 tokens per second is the ceiling. With a 4 GB file the ceiling becomes 400 / 4 = 100 tokens per second, because each token reads half as much data. Real speed will be lower in both cases.
Exercise
Two machines have the same GPU compute, but one has 200 GB/s memory bandwidth and the other has 500 GB/s. Which generates tokens faster for the same model, and why?
Show answer
The 500 GB/s machine. Generation is limited by how fast weights are read from memory, so its ceiling is 2.5 times higher. Equal compute does not help when the processor is waiting on memory.