1. Overview
Both SGLang and vLLM are high-performance, open-source inference engines for serving large language models. They share a lineage: both came out of UC Berkeley research labs, and both have grown quickly into production systems behind some of the world's largest AI deployments. They take different architectural approaches to the same problem, which is making LLM inference fast, efficient, and cost-effective.
SGLang (Structured Generation Language)
SGLang co-designs a frontend DSL with a backend runtime. Its core innovation is RadixAttention, a radix-tree-based KV cache manager that shares prefixes across requests automatically and at fine granularity. It also has a zero-overhead CPU scheduler, a cache-aware load balancer, and a compressed FSM for structured outputs. It is optimized for multi-turn, agentic, and structured workloads.
- Origin: LMSYS Org (Lianmin Zheng, Ying Sheng)
- First release: Jan 2024
- GitHub stars: ~20k+ (as of early 2026)
- Hosted by: LMSYS (PyTorch ecosystem)
vLLM (Virtual Large Language Model)
vLLM pioneered PagedAttention, an OS-inspired virtual memory system for KV cache management. It focuses on maximum hardware compatibility, broad model support, and stability for enterprise use. Its plugin-based architecture supports many backends, quantization formats, and hardware targets. By install base, it is the most widely adopted OSS inference engine.
- Origin: UC Berkeley (Woosuk Kwon)
- First release: Jun 2023
- GitHub stars: ~50k+ (as of early 2026)
- Hosted by: PyTorch Foundation (via LF AI)
2. Architecture comparison
Both engines aim to maximize GPU utilization for LLM serving, but their design philosophies differ. SGLang co-designs the programming interface with the runtime to optimize structured, multi-step generation workflows. vLLM aims to be a modular, pluggable inference engine with the broadest possible compatibility.
SGLang architecture
SGLang inference dataflow
How a request moves through SGLang:
- Cache-aware routing (steps 1-3): The Rust-based sgl-router predicts which backend instance will have the highest cache hit rate for the request's prefix. This gives up to 3.8x higher hit rates than round-robin.
- Radix tree lookup (steps 4-5): The scheduler walks the radix tree to find the longest matching prefix. It finds shared prefixes (system prompts, few-shot examples) automatically, with no configuration.
- Zero-overhead scheduling (step 6): While the GPU processes the current batch, the CPU prepares the next one. This overlap removes the CPU scheduling stalls that can waste up to 50% of time in other engines.
- Execution with jump-forward (steps 7-8): FlashInfer kernels run attention. For structured output, xGrammar's compressed FSM can skip deterministic tokens entirely, bypassing 30-50% of GPU forward passes.
- Cache update and streaming (steps 9-11): New KV cache goes into the radix tree for later reuse, and tokens stream back to the client as they're generated.
vLLM architecture (V1 engine)
vLLM inference dataflow
How a request moves through vLLM:
- Request handling (steps 1-3): The API server tokenizes the input and queues the request in the core engine. vLLM's OpenAI-compatible API is the most mature in the ecosystem.
- Block allocation (steps 4-6): The block manager allocates logical blocks for the sequence. As in OS virtual memory, blocks are fixed size (typically 16 tokens) and mapped to physical GPU memory on demand. Automatic Prefix Caching (APC) checks for reusable prefixes.
- Continuous batching loop (steps 7-12): Each iteration forms a batch from all active requests. The GPU executes attention through block table indirection, so physical blocks don't need to be contiguous. New tokens are appended, and if blocks are shared, copy-on-write creates new physical blocks.
- Memory management (steps 13-14): Under memory pressure, vLLM can preempt lower-priority requests and either swap their KV cache to CPU memory or recompute it later. This is how it copes with bursty workloads.
- Streaming (step 15): Tokens stream back as they're generated, and the loop continues until all sequences complete.
Core philosophical differences
| Dimension | SGLang | vLLM |
|---|---|---|
| Design philosophy | Co-designed frontend language + runtime; treats inference as a program | Modular engine with pluggable backends; treats inference as request serving |
| KV cache strategy | RadixAttention: radix tree, automatic prefix discovery, content-addressable | PagedAttention: OS-style virtual memory, fixed-size blocks, block tables |
| Scheduler | Zero-overhead; overlaps CPU scheduling with GPU compute | Dynamic scheduler with preemption support; V1 engine rewrite |
| Structured output | xGrammar with compressed FSM + jump-forward decoding (up to 10x faster) | Guided decoding via xGrammar / Outlines integration |
| Load balancing | sgl-router: Rust-based, cache-aware routing (1.9x throughput gain) | llm-d: K8s-native with prefix-aware routing (via LMCache) |
| Codebase size | ~4K lines core scheduler (lean, focused) | Larger codebase (broad compatibility layer) |
| Primary language | Python + Rust (router) + CUDA/FlashInfer | Python + C++/CUDA + multi-backend support |
3. KV cache management: the core differentiator
The KV cache is the largest memory consumer during LLM inference, and how each engine manages it is perhaps its single most important architectural decision. Both try to eliminate memory waste and enable sharing, but they use very different data structures and make different trade-offs.
SGLang: RadixAttention (radix tree)
SGLang stores KV cache tensors in a radix tree (compressed trie) whose edges are labeled with variable-length token sequences. Prefix sharing across all requests happens automatically and at fine granularity, with no manual configuration.
How it works:
- When a new request arrives, the system traverses the radix tree matching token-by-token
- Shared prefixes (e.g., system prompts) are found automatically
- Only divergent suffixes need computation
- An LRU eviction policy recursively removes leaf nodes when memory is full
┌─────────────────────────┐
│ "You are a helpful..." │ ← Shared prefix
│ (KV cache computed │ (computed ONCE)
│ once, reused) │
└──────────┬──────────────┘
┌───────────┼───────────────┐
▼ ▼ ▼
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ "What is │ │ "What is │ │ "Explain │
│ Python?" │ │ JavaScript?"│ │ recursion" │
└──────┬───────┘ └──────┬───────┘ └──────┬───────┘
▼ ▼ ▼
[output A] [output B] [output C]
Only the unique suffixes need fresh computation!
The cache is dynamic and content-addressable, so the system "learns" caching patterns from actual traffic. It handles branching conversations, few-shot examples, agentic loops, and tree-of-thought workloads automatically, which makes it a good fit for multi-turn chat, shared system prompts, RAG with common prefixes, and agentic workflows with branching.
vLLM: PagedAttention (virtual memory paging)
vLLM breaks the KV cache into fixed-size blocks (typically 16 tokens each) that can sit non-contiguously in GPU memory. A block table maps logical blocks to physical blocks, an idea taken directly from OS virtual memory.
How it works:
- Each request maintains a block table (like a page table)
- Blocks are allocated on demand, not pre-reserved
- When sequences share a prefix, their block tables point to the same physical blocks
- Copy-on-write handles divergence
- Blocks can be swapped to CPU or recomputed under memory pressure
Request A Physical GPU Memory
┌──────────────┐ ┌─────────────┐
│ Logical Blk 0│──────────► │ Phys Blk 7 │ ← shared prefix
│ Logical Blk 1│──────┐ │ Phys Blk 1 │ ← shared prefix
│ Logical Blk 2│──┐ │ │ Phys Blk 3 │ ← A's unique tokens
└──────────────┘ │ │ │ Phys Blk 5 │ ← B's unique tokens
│ │ │ (free) │
Request B │ │ │ (free) │
┌──────────────┐ │ │ └─────────────┘
│ Logical Blk 0│──┼───┘
│ Logical Blk 1│──┘ Blocks stored
│ Logical Blk 2│──────────► NON-CONTIGUOUSLY
└──────────────┘ (like OS pages)
Memory waste is near zero (under 4%, vs 60-80% in traditional systems), and it works consistently across all hardware backends and model types. It suits predictable workloads, batch inference, templated prompts, beam search, and setups that need broad hardware support.
Practical impact
Say you have 100 requests sharing a 500-token system prompt:
- A traditional system computes 50,000 tokens.
- RadixAttention (SGLang) computes 500 tokens once and reuses them 99 times automatically, with zero configuration.
- APC (vLLM) gives similar savings, but works best when you can predict and structure your caching patterns.
The savings compound with few-shot prompting, RAG pipelines, and multi-turn conversations.
4. Scheduler design
The CPU scheduler is a surprisingly serious bottleneck in LLM inference. On every iteration the CPU decides which requests to batch, allocates memory, handles prefix matching, and prepares metadata, all while the GPU waits. How each engine handles this overhead accounts for a good part of the performance gap between them.
SGLang: zero-overhead scheduler
SGLang's scheduler runs one batch ahead of the GPU: while the GPU processes the current batch, the CPU prepares the next one, so scheduling work overlaps with GPU computation.
TRADITIONAL (Sequential):
┌──────────┐ ┌────────────────────┐ ┌──────────┐ ┌────────────────────┐
│ CPU sched│ │ GPU batch 1 │ │ CPU sched│ │ GPU batch 2 │
└──────────┘ └────────────────────┘ └──────────┘ └────────────────────┘
GPU idle ↑ GPU idle ↑
SGLANG (Overlapped):
┌──────────┐
│CPU prep 1│
└────┬─────┘
│ ┌──────────┐
│ │CPU prep 2│
│ └────┬─────┘
│ │ ┌──────────┐
│ │ │CPU prep 3│
┌────┴───────────────┐ │
│ GPU batch 1 │ │
└────────────────────┤ │
┌───────────────┴─────────────┐
│ GPU batch 2 │
└─────────────────────────────┤
┌──────────────────────┴───────────┐
│ GPU batch 3 │
└──────────────────────────────────┘
→ No GPU idle time! CPU scheduling is fully hidden behind GPU work.
Profiling shows unoptimized engines spend up to 50% of time on CPU overhead. SGLang cuts this to near zero, for a measurable 1.1-1.3x throughput improvement. The effect is largest with small models and large tensor parallelism, where GPU steps are fast and CPU stalls cost proportionally more.
vLLM: V1 engine scheduler
vLLM's V1 engine (released 2025) is a full re-architecture. It uses dynamic scheduling with preemption support, so it can pause lower-priority requests and offload their KV cache to CPU memory when GPU memory is tight.
The V1 scheduler favors flexibility and correctness over raw scheduling speed. It supports guided decoding, speculative decoding, and prefix caching within the same scheduling loop. The cost is somewhat higher per-step overhead than SGLang's heavily optimized pipeline.
5. Structured output generation
Production applications increasingly need guaranteed-valid structured outputs (JSON, XML, SQL). Both engines support constrained decoding, but SGLang has invested more heavily in it.
SGLang: compressed FSM + jump-forward decoding
SGLang compiles output schemas (e.g., Pydantic models) into a compressed finite state machine. When the FSM knows the next token deterministically (like : after a JSON key), SGLang skips the GPU and inserts the token directly. For highly structured outputs, this "jump-forward" technique can bypass 30-50% of generation steps.
With the xGrammar backend, SGLang decodes JSON up to 10x faster than other open-source solutions.
Schema: { "name": str, "age": int }
Standard decoding: GPU → "{" → GPU → '"' → GPU → "n" → GPU → "a" → ...
(every token goes through the model)
Jump-forward: GPU → "name" → SKIP '{"' → GPU → value → SKIP '","age":' → GPU → value → SKIP "}"
(deterministic tokens inserted directly, no GPU call)
Result: 30-50% fewer GPU forward passes for structured output
vLLM: guided decoding via plugins
vLLM supports constrained decoding through its pluggable architecture, with xGrammar and Outlines as backends. It applies token-level masks that restrict the model's vocabulary at each step. This works, but it runs as an overlay on the standard pipeline and isn't deeply integrated into the scheduling and caching system.
6. Distributed serving & multi-GPU
Both engines support tensor, pipeline, and data parallelism. Where they differ is load balancing and cache-aware routing at scale.
| Strategy | SGLang | vLLM |
|---|---|---|
| Tensor Parallelism | Full support; optimized for high-TP with zero-overhead scheduling | Full support; zero-redundancy memory allocation |
| Data Parallelism | DP attention for DeepSeek models (1.9x decode throughput); sgl-router coordinates | Standard DP; llm-d project for K8s-native scaling |
| Expert Parallelism | Native EP for MoE models; large-scale EP on 96+ H100 GPUs demonstrated | MoE support with expert-level load balancing |
| Pipeline Parallelism | Supported for multi-node deployments | Multi-node scaling via PP across servers |
| Prefill-Decode Disagg. | Native support | Via llm-d project (Red Hat, Google, IBM, NVIDIA) |
| Load Balancing | sgl-router: Rust, predicts cache hit rates (3.8x higher hit rate) | llm-d: K8s Inference Gateway + LMCache |
| Hardware Support | NVIDIA (GB200/H100/A100), AMD (MI355/MI300), Intel Xeon, TPUs, Ascend NPUs | NVIDIA (all from V100+), AMD MI, TPU, AWS Trainium/Inferentia, Intel Gaudi/XPU |
vLLM has the edge on hardware breadth. Its plugin architecture supports more hardware, including AWS Neuron and Intel Gaudi, which matters for organizations committed to non-NVIDIA stacks. SGLang leads on optimization for cutting-edge NVIDIA hardware (GB200, large-scale EP) and has been closing the gap.
7. Performance benchmarks
Read performance comparisons carefully. Results depend heavily on model size, hardware, workload type, batch size, and engine version, and both projects iterate quickly. That said, independent benchmarks from 2025 paint a consistent picture.
Throughput: Llama 3.1 8B on H100 (ShareGPT workload)
Source: AIMultiple Research (1,000 ShareGPT prompts, bfloat16, 0.8 GPU memory utilization)
SGLang ████████████████████████████████████████████████████ 16,215 tok/s LMDeploy ███████████████████████████████████████████████████▉ 16,132 tok/s vLLM* ████████████████████████████████████████ 12,553 tok/s * vLLM with FlashInfer backend (same kernels as SGLang) → 29% gap persists even with identical compute kernels → Difference stems from orchestration overhead, not kernel performance
Key benchmark findings
| Metric | Value | Note |
|---|---|---|
| SGLang throughput advantage | 29% | H100, batch inference, vs vLLM with FlashInfer |
| vLLM time-to-first-token | Best | Fastest TTFT across all concurrency levels in GPT-OSS-120B tests |
| sgl-router cache hit rate | 3.8x | vs round-robin load balancing |
| Stripe's vLLM cost reduction | 73% | 50M daily API calls on 1/3 the GPU fleet |
Where each engine wins
| Metric | SGLang Wins | vLLM Wins |
|---|---|---|
| Batch throughput (tok/s) | Consistently higher by 15-30% on H100 | — |
| Time to First Token (TTFT) | 79ms mean (with cache hits) | Fastest across all concurrency in some benchmarks |
| Inter-Token Latency | Most stable (4-21ms regardless of load) | — |
| High concurrency (100+ req) | — | Highest throughput at 100 concurrent requests (GPT-OSS-120B) |
| Multi-turn conversations | Clear advantage (RadixAttention prefix sharing) | — |
| Structured output (JSON) | Up to 10x faster with xGrammar | — |
| Non-NVIDIA hardware | — | Broader support and testing |
| DeepSeek models | Day-0 support, DP attention (1.9x decode) | Full support with MLA optimizations |
8. Industry adoption survey
Both engines are widely used in production, in different ways. vLLM has the larger install base and broader enterprise footprint. SGLang adoption has grown fast for frontier-model serving and post-training workflows.
SGLang notable adopters
SGLang runs on 400,000+ GPUs worldwide and generates trillions of tokens a day.
| Category | Companies |
|---|---|
| Flagship | xAI (serves Grok 3), Microsoft Azure (DeepSeek R1 on AMD) |
| Cloud Providers | Oracle Cloud, Google Cloud, AWS, Nebius, DataCrunch, Voltage Park |
| AI Companies | Cursor, NVIDIA, AMD, Intel, LinkedIn, Baseten, RunPod, Novita |
| Academia | Stanford, UC Berkeley, UCLA, MIT, U of Washington, Tsinghua |
| RL/Post-Training | De facto backbone for verl, AReaL, Miles, slime, Tunix |
It is funded by a16z's OSS AI Grant and has been part of the PyTorch ecosystem since March 2025.
vLLM notable adopters
vLLM has ~50K+ GitHub stars, the largest OSS inference community, and support for 100+ model architectures.
| Category | Companies |
|---|---|
| Flagship | Meta, Amazon (Rufus), Stripe (73% cost reduction) |
| AI Companies | Mistral AI, Cohere, Anyscale, Roblox |
| Enterprise | IBM / Red Hat (AI Inference Server), NVIDIA, AMD, Intel |
| Cloud Providers | Google Cloud, AWS, Azure |
| K8s Ecosystem | llm-d project (Red Hat, Google Cloud, IBM, NVIDIA, CoreWeave) |
Red Hat acquired Neural Magic and launched a commercial AI Inference Server based on vLLM.
Adoption pattern comparison
| Dimension | SGLang | vLLM |
|---|---|---|
| Primary adopters | Frontier AI labs, GPU cloud providers | Enterprise teams, platform companies |
| Enterprise product | None (community-driven) | Red Hat AI Inference Server |
| Foundation backing | PyTorch ecosystem; LMSYS non-profit | PyTorch Foundation; Red Hat (Neural Magic) |
| Post-training / RL | De facto standard (verl, AReaL, Miles) | Growing adoption |
| Cloud integrations | Available on most GPU clouds | Deeper integrations (SageMaker, RHEL AI, OpenShift AI) |
| Community velocity | 300+ contributors, rapid iteration | 15+ full-time, 20+ orgs, largest community |
9. TL;DR decision guide
Neither engine is universally "better". The right choice depends on your workload, team capabilities, hardware, and priorities.
Choose SGLang when...
- Multi-turn conversations with shared context, such as chatbots, coding assistants, and tutoring systems. RadixAttention shares KV cache across conversational turns automatically, with zero configuration.
- Structured output generation (JSON, XML, SQL). Compressed FSM + jump-forward decoding can skip 30-50% of generation steps, and JSON tasks run up to 10x faster.
- Agentic / tree-of-thought / reasoning workloads. Branching execution paths fit the radix tree cache naturally, and the frontend DSL makes complex LLM programs composable.
- Maximum throughput on NVIDIA H100/GB200. Independent benchmarks consistently show a 15-30% throughput advantage on Hopper-class GPUs.
- RL post-training / rollout generation. SGLang is the de facto backbone for RL frameworks (verl, AReaL, Miles), with native integrations for training workflows.
Choose vLLM when...
- Broad hardware compatibility is critical. If you need AMD, Intel Gaudi, AWS Trainium, TPU, and NVIDIA, vLLM has the widest hardware backend support.
- Enterprise-grade stability & support. Red Hat AI Inference Server is a commercial, hardened distribution, and vLLM has the largest community, the most tutorials, and the most battle-testing in the Fortune 500.
- Drop-in OpenAI API replacement. vLLM's OpenAI-compatible API is the most mature, so migrations have little friction.
- K8s-native distributed deployment. The llm-d project provides production-grade K8s orchestration with disaggregated serving.
- Batch inference with predictable patterns, such as templated prompts, batch content generation, and single-round Q&A. PagedAttention does well when caching patterns are consistent.
Either works well for...
- Standard chat serving, RAG pipelines, general-purpose LLM APIs. Both are production-grade, and the performance differences narrow with each release.
- DeepSeek, Llama, Qwen, Mistral model families. Both have day-0 support for major releases, and both support FP8, INT4, AWQ, and GPTQ quantization.
Quick decision flowchart
START
│
├─ Multi-turn / agentic / structured output heavy?
│ └─ YES → SGLang
│
├─ Need non-NVIDIA hardware (Trainium, Gaudi)?
│ └─ YES → vLLM
│
├─ Need enterprise support / Red Hat ecosystem?
│ └─ YES → vLLM
│
├─ Max throughput on H100/GB200?
│ └─ YES → SGLang
│
├─ RL / post-training rollouts?
│ └─ YES → SGLang
│
├─ K8s-native with disaggregated serving?
│ └─ YES → vLLM (llm-d)
│
└─ Standard chat / RAG / batch?
└─ EITHER — benchmark YOUR workload
Always benchmark your own workload on your own hardware before committing. Both projects release new versions often, with significant performance improvements, so the "best" engine today may not be the best in 3 months. It's worth keeping the ability to switch; both support OpenAI-compatible APIs, which makes migration relatively straightforward.
Research compiled from: official documentation, GitHub repos, academic papers (arXiv:2312.07104, arXiv:2309.06180), LMSYS blog, vLLM blog, independent benchmarks (AIMultiple, Clarifai), PyTorch Foundation announcements, Red Hat engineering blogs, and community reports. All data as of January 2026.