Heavy multi-turn chat shares system prompts across requests, pick the serving framework that exploits that best.
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
SGLang's RadixAttention indexes prompt prefixes in a radix tree so deeply branched chats reuse the same KV blocks; vLLM v1 has prefix caching too, but SGLang specifically targets branching agent workloads.
Imagine a thousand people at a library all reading the same first chapter of the same book, then branching to different second chapters. The slow way: every reader gets a fresh copy of chapter 1 photocopied just for them. The fast way: one shared copy of chapter 1 sits on a central table, and everybody reads from it before walking off to their own desk for their unique chapter 2. SGLang builds that shared table for you automatically. It looks at all the conversations coming in, finds the parts they share at the start (the system prompt, the user history), and only does the work once. The other frameworks listed either solve a different problem (faster kernel launches, faster HTTP routing, smarter tokenizers) or invent a feature that does not exist. The winning move is a data structure called a radix tree that organizes the shared prefixes.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
1 min: name the workload's dominant cost (shared prefix prefill). 2 min: explain RadixAttention as a radix tree of token-id prefixes that lets sibling branches reuse KV. 1 min: contrast with vLLM v1 (hash table, single-prefix focused). 1 min: kill the wrong options by naming the wrong axis each addresses (CUDA graphs, dynamic batching, tokenizers).
| Framework | Prefix sharing strategy | Best for | Headline feature |
|---|---|---|---|
| SGLang | RadixAttention (radix tree of prefixes) | Branching agents, A/B prompts, shared system prompts | Sibling-branch KV reuse |
| vLLM v1 | Hash-based prefix cache + PagedAttention | General serving, throughput, broad coverage | Continuous batching + prefix cache |
| TensorRT-LLM | Block-level KV cache with growing prefix support | Low-latency, fixed-shape, NVIDIA-only | CUDA graphs, FP8 / FP4 kernels |
| TGI (HuggingFace) | Has prefix caching (added 2024) | Hugging Face ecosystem deployments | Easy HF Hub integration |
| Triton Inference Server | No native prefix sharing (delegates to runtime) | Multi-model gateway in front of runtimes | Model orchestration, dynamic batching |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Choosing TensorRT-LLM because it sounds the fastest. CUDA graph capture optimizes kernel launch overhead for a single fixed-shape execution; it does not deduplicate KV across two different requests that happen to share a prefix.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.