Serving large language models in production environments requires managing two fundamentally different compute regimes: the compute-bound prefill phase and the memory-bandwidth-bound autoregressive decode phase. Over the past three years, the infrastructure stack for LLM inference has shifted from naive batched execution to specialized serving engines capable of continuous batching, non-contiguous key-value (KV) cache memory management, prefix caching, and compiler-level kernel fusion.
Four systems represent the primary choices for deploying open-weight models at scale: vLLM, SGLang, NVIDIA TensorRT-LLM, and Hugging Face Text Generation Inference (TGI). While each runtime aims to maximize token throughput and minimize Time-to-First-Token (TTFT) and Inter-Token Latency (ITL), they make distinct architectural trade-offs in KV cache layout, scheduling granularity, structured generation support, and hardware portability.

The Dual-Regime Inference Bottleneck
To evaluate serving engines, one must examine how autoregressive transformers consume hardware resources.
During the prefill phase, the model processes the entire input prompt simultaneously. This operation is dominated by General Matrix Multiplications (GEMMs), exhibiting high arithmetic intensity where tensor cores operate near theoretical peak compute limits.
During the decode phase, the model generates output tokens sequentially, one token per sequence per forward pass. Generating a single token requires loading all model weights and historical KV tensors from high-bandwidth memory (HBM) into SRAM to perform General Matrix-Vector (GEMV) operations. This decode phase has low arithmetic intensity and is strictly bottlenecked by GPU memory bandwidth.
Furthermore, dynamic request lengths create severe memory allocation challenges. The KV cache size scales linearly with sequence length:
KV Size = 2 * n_layers * n_heads * d_head * seq_len * precision_bytes
For a 70B parameter model in FP16 precision, each token requires approximately 1.3 MB of KV cache. In early inference engines, static memory pre-allocation for maximum sequence lengths resulted in 60% to 80% of GPU memory being wasted due to internal fragmentation (unallocated space reserved for potential output tokens) and external fragmentation (unusable memory gaps between variable-length requests).
Modern serving engines exist primarily to resolve memory fragmentation, maximize compute saturation across mixed prefill-decode batches, and minimize scheduling overhead.
Architectural Comparison
1. vLLM: Virtual Memory Paging and Chunked Prefills
Developed at UC Berkeley and published at SOSP 2023, vLLM introduced PagedAttention, an algorithm inspired by virtual memory management in operating systems.
Key architectural components of vLLM include:
- Block-Based KV Allocation: Physical KV cache is partitioned into fixed-size contiguous blocks (typically 16 or 32 tokens). Logical token sequences map to physical blocks through a centralized block allocation table, eliminating external fragmentation and capping internal fragmentation at the boundary of a single block.
- Copy-on-Write Memory Sharing: When requests share prefixes (such as few-shot prompts, parallel sampling branches, or beam search), multiple logical sequences point to identical physical blocks. New physical blocks are allocated only when a sequence mutates its state.
- Chunked Prefills: By adopting scheduling principles from SARATHI, vLLM divides long prompt prefills into discrete chunks. A single prefill chunk is batched alongside ongoing decode requests ("piggybacking"), maintaining high compute saturation while preventing long prompts from starving decode iterations and causing latency spikes.
- V1 Engine Redesign: Recent architectural updates in vLLM V1 decoupled the execution loop, introducing a lightweight C++ scheduler and continuous execution pipeline that minimizes Python runtime overhead.
2. SGLang: RadixAttention and Compressed FSMs
Introduced by Lianmin Zheng and colleagues at LMSYS and UC Berkeley (NeurIPS 2024), SGLang was designed to accelerate complex language model programs, including multi-turn conversations, agent workflows, and structured JSON generation.
Core architectural features of SGLang include:
- RadixAttention for Prefix Caching: Rather than treating KV caches as static request allocations, SGLang maintains a global Radix Tree over physical KV cache memory blocks. The radix tree maps token sequences to their cached KV tensors across different user requests and chat turns. Cache lookup, insertion, and Least Recently Used (LRU) eviction operate directly on the tree structure, enabling zero-copy cache hits for multi-turn sessions, few-shot prompts, and system instructions.
- Compressed Finite State Machines (FSM): Structured decoding frameworks typically mask invalid vocabulary logits at each step, incurring significant CPU-GPU synchronization latency. SGLang compiles regular expressions and JSON schemas into compressed FSMs. When a regex contains deterministic multi-character string constants (such as JSON keys or formatting syntax), the runtime decodes multiple tokens in a single step without invoking full model forward passes.
- FlashInfer Kernel Integration: SGLang integrates closely with FlashInfer, providing high-performance fused attention kernels optimized for heterogeneous batch sizes and variable prefix-shared attention patterns.
3. NVIDIA TensorRT-LLM: Hardware-Fused Compilation and Disaggregation
TensorRT-LLM is NVIDIA's compiler-driven C++ and Python framework for maximizing inference throughput on Tensor Core GPUs (Hopper, Ada Lovelace, and Blackwell architectures).
Key architectural features include:
- In-Flight Batching (IFB): TensorRT-LLM was an early production implementer of iteration-level batching via its C++ Batch Manager. Requests enter and exit the generation loop on individual token iterations without pipeline stalls.
- Custom Hardware Kernels: TRT-LLM leverages highly tuned CUTLASS GEMM routines, custom XQA (Hopper-optimized attention) kernels, and fused multi-head attention (FMHA). It provides native support for FP8 (E4M3/E5M2) and FP4 quantization formats on Hopper and Blackwell tensor cores.
- Disaggregated Serving: TensorRT-LLM supports prefill-decode disaggregation architectures (separating compute-bound prefill instances from memory-bandwidth-bound decode instances across dedicated GPU nodes), communicating KV cache transfers via high-speed NVLink and InfiniBand networks.
- Triton C++ Backend: Production deployments run through the Triton Inference Server C++ backend, offering multi-GPU tensor and pipeline parallelism without Python interpreter locks.
4. Hugging Face Text Generation Inference (TGI): Rust Router Architecture
Developed by Hugging Face, Text Generation Inference (TGI) established many modern serving standards, including Safetensors streaming and continuous batching.
Key architectural features include:
- Rust / Python Hybrid Architecture: TGI utilizes a high-performance web server and request router written in Rust that communicates with Python model worker processes over gRPC and Unix domain sockets.
- Zero-Copy Weight Loading: Fast startup and dynamic sharding via Safetensors memory mapping.
- Current Lifecycle Status: Hugging Face announced that TGI is in maintenance mode, with active development efforts redirecting toward contributing upstream optimizations to community engines such as vLLM and SGLang.
Comparative Breakdown: Key Technical Dimensions
KV Cache Memory Management
- vLLM: Paged memory blocks with centralized page table. Supports automatic prefix caching using hash-based block matching.
- SGLang: Radix tree-indexed KV cache. Provides native tree-based LRU eviction, prefix matching, and hierarchical cache reuse across requests.
- TensorRT-LLM: Paged KV cache managed in C++ memory pools with optional offloading and disaggregated KV streaming across nodes.
- TGI: Paged attention memory management integrated with FlashAttention kernels.
Scheduling and Batching Mechanics
- vLLM: Continuous iteration-level batching with chunked prefill scheduling (Sarathi algorithm) to balance TTFT and ITL.
- SGLang: Continuous batching with Radix-aware scheduling, prioritizing requests that share existing cache prefixes to maximize cache hit rates.
- TensorRT-LLM: In-Flight Batching (IFB) with dynamic micro-batch management and support for heterogeneous prefill/decode split execution.
- TGI: Continuous batching via Rust router with token-level dynamic scheduling.
Structured Output and Constrained Decoding
- vLLM: Integrates with Outlines and llguidance for logit masking based on regular expressions and Context-Free Grammars (CFGs).
- SGLang: Native compressed FSM interpreter with jump-forward decoding, bypassing forward passes on deterministic token strings.
- TensorRT-LLM: Support for guided decoding via XGrammar integration and custom logit processors.
- TGI: Grammar-guided generation using Outlines-backed FSM logit index masking.
Hardware Portability and Ecosystem
- vLLM: Highly portable: NVIDIA CUDA, AMD ROCm, Intel Gaudi, AWS Inferentia, and Apple Silicon (via Metal/MPS).
- SGLang: Primarily optimized for NVIDIA CUDA and AMD ROCm.
- TensorRT-LLM: Exclusively optimized for NVIDIA architectures (Ampere, Ada Lovelace, Hopper, Blackwell).
- TGI: NVIDIA CUDA, AMD ROCm, and Intel Gaudi.
Serving Economics and Deployment Selection
Selecting an inference engine depends on the structure of production traffic, hardware constraints, and operational complexity tolerances.
+--------------------------------------------------------------------------------+
| Workload Traffic Pattern |
+--------------------------------------------------------------------------------+
|
+----------------------------+----------------------------+
| |
[Multi-turn Chat / Agent Tool Loops] [High-Throughput General API]
[Shared System Prompts & RAG] [Diverse Mixed-Length Tasks]
| |
v v
Choose SGLang Choose vLLM
(RadixAttention prefix reuse (Sarathi chunked prefill,
& compressed FSM jump decoding) broad hardware support)
|
+---------------------------+
|
[Pure NVIDIA Infrastructure]
[Targeting Maximum Hardware FLOPs]
[Dedicated Infra Operations Team]
|
v
Choose TensorRT-LLM
(Custom XQA kernels, FP8/FP4,
prefill-decode disaggregation)When to Deploy SGLang
SGLang offers distinct performance advantages for workloads characterized by significant prompt sharing:
- Agentic Workflows and Tool Calling: Multi-turn agent loops append observations to existing message histories. RadixAttention retains historical prefixes in VRAM, eliminating redundant prompt computation across successive turns.
- Complex RAG Pipelines: When thousands of queries reference shared document chunks or system instructions, SGLang achieves high cache hit ratios, reducing TTFT significantly.
- Heavy JSON / Structured Schema Output: The compressed FSM jump decoding engine provides measurable speedups when generating rigidly formatted data payloads.
When to Deploy vLLM
vLLM serves as the standard general-purpose inference engine across enterprise architectures:
- Multi-Vendor Hardware Fleets: Organizations running mixed hardware (such as NVIDIA H100s alongside AMD MI300X or Intel Gaudi accelerators) can standardize on a single serving API and deployment manifest.
- Variable-Length Mixed Workloads: The chunked prefill scheduler prevents long background document summarizations from degrading real-time chat latency.
- Rapid Model Adoption: Community support allows immediate day-zero deployment of newly released model architectures.
When to Deploy TensorRT-LLM
TensorRT-LLM is suited for high-scale, dedicated deployments on pure NVIDIA hardware:
- Maximum FLOP Utilization: When extracting maximum throughput from HGX H100/H200 or GB200 clusters, TensorRT-LLM's fused XQA kernels and optimized FP8 GEMMs deliver the highest raw tokens per second per dollar.
- Disaggregated Deployments: Large-scale production clusters with separate prefill and decode pools benefit from TRT-LLM's optimized KV transfer infrastructure.
- Trade-off: Requires engine build and serialization steps for specific GPU architectures, increasing deployment cycle times compared to Python-native engines.
Sources
- Efficient Memory Management for Large Language Model Serving with PagedAttention (SOSP 2023 / arXiv:2309.06180)
- SGLang: Efficient Execution of Structured Language Model Programs (NeurIPS 2024 / arXiv:2312.07104)
- SARATHI: Efficient LLM Inference by Piggybacking Decodes with Chunked Prefills (arXiv:2308.16369)
- NVIDIA TensorRT-LLM Architecture and Documentation
- Hugging Face Text Generation Inference Repository and Architecture



