Zenaique

Heavy multi-turn chat shares system prompts across requests, pick the serving framework that exploits that best.

MCQ·Medium·4.0 · 0·~1 min·Asked atFiddler AiQdrantWorkday·Relevant atNVIDIASglang
Attempt it
TL;DR

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.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

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.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Pick a serving framework for the wrong reason and you pay it in latency tax every minute the service is up. The right way to pick is to ask: what is the dominant cost in the workload, and which framework has a first-class data structure for that cost?

For heavy multi-turn chat with shared system prompts, the dominant cost is prefill of the shared prefix. Every new turn from every user re-prefills the same 1k to 4k token system prompt unless something stops it. That something is prefix caching, and the framework that turned it into a first-class structure is SGLang, via RadixAttention.

The wrong options each describe a real optimization that targets a different cost. Sorting which optimization targets which cost is the substance of this question.

The cost shape of multi-turn chat

A typical chat request consists of three phases:

  1. Tokenize the input prompt (negligible, microseconds).
  2. Prefill: process the entire input prompt through the model to produce the KV cache. This is compute-bound and scales linearly with prompt length.
  3. Decode: generate output tokens one at a time. This is bandwidth-bound (each step reads all weights from HBM) and scales linearly with output length.

For a 3k-token system prompt + 200-token user message generating a 300-token reply on Llama-3-70B (FP8) on one H100, the rough split is: prefill ~200 ms, decode ~6 seconds. Decode dominates wall-clock time, but prefill dominates the controllable tax, because most of it is repeated work across users.

If every request prefills the same 3k system prompt fresh, and you serve 100 RPS, you are spending 100 * 200 ms = 20 GPU-seconds per wall-clock second just on the shared prefix. That is a brutal amount of compute to throw away. Prefix caching is the move that recovers it.

What RadixAttention actually does
Why the three wrong options each describe a different cost
vLLM v1 as the strong runner-up
How to pick under interview pressure
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.
FrameworkPrefix sharing strategyBest forHeadline feature
SGLangRadixAttention (radix tree of prefixes)Branching agents, A/B prompts, shared system promptsSibling-branch KV reuse
vLLM v1Hash-based prefix cache + PagedAttentionGeneral serving, throughput, broad coverageContinuous batching + prefix cache
TensorRT-LLMBlock-level KV cache with growing prefix supportLow-latency, fixed-shape, NVIDIA-onlyCUDA graphs, FP8 / FP4 kernels
TGI (HuggingFace)Has prefix caching (added 2024)Hugging Face ecosystem deploymentsEasy HF Hub integration
Triton Inference ServerNo native prefix sharing (delegates to runtime)Multi-model gateway in front of runtimesModel orchestration, dynamic batching

Real products, models, and research that use this idea.

  • ChatGPT-style assistants with a long system prompt see 50%+ of their prefill cost in the system prompt; prefix caching turns that into a one-time cost amortized across all users.
  • Agent frameworks (LangChain, AutoGen, custom multi-agent systems) generate many sibling branches off a planning prompt; SGLang's radix tree was designed for this branching shape.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow would you estimate the cache hit rate for a production assistant before switching frameworks?
A

Log the token-id prefix of every incoming request for a day; group by prefix; compute coverage curves. If 80% of requests share a single 3k-token prefix, you have a strong case for RadixAttention. If every request is unique, prefix caching buys nothing and the framework choice swings to other axes (continuous batching, kernel performance).

3 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

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.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • Describe the cost structure of multi-turn chat workloads.

  • Explain why prefill dominates latency for long shared prefixes.

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
What is the KV cache in transformer inference?
Flashcard·Easy