Sub topic 7
VRAM, System RAM and Unified Memory
This chapter covers the three places a model's weights can live: GPU memory (VRAM), system RAM, and the single shared pool on unified-memory machines. It assumes you can already estimate weight size from parameter count and bits per weight, and that you know what the KV cache is. The next chapter uses these tiers to check whether a model fits.
Why the tier matters
A model runs fast only where the processor doing the math can read the weights quickly. A computer has several kinds of memory, and they differ in three ways:
- Capacity. How many gigabytes the tier holds.
- Bandwidth. How many gigabytes per second the processor can read from it.
- Reach. Which processors can use it directly.
Capacity decides whether a model loads at all. Bandwidth decides how fast it generates tokens. Reach decides whether data must be copied between tiers first.
The three tiers
VRAM on a discrete GPU
VRAM is memory soldered onto a graphics card. It is physically separate from the rest of the computer. The GPU reads it over a very wide bus, so bandwidth is high. Typical figures are:
| Card class | VRAM | Approximate bandwidth |
|---|---|---|
| Mainstream consumer | 8 to 16 GB | 250 to 500 GB/s |
| High-end consumer | 24 to 32 GB | 900 to 1800 GB/s |
| Data center | 80 GB and up | 2000 GB/s and up |
The limit is capacity. VRAM is expensive and cannot be upgraded after purchase. A 24 GB card cannot hold a 30 GB model, however fast it is.
System RAM
System RAM is the memory on the motherboard, normally DDR4 or DDR5 modules. The CPU reads it directly. It is cheap and often upgradeable, so 32, 64 or 128 GB is common.
Its bandwidth is much lower than VRAM. A typical dual-channel DDR5 desktop reaches roughly 60 to 100 GB/s. A GPU cannot read system RAM directly at full speed either. Data crosses the PCIe bus, which delivers roughly 16 to 64 GB/s depending on the generation and lane count. That is far below VRAM speed.
Unified memory
On unified-memory machines, the CPU and GPU share one pool of memory. Apple Silicon Macs are the best-known example, and some AMD and NVIDIA systems work similarly. There is no copy between a "CPU side" and a "GPU side" because both read the same chips.
The pool is large (16 to 192 GB or more on Macs) and its bandwidth sits between desktop RAM and a high-end GPU. Many Apple chips deliver roughly 100 to 800 GB/s, depending on the model. This makes unified memory attractive for big models, because a large model can be fully "on the GPU" without a large discrete card.
Two caveats apply:
- The operating system and your other programs use part of the pool.
- The GPU is usually allowed only a fraction of it. On macOS, the default limit for GPU use is often around two thirds to three quarters of total memory on smaller machines. Check your platform's documentation for the current rule, because it varies by version and can often be raised with a system setting.
Comparing the tiers for a local model
Suppose a model file is 4.9 GB. Using the ceiling formula from the speed chapter (bandwidth divided by model size), here is the upper bound on generation speed in each tier.
def decode_ceiling_tokens_per_s(bandwidth_gb_s, model_file_gb):
return bandwidth_gb_s / model_file_gb
tiers = {
"Dual-channel DDR5 RAM": 80,
"Unified memory (mid-range)": 273,
"Mainstream GPU VRAM": 450,
"High-end GPU VRAM": 1000,
}
for name, bw in tiers.items():
ceiling = decode_ceiling_tokens_per_s(bw, 4.9)
print(f"{name:28s} {bw:5d} GB/s -> at most {ceiling:6.1f} tokens/s")The bandwidth numbers are illustrative. Look up the figure for your own hardware. The point is the ratio: the same file can generate over ten times faster from fast VRAM than from desktop RAM. Real speeds fall below these ceilings.
What this means in practice
The model must fit in one tier to be fast
The best case is a model, its KV cache and runtime buffers all inside VRAM (or the GPU-usable part of a unified pool). Everything the GPU needs is then read at full speed.
If the model does not fit, the runtime can keep some layers in system RAM and run them on the CPU. This is partial offload, and a later chapter covers it. The slow tier then sets the pace for those layers, so speed drops sharply once any layers spill.
Capacity is not additive in a simple way
A machine with 16 GB VRAM and 64 GB RAM does not behave like a machine with 80 GB of fast memory. Layers held in RAM are processed at RAM speed. The extra RAM lets bigger models load, but it does not make them fast.
Overhead takes a share
Plan for memory beyond weights and KV cache:
- Compute buffers. The runtime allocates scratch space for intermediate results. This often adds several hundred megabytes, and more with larger batch sizes.
- Operating system and display. On a discrete card driving your monitor, the desktop uses some VRAM. On unified-memory machines, the OS uses part of the shared pool.
- Other programs. A browser with many tabs can take several gigabytes.
A safe habit is to leave 1 to 2 GB of headroom in the tier you plan to use, and more if you run other heavy programs.
Multiple GPUs
Some runtimes can split a model across several GPUs. Capacity adds up, since each card holds some layers. Speed does not scale the same way, because the layers are processed in turn and data moves between cards over PCIe. Splitting is mainly a way to fit a larger model, not to speed up a model that already fits.
Common errors
- Treating "total memory" on a unified system as all available to the GPU. The GPU limit and OS usage reduce it.
- Comparing RAM size without comparing bandwidth. Two machines with 32 GB can differ by several times in speed.
- Ignoring overhead. A model whose weights are 23.5 GB will not load on a 24 GB card once buffers and the desktop are counted.
- Assuming single-channel RAM performs like dual-channel. Populating only one memory slot can roughly halve CPU memory bandwidth. Check that your modules are installed in the correct slots.
- Expecting PCIe speed during GPU compute. The PCIe link matters when data moves between tiers. When everything is in VRAM, it matters little after loading.
Checking your own machine
Find out what you have before estimating anything. On a machine with an NVIDIA GPU, this command reports total and used VRAM:
nvidia-smi --query-gpu=name,memory.total,memory.used --format=csvOn Linux, this shows system RAM:
free -hThen look up your GPU's or chip's published memory bandwidth in its specification sheet. You now have the three numbers needed for the next chapters: capacity of the fast tier, capacity of the slow tier, and bandwidth of each.
Exercise
A laptop has 16 GB of system RAM in a discrete-GPU design, and its GPU has 8 GB of VRAM. You want to run a 12 GB model file. Name the tier problem you will face and say what you expect for speed compared with a model that fits in VRAM.
Show answer
The model does not fit in the 8 GB of VRAM, so at least part of it must stay in system RAM and run on the CPU through partial offload. Those layers are read at RAM bandwidth (tens of GB/s) instead of VRAM bandwidth (hundreds of GB/s), so generation will be much slower than for a model that fits entirely in VRAM. Weights, KV cache and overhead also need to fit in the 16 GB of RAM along with the operating system, so context length should be kept modest.
Exercise
A Mac has 64 GB of unified memory and the GPU can use about 75 percent of it by default. You want a 40 GB model with a 3 GiB KV cache and about 1 GB of runtime overhead. Does it fit in the GPU-usable memory?
Show answer
The GPU-usable memory is 0.75 x 64 = 48 GB. The model needs about 40 + 3 + 1 = 44 GB, which is under 48 GB, so it fits with roughly 4 GB to spare. That spare space must also cover growth in context length, so it is a tight but workable fit.