If you have ever watched an LLM generate a long response and wondered why it seems to crawl after the initial prompt flash, you are observing a hardware bottleneck in real time. Most developers blame their Python code, the framework, or the sheer size of the model. They profile functions, swap optimizers, and shave milliseconds off preprocessing. None of that fixes the real problem. The speed limit is not in your software. It is in the silicon.
Every large language model inference job depends on two physical traits of the GPU sitting in your server: how fast it can crunch numbers, and how fast it can move those numbers into position to be crunched.
Math Is Cheap. Moving Data Is Not
GPU marketing loves to talk about compute. Trillions of floating-point operations per second. The numbers are staggering. But compute is only half the story. The other half is memory bandwidth, the rate at which data travels from high-bandwidth memory into the compute cores where the actual arithmetic happens.
An LLM cannot run faster than the weaker of these two links. Imagine a commercial kitchen with twenty master chefs. The ovens are hot, the knives are sharp, and every cook is ready. But the produce delivery arrives by bicycle, one basket at a time. The kitchen stalls. Adding more chefs will not fix it. Buying faster ovens will not fix it. The bottleneck is the road.
In modern datacenter GPUs, the arithmetic units are so powerful that they often finish their calculations and then sit idle, burning cycles while they wait for weights and activations to stream through memory. This imbalance is not a bug in your code. It is the physical reality of how chips are built. Memory bandwidth has not kept pace with raw compute, and LLMs are particularly cruel to this imbalance because their forward passes require touching every single parameter for every single output token.
Why Prompts Feel Fast and Generation Feels Slow
LLM inference splits into two distinct phases, and they stress the hardware in completely different ways.
Prefill happens when your prompt first hits the model. All tokens arrive together. The GPU can process them in parallel using large matrix-matrix multiplications. Thousands of arithmetic units fire at once, and the workload stays dense. This phase is compute-bound. That sudden burst of speed you see at the start? That is the GPU doing exactly what it was built to do.
Decode is where things turn painful. When the model generates the next token, it does so one token at a time. This stage relies on matrix-vector operations, which use only a tiny fraction of the GPU's parallel capacity. Worse, every new token forces the GPU to reload the entire model weights from memory. The arithmetic units want work. Instead, they wait. Decode is memory-bound. The GPU is effectively acting as an expensive traffic controller, shuttling parameters back and forth across the memory bus while the math engines cool off. This is why a hundred-word response can take ten seconds even though the initial prompt analysis felt instant.
The KV cache makes this even more interesting. During decode, the model stores key and value tensors for every previous token so it does not recompute attention from scratch. That cache grows with sequence length. It also lives in memory. So now the GPU is not just reloading weights; it is reading and writing an ever-expanding cache on every single forward pass. The compute cores are barely breaking a sweat while the memory bus sweats for both of them.
Fighting the Memory Wall
Engineers have developed a small arsenal of techniques to reduce how much data must move, or at least to share the cost of moving it.
Batching is the most straightforward. If one user’s request forces a full weight load from memory, then processing eight or sixteen requests at once lets the GPU amortize that load across all of them. The weights are read once and reused for every sequence in the batch. In production, sophisticated scheduling systems group requests dynamically, sometimes called continuous or in-flight batching, so that the GPU rarely pauses. It is the difference between a bus and sixteen separate cars on the same route.
Quantization hushughulikia tatizo la bandwidth moja kwa moja. Model weights kwa kawaida huhifadhiwa katika mifumo ya sixteen-bit floating-point. Kwa kuzipunguza hadi kuwa eight-bit au hata four-bit integers, unakata kiasi cha data kinachosafiri kwenye bus kwa nusu au zaidi. Modeli bado inahitaji usahihi wa kutosha ili kutoa matokeo yenye mantiki, lakini mbinu za kisasa za post-training quantization zinaweza kupunguza memory footprint ya modeli kwa kiasi kikubwa bila kuharibu ubora. Data kidogo inayotiririka inamaanisha muda mdogo wa kusubiri kwenye memory controller.
FlashAttention inarekebisha attention mechanism ili kuweka matokeo ya kati ndani ya
