Why does a large language model sometimes feel instant and other times crawl, even when it runs on the same GPU? The answer rarely comes down to raw chip speed. It comes down to architecture: how memory moves, how requests are batched, how the key-value cache is stored, and how kernels are written. Understanding GPU inference architecture is the difference between buying more hardware and actually fixing the bottleneck.
This article walks through the systems decisions that shape inference performance, from the memory hierarchy up to serving frameworks. It focuses on what practitioners get wrong and what genuinely moves the needle.
What GPU inference architecture actually means
GPU inference architecture is the full stack of decisions that determine how a trained model turns a prompt into output on graphics hardware. That includes the physical memory hierarchy, the kernels that execute model operations, the way the key-value cache is managed, the batching scheduler, and the serving layer that ties it together.
It is not the same as model architecture. A transformer is a transformer whether it runs on a laptop or a data center rack. Inference architecture is about the execution environment around that model, and it is where most of the performance variance lives.
The stack generally looks like this:
| Layer | What it controls | Typical failure mode |
|---|---|---|
| Memory hierarchy | Where data lives (registers, SRAM, L2, HBM) | Kernel starved by memory reads |
| Kernels | How each operation executes | Unfused ops, extra round trips to HBM |
| KV cache | Stored context for each request | Fragmentation, wasted memory |
| Scheduler | Which requests run together | Padding waste, idle GPU cycles |
| Serving layer | Routing, scaling, observability | Queuing delays, poor utilization |
Each layer can be the bottleneck. Fixing the wrong one wastes money.
The memory hierarchy is the real design constraint

GPUs are not simply fast processors. They are processors surrounded by a carefully tiered memory system, and kernel design is largely about exploiting that hierarchy. Registers are fastest, shared memory (SRAM) sits on-chip, L2 cache is shared across the chip, and high-bandwidth memory (HBM) holds the model weights and activations but sits much further away in latency terms.
The official CUDA C++ programming guide documents this hierarchy in detail, and it is worth reading if you want to reason about why a kernel is slow rather than guessing. The practical takeaway is simple: every byte fetched from HBM costs time, so good kernels minimize those trips. (CUDA Zone: parallel computing platform overview)
This matters enormously for large language models. Autoregressive decoding generates one token at a time, streaming the model weights from HBM on each step. For a single request, the GPU’s arithmetic units are often mostly idle while waiting for memory. This is why memory bandwidth, not raw FLOPs, frequently limits single-request decoding. Adding more compute does not help if the compute is waiting on data.
FlashAttention and the IO-aware mindset
The clearest illustration of memory-aware kernel design is FlashAttention, an IO-aware exact attention algorithm that tiles computation so intermediate results stay in on-chip SRAM instead of being written out to HBM and read back. The FlashAttention paper explains the motivation directly: attention is memory-bound on modern hardware, and reducing memory reads and writes is the lever.
The broader lesson generalizes. When teams profile a slow inference pipeline, the fix is often kernel fusion or tiling, not a bigger GPU. Operators that could run in one fused kernel but instead run as five separate kernels pay five round trips to HBM.
The KV cache is where memory budgets disappear
Every token a model has already processed must be remembered so the next token can attend to it. That stored state is the KV cache, and it grows linearly with sequence length and batch size. For long-context workloads it becomes the dominant memory cost, often dwarfing the model weights themselves.
This is the single most common planning error: teams size a GPU by model weights alone, then discover that concurrent long requests exhaust memory long before compute is saturated. A useful companion read is why memory capacity matters for inference planning, which walks through the sizing math. (Graphics processing unit (Wikipedia))
Two techniques dominate how the cache is handled:
- PagedAttention, introduced with vLLM, stores the KV cache in non-contiguous blocks managed much like operating system virtual memory. The vLLM and PagedAttention paper reports that this approach sharply reduces memory waste from fragmentation and over-reservation, improving serving throughput as a result.
- Grouped-query attention (GQA) reduces the size of the cache itself by sharing key and value heads across multiple query heads, trading a small amount of model quality for a large memory saving.
In practice, teams that run long-context workloads often combine both: a GQA-based model served with a paged cache. The combination is what makes high concurrency feasible on a fixed number of GPUs.
Batching decides whether the GPU is busy or bored
If decoding is memory-bound, the way to use the idle compute is to run more requests at once. That is batching, and the scheduling strategy matters more than most people expect.
Static batching groups a set of requests and runs them to completion together. It is simple, and it wastes GPU cycles. Short requests finish early and leave their slots empty. Long requests hold up the whole batch. Padding to equal lengths burns memory and compute on nothing.
Continuous batching, also called iteration-level scheduling, adds new requests into the running batch at each decode step. The Orca paper presented at USENIX OSDI 2022 describes this approach: the scheduler operates at the granularity of a single generation step rather than a whole request, so finished sequences are dropped and new ones join immediately. The result is much higher GPU utilization, especially with variable-length traffic.
For real-world serving, continuous batching is close to mandatory. The trade-off is complexity in the scheduler and more careful memory management, since the KV cache must accommodate a batch that changes every step.
Choosing between real-time and batch inference
Not every workload needs interactive latency. Offline jobs such as document summarization, embedding generation, or nightly classification can run as batch inference, where throughput and cost per token matter far more than response time. Interactive chat needs low time-to-first-token and steady per-token latency.
The two goals pull in different directions. Batch workloads can use large static batches and aggressive quantization; interactive workloads need continuous batching, careful admission control, and headroom for spikes. A practical comparison of the trade-offs is laid out in choosing between batch and real-time inference, which is worth reviewing before committing to a serving design.
Quantization and precision: trading accuracy for bandwidth
Because decoding is bandwidth-bound, anything that reduces the bytes moved per token speeds things up. Quantization stores weights and sometimes activations in lower precision, such as INT8 or INT4, cutting memory traffic and often compute cost.
The trade-off is accuracy. Aggressive quantization can degrade output quality, particularly on reasoning-heavy tasks, and the damage is not always obvious in casual testing. A sound practice is to benchmark quantized models against the full-precision baseline on a task-specific evaluation set rather than trusting a generic benchmark score.
Precision choice also interacts with hardware features. Newer GPU generations include dedicated support for low-precision formats, and runtimes like NVIDIA TensorRT-LLM provide optimized kernels for them. The practical rule: pick the lowest precision that passes your own quality bar, and re-verify after any model or runtime upgrade, because kernel support and numerical behavior change between versions.
Where serving frameworks fit
Most teams do not write inference kernels. They assemble a serving stack, and the framework choice determines which optimizations are available out of the box. The main options include vLLM, NVIDIA Triton Inference Server, TensorRT-LLM, and Hugging Face TGI, each with different strengths in batching, quantization support, and operational tooling.
A sensible evaluation process looks like this:
- Define the workload: sequence lengths, concurrency, latency targets, and quality thresholds.
- Benchmark candidate frameworks on your own traffic pattern, not a vendor demo.
- Measure end-to-end latency, including queuing, not just kernel time.
- Test failure behavior under load, since scheduling breaks down first at saturation.
- Re-benchmark after upgrades, because feature sets shift quickly.
The measurement discipline matters as much as the framework. A guide to measuring inference latency end to end explains why averaging latency hides the tail, and why p95 and p99 numbers are what users actually feel.
How the pieces connect at the infrastructure level
Zoom out and the inference stack is one part of a larger picture. Model serving sits on top of cloud infrastructure, networking, storage, and orchestration. Decisions at that layer, such as instance types, autoscaling policy, and placement, constrain what the serving layer can achieve. A broader view of cloud infrastructure and architecture helps frame those choices.
There is also a growing pattern of infrastructure that adapts to the model rather than the reverse. Schedulers that route requests based on cache locality, or that scale replicas based on queue depth, are examples of this shift toward AI cloud architecture where infrastructure becomes intelligent.
For teams designing the full stack, a practical enterprise guide to AI inference architecture is a useful reference point for how the layers fit together and where to invest first.
Common mistakes that quietly cost money
A few patterns show up again and again in real deployments.
Sizing by model weights only. The KV cache is the hidden cost. Plan for concurrency and sequence length, not just parameters.
Ignoring time-to-first-token. Prefill and decode have different bottlenecks. A system that handles decode well can still feel slow if prefill queues up.
Benchmarking with uniform synthetic traffic. Real traffic has a long tail of long requests. Uniform benchmarks hide the stragglers that wreck static batching.
Over-quantizing without evaluation. A model that scores well on a generic benchmark can still fail on your specific task after INT4 quantization.
Skipping tail latency. Mean latency is a comfort metric. p99 is the one that generates support tickets.
Treating framework defaults as optimal. Default batch sizes and cache settings are starting points, not answers. Tune them against your own workload.
Conclusion
GPU inference architecture is less about the chip and more about the flow of data around it. The memory hierarchy sets the physical limits, kernel design determines how efficiently those limits are approached, the KV cache governs how much concurrency fits in memory, and the scheduler decides whether the hardware is actually busy. Quantization and serving frameworks are the levers that translate those principles into throughput and cost.
The teams that get this right tend to share a habit: they measure before they buy. They know their p99 latency, their cache footprint per request, and their real traffic distribution. That knowledge is worth more than an extra GPU, and it is available to anyone willing to profile carefully.
FAQ
What is the difference between GPU inference and GPU training?
Training updates model weights through forward and backward passes, so it is compute-heavy and benefits from large batches and high FLOP throughput. Inference only runs forward passes, and for autoregressive models it is often memory-bandwidth-bound instead. That means the hardware and optimization choices differ: training favors raw compute and interconnect, while inference favors memory capacity, memory bandwidth, and smart scheduling.
Why is my GPU underutilized during inference?
The most common causes are static batching that leaves slots idle, KV-cache fragmentation that forces small batches, and single-request decoding that cannot saturate compute. Continuous batching and paged KV-cache management usually address all three. It is also worth checking whether prefill and decode are competing for the same resources, since mixing them poorly can stall both.
Does a bigger GPU always mean faster inference?
No. If the workload is bandwidth-bound, a GPU with more compute but similar memory bandwidth may deliver little improvement. Memory capacity matters too: a larger card can hold more concurrent KV cache, which raises throughput. The right question is which resource is saturated, and that requires profiling rather than spec sheets.
What is PagedAttention and why does it matter?
PagedAttention stores the KV cache in non-contiguous blocks managed like virtual memory pages, rather than requiring one contiguous allocation per request. This reduces wasted memory from fragmentation and over-reservation, which lets a server hold more concurrent requests. The technique, introduced with vLLM, is now a standard part of high-throughput LLM serving.
How much does quantization actually help?
It depends on the bottleneck. Because decoding is often bandwidth-bound, reducing weight precision cuts the bytes moved per token and can meaningfully improve throughput and latency. The gain shrinks if the workload is compute-bound or if the runtime lacks optimized kernels for the chosen format. Always validate quality on your own task before shipping a quantized model.
What should I measure first when tuning inference?
Start with end-to-end latency broken into time-to-first-token and per-token decode time, then add throughput at your target concurrency. Track p95 and p99, not just averages. Finally, measure GPU memory headroom and utilization together, because a memory-starved scheduler and a compute-starved kernel look similar in a single dashboard but need opposite fixes.







