LLM Inference Optimization: Inside vLLM's High-Throughput Engine Design

When a Hacker News thread dissecting vLLM's internals pulls 131 upvotes, it's not because readers care about one open-source project — it's because llm inference optimization is the single most expensive unsolved problem in applied AI right now. Every team serving a model in production eventually hits the same wall: latency climbs, GPU bills balloon, and throughput plateaus far below what the hardware should theoretically deliver. The vLLM project, built initially at UC Berkeley's Sky Computing Lab, became a reference implementation precisely because it made the invisible bottlenecks visible.
This isn't a vLLM tutorial. It's a breakdown of the actual engineering problem — why inference is hard, what's actually consuming your GPU cycles, and which optimization techniques deliver real throughput gains regardless of which serving framework you choose.
Why LLM Inference Optimization Is Fundamentally Different From Training
Training is throughput-bound and predictable — you know your batch size, sequence length, and epoch count in advance. Inference is latency-bound, bursty, and unpredictable, with requests arriving at random intervals with wildly different input and output lengths. A chatbot request might generate 20 tokens or 2,000, and you don't know which until generation finishes.
This asymmetry is why naive inference serving is so wasteful. Static batching — the default approach — forces short requests to wait for the longest one in a batch to finish, leaving GPU compute idle for a large fraction of each cycle. Studies from the vLLM team (Kwon et al., 2023, "Efficient Memory Management for Large Language Model Serving with PagedAttention") showed that naive systems waste 60-80% of KV cache memory to fragmentation and over-allocation, directly capping achievable batch sizes.
The core resource being fought over isn't raw FLOPs — it's memory bandwidth and GPU HBM capacity, consumed almost entirely by the KV cache.
The KV Cache Bottleneck Everyone Underestimates
Every transformer decoder step needs the key and value tensors from all previous tokens to compute attention. Storing these tensors — the KV cache — grows linearly with sequence length and batch size, and for large models it dwarfs the memory footprint of the weights themselves. A 13B parameter model serving 2,048-token contexts at reasonable batch sizes can require tens of gigabytes of KV cache alone, on top of the ~26GB the weights occupy in FP16.
Before PagedAttention, most engines pre-allocated a maximum-length contiguous memory block per sequence, regardless of actual usage. If a request needed only 50 tokens but the system reserved space for 2,048, that unused allocation blocked other requests from being scheduled — pure waste sitting in HBM.
GPU memory fragmentation diagram.
vLLM's answer borrows directly from operating systems: virtual memory paging. Instead of contiguous allocation, the KV cache is split into fixed-size blocks that can be scattered non-contiguously across memory and mapped via a block table, exactly like OS page tables map virtual to physical memory. This single architectural decision is credited with vLLM's headline 2-4x throughput improvement over prior systems like FasterTransformer and Orca in the original benchmarks.
Continuous Batching: The Scheduler-Level Fix
Static batching's core flaw is that it batches at the request level, not the iteration level. Continuous batching (also called in-flight batching, a term popularized by NVIDIA's TensorRT-LLM) instead makes scheduling decisions at every single forward pass. As soon as one sequence in a batch finishes generating, a new incoming request is immediately slotted into that freed batch slot.
The practical effect is that GPU utilization stops being gated by the slowest request in an arbitrary batch window. Orca, the 2022 OSDI paper that introduced this idea, reported throughput gains of over 10x compared to naive request-level batching under realistic, variable-length workloads. This is now table stakes — vLLM, TensorRT-LLM, and Hugging Face's TGI all implement some variant.
The tradeoff is scheduling complexity: the engine must constantly rebalance which sequences get compute each step, weighing new prompt "prefill" work against ongoing "decode" work for existing sequences, since these have very different compute profiles.
Quantization: Trading Precision for Throughput
Reducing numerical precision is the most direct lever for cutting memory footprint and increasing effective batch size. Moving weights from FP16 to INT8 halves memory usage; INT4 techniques like GPTQ and AWQ (Activation-aware Weight Quantization) push it further, often with less than 1-2% degradation in benchmark accuracy for well-calibrated methods.
The gain isn't just storage — inference on memory-bandwidth-bound workloads (which decoding almost always is) speeds up because moving less data per token directly reduces the dominant bottleneck. FP8 support on NVIDIA Hopper and Blackwell GPUs has pushed this further into production, with vLLM, TensorRT-LLM, and SGLang all shipping native FP8 KV cache and weight support by 2024-2025.
Quantizing the KV cache itself (not just weights) is a newer, more aggressive optimization — since KV cache, not weights, is often the actual memory ceiling at scale. This is why techniques like KV cache quantization to FP8 or even INT4 have become a 2025 focus area across every major inference engine.
Speculative Decoding and Other Latency Tricks
Speculative decoding uses a small, fast "draft" model to propose several tokens ahead, which the larger target model then verifies in a single parallel forward pass rather than generating token-by-token. When the draft model's guesses are accepted (common for predictable text), this can cut end-to-end latency by 2-3x with mathematically identical output distributions to standard sampling.
speculative decoding draft verification.
Prefix caching is another underrated win: if multiple requests share a common prompt prefix (a system prompt, a RAG template), the KV cache for that prefix can be computed once and reused, eliminating redundant prefill compute entirely. For applications with repeated system prompts — the vast majority of production chat and agent systems — this alone can meaningfully cut average latency.
Choosing an Inference Engine: What Actually Matters
vLLM, TensorRT-LLM, SGLang, and Hugging Face TGI all now implement PagedAttention-style memory management and continuous batching — the baseline has converged. Differentiation now lives in scheduler sophistication, quantization format support, multi-GPU tensor/pipeline parallelism efficiency, and how well each handles structured output (JSON mode, function calling) without throughput collapse.
SGLang, built by the LMSYS team behind Chatbot Arena, has gained traction specifically for its RadixAttention approach to prefix caching, showing particular strength in agentic and multi-turn workloads. TensorRT-LLM tends to win on raw single-GPU NVIDIA hardware performance due to kernel-level optimization, at the cost of flexibility and slower iteration on new model architectures.
For teams evaluating options, the honest answer is: benchmark on your actual traffic pattern, not published leaderboards. A RAG system with long shared prefixes behaves nothing like a creative-writing chatbot with long, unique generations.
server rack running AI inference.
Practical Steps to Optimize Your Own LLM Inference
- Profile before you optimize — measure your actual time-to-first-token and inter-token latency separately; prefill and decode bottlenecks require different fixes.
- Adopt a continuous-batching engine (vLLM, TensorRT-LLM, or SGLang) instead of a naive HTTP wrapper around
model.generate()— this alone typically yields multi-x throughput gains. - Quantize deliberately — start with FP8 or AWQ INT4 on weights, benchmark accuracy on your actual eval set, then consider KV cache quantization if memory is still the ceiling.
- Exploit shared prefixes — if your system prompts or RAG templates repeat across requests, enable prefix/radix caching to avoid redundant compute.
- Right-size your context window — don't pay the KV cache tax for a 128K context window if your real workload rarely exceeds 4K tokens.
Frequently Asked Questions
What is the main bottleneck in LLM inference?
For most production workloads, the bottleneck is GPU memory bandwidth and capacity consumed by the KV cache, not raw compute (FLOPs). This is why memory-management techniques like PagedAttention and quantization deliver larger gains than simply adding more compute.
Does quantization hurt LLM output quality?
Well-calibrated INT8 or INT4 quantization methods like AWQ or GPTQ typically cause under 1-2% accuracy degradation on standard benchmarks, though this varies by model and task. Aggressive KV cache quantization requires more careful validation since it directly affects generation quality across long contexts.
Is vLLM better than TensorRT-LLM?
Neither is universally "better" — vLLM offers faster iteration, broader model support, and easier setup, while TensorRT-LLM often achieves higher raw throughput on NVIDIA hardware through deeper kernel-level optimization. The right choice depends on your hardware, model architecture, and how much engineering time you can invest in tuning.



