GPU memory
Also called VRAM, HBM
GPU memory is the memory attached to a GPU, in the same package or on the same card, that holds the data its threads work on. The GPU reads it far faster than it could reach the main memory of its host. A GPU keeps so many threads busy at once that a slow path to memory would leave most of them idle. The amount is fixed when the card is made and cannot be upgraded later.
Data-center GPUs use high-bandwidth memory, stacks of memory chips placed beside the GPU in one package. Consumer cards use graphics memory chips soldered around the GPU on the card, which is cheaper and slower. High-bandwidth memory costs much more per gigabyte, and its supply has at times limited how many data-center GPUs could be built. Graphics memory belongs to the GDDR family, which game consoles use too.
The amount of GPU memory often decides which models a GPU can run at all. The weights of a model and the working data of each request must fit in it, or be split across several GPUs. Splitting works, but the GPUs then exchange data on every step, which is slower than reading local memory. Running a model at lower numeric precision shrinks its weights, a common way to fit it on fewer GPUs.
Memory bandwidth
Memory bandwidth is the rate at which a GPU can move data between its memory and its multiprocessors. Many GPU workloads are limited by bandwidth rather than by arithmetic, because each value they read is used only a few times. The number of operations a program does per byte it reads is called its arithmetic intensity. When it is low, the multiprocessors finish their work quickly and then wait for the next data to arrive.
Generating text one token at a time with a language model is a common example, since every step reads all of the weights. For such work, a GPU with more bandwidth runs faster even when its arithmetic peak is the same. Serving many requests at once helps, because one read of the weights then serves every request in the batch. Batching therefore has a large effect on the cost of serving a model.
High-bandwidth memory exists for this reason, trading cost and capacity for speed. Its stacks sit millimetres from the chip, so a much wider bus fits between them than a card could route. The wires run through a silicon base under both chips, called an interposer. A wide bus can run at a modest clock speed, which keeps the energy spent per bit low.
| Memory | Memory is the fast, temporary storage that holds the instructions and data a processor works on. |
|---|---|
| High-bandwidth memory | High-bandwidth memory gives a data-center GPU terabytes per second and tens to hundreds of gigabytes. |
| Graphics memory | Graphics memory gives a consumer card up to about two terabytes per second and a few to tens of gigabytes. |
| Host memory over PCIe | Host memory reached over PCIe gives a GPU tens of gigabytes per second. |
Transfers between host and GPU
Transfers between host and GPU are the copies that move data across the PCIe link between main memory and GPU memory. That link is far slower than GPU memory itself, so programs copy data once and keep it on the GPU. Each copy also has a fixed start-up cost, so many small copies are slower than one large one. A program that moves data back and forth on every step can spend more time copying than computing.
Copies run fastest from host memory that is pinned, which the kernel promises never to move or swap out. The GPU can then read it directly, without the CPU copying each block. Ordinary memory may be moved by the kernel at any time, so the driver first copies it into a pinned buffer of its own. Pinned memory cannot be reclaimed, so pinning too much of it starves the rest of the system.
Some systems narrow the gap with a faster link between the processor and the GPU, or with memory that both share in one package. GPUs in one server can also read the memory of each other over a direct interconnect. When the processor and the GPU share one memory, no copy is needed at all. The direct interconnect is much faster than PCIe, which matters when a model is split across several GPUs.
GPU memory in virtual machines
GPU memory in virtual machines is memory that a guest reaches directly when a GPU is passed through to it. The hypervisor maps the GPU into the guest, and the driver in the guest then manages all of its memory as on a physical machine. Passthrough relies on an IOMMU, which limits the memory the GPU can reach to that of its own guest. Performance is close to a physical machine, because the hypervisor stays out of the path for nearly every operation.
The hypervisor does not page or overcommit GPU memory the way it does main memory. The memory of a passed-through GPU belongs to one guest at a time, with no balloon or swap behind it. A guest that runs out of it gets an error from its driver, rather than a slower copy on disk. GPU capacity is therefore harder to share than processor time, since an idle card still holds all its memory for one guest.
Splitting a GPU in hardware gives each partition a fixed slice of its memory, isolated from the others. Before a GPU moves to another tenant, its memory must be cleared, or the next tenant could read the data left behind. Sharing a GPU in time slices without that hardware support gives weaker isolation, since the tenants then share one memory space. Hardware partitions avoid that, at the cost of fixed sizes that may not match each workload.