My account

How a GPU works

A GPU has thousands of simple cores and its own fast memory (HBM). For a language model, the speed limit is often not the math but how fast the GPU can read the weights from memory. Compare FLOPs per byte with the GPU's balance point to know if a job is memory-bound or compute-bound, and pick number formats (BF16, FP8, INT8) with memory in mind.

Not reviewedWritten with AI helpReading time: 12 minShop assistant examplenvidia-smi

Author: bezzad

Contents

The problem: “the GPU is 100% busy, but it is slow”

Our shop assistant runs on one data center GPU with 80 GB of memory. A teammate opens nvidia-smi and sees GPU-Util 100%. They say: “The GPU is full. We need another one.”

But a load test shows the GPU can serve many more users if we batch requests. How can a “100% busy” GPU do more work? To answer, you need a simple picture of what is inside a GPU.

CPU versus GPU

  1. A CPU has a few strong cores (for example 8 to 64). Each core is fast at complex, step-by-step work with many ifs.
  2. A GPU has thousands of simple cores, grouped into units called streaming multiprocessors (SMs). They all run the same small program on different data at the same time.
  3. Matrix multiply is perfect for a GPU: millions of independent multiply-and-add operations. Modern GPUs also have tensor cores, special units that do small matrix multiplies very fast in low-precision formats.

A small program that runs on the GPU is called a kernel. Frameworks like PyTorch launch many kernels for each step of a model. CUDA is NVIDIA’s platform for writing and running kernels.

The memory levels

coreson-chip memory (registers, caches)tens of MB · fastestHBM: GPU memory80 GB · about 2 to 8 TB/s · weights + KV cacheCPU memory, over PCIehundreds of GB · tens of GB/sfasterbigger
Closer to the cores means faster but smaller. The model weights and the KV cache live in HBM. Copying from CPU memory is much slower.
  1. On-chip memory (registers, shared memory, caches). Tens of MB in total, the fastest. Kernels load small tiles of data here to work on them.
  2. HBM (high bandwidth memory). The “GPU memory” you see in specs: 80 GB on our GPU. The weights and the KV cache live here. A data center GPU can read roughly 2 to 8 TB per second from HBM, depending on the model.
  3. CPU memory. Large, but it is reached over PCIe, which moves tens of GB per second, about 50 to 100 times slower than HBM. Copying data between CPU and GPU in every step is a common hidden cost.

When a model “does not fit on the GPU”, it means it does not fit in HBM.

Memory-bound or compute-bound?

A GPU has two speed limits:

  1. Compute: how many FLOPs per second. A high-end data center GPU can do roughly 1,000 TFLOPS of dense BF16 math on its tensor cores.
  2. Memory bandwidth: how many bytes per second it can read from HBM. For the same GPU, about 3.35 TB per second.

Divide the two: about 300 FLOPs per byte. This is the GPU’s balance point. Now look at a job’s arithmetic intensity: how many FLOPs it does for each byte it reads.

  1. Below the balance point → memory-bound. The cores wait for data.
  2. Above it → compute-bound. The memory waits for the cores.
memory-boundcores wait for datacompute-boundmemory waits for coresbalance point ≈ 300decode, 1 user≈ 1decode, batch 64≈ 64prefill, 2,000 tokens≈ 2,000FLOPs per byte read (log scale)
Decode for one user does about 1 FLOP per byte read, far below the balance point. Batching moves it to the right. Prefill of a long prompt is already compute-bound.

Apply this to our model:

  1. Decode, one user. Each weight (2 bytes) is used for one multiply and one add: 2 FLOPs per 2 bytes = about 1 FLOP per byte. Very memory-bound. The speed limit is reading 16 GB of weights per step: at 3.35 TB/s that is about 5 ms, so about 200 tokens per second at best.
  2. Decode, batch of 64. The weights are read once for 64 tokens: about 64 FLOPs per byte. Still memory-bound, but 64 times more useful work for almost the same time.
  3. Prefill of a 2,000-token prompt. About 2,000 FLOPs per byte of weights. Compute-bound.

This is the single most useful idea in LLM serving.

Why “GPU-Util 100%” lies

The GPU-Util number in nvidia-smi means: in the last sample period, was at least one kernel running? It does not say how many cores were busy or how much bandwidth was used.

  1. A single small kernel running all the time shows 100%.
  2. Decode with batch size 1 shows near 100% while most of the compute power is idle.
  3. Better signals: tokens per second, batch size, KV cache usage, and profiler numbers like memory bandwidth used and SM activity (for example from NVIDIA DCGM or Nsight).

So the teammate’s GPU was “busy” but not “full”.

Number formats

Every weight and activation is stored in some number format. Fewer bytes means less memory and faster reading.

Format Bytes Notes
FP32 4 Full precision. Rarely used for LLM inference weights.
FP16 2 Half precision. Small range: very big numbers can overflow.
BF16 2 Same range as FP32, less precision. The common default for LLMs today.
FP8 1 Needs newer GPUs and engine support. Often used for weights or the KV cache.
INT8 / INT4 1 / 0.5 Integer formats for quantized weights. Check quality with evals.
params = 8e9
for name, bytes_per in [("FP32", 4), ("BF16", 2), ("FP8", 1), ("INT4", 0.5)]:
    print(name, params * bytes_per / 1e9, "GB")
# FP32 32.0 GB, BF16 16.0 GB, FP8 8.0 GB, INT4 4.0 GB

Fewer bytes per weight also means faster decode, because decode is memory-bound. The “Quantization” lesson goes deeper.

Common mistakes

Mistake Result Right way
Trusting GPU-Util as “how busy” Buying GPUs too early. Watch tokens/s, batch size, KV cache, bandwidth.
Looking only at TFLOPS when choosing a GPU Slow decode on a “fast” GPU. For decode, memory bandwidth and HBM size matter most.
Copying tensors to the CPU in every step Hidden slowness over PCIe. Keep data on the GPU; copy only the final tokens.
Using FP16 where the model was trained in BF16 Rare overflows, nan outputs. Use the format the model card recommends.

Summary in six lines

  1. A GPU has thousands of simple cores; a kernel is a program they run.
  2. Weights and the KV cache live in HBM; CPU memory over PCIe is far slower.
  3. Balance point = FLOPs per second ÷ bytes per second, about 300 on a high-end GPU.
  4. Decode for one user is about 1 FLOP per byte: memory-bound. Batching raises it.
  5. GPU-Util only says a kernel was running, not how full the GPU is.
  6. Fewer bytes per number means less memory and faster decode.

Done reading this lesson?Mark it as finished so it shows in your lessons list and report card.