What is RadixAttention?
RadixAttention is a cache management technique storing the KV cache computed during inference in a radix tree (a prefix tree sharing common prefixes) instead of discarding it after requests finish, then reusing that part without recomputation when a new request starts with the same prefix.
PagedAttention manages the KV cache in blocks to avoid memory waste; RadixAttention tracks which text prefix those blocks belong to in a tree, enabling automatic reuse across requests. It is an automatic, tree-based implementation of prefix caching.
- Topic
- Inference and performance
- Also known as
- Radix tree KV cache
- Origin
- Zheng et al., 2023
How RadixAttention works
- Each request's processed token sequence and KV cache are inserted into the radix tree.
- For a new request, the longest matching prefix is found in the tree and its cache reused directly.
- Prefill runs only for the remaining unmatched tokens.
- When memory fills, least recently used leaves are evicted while frequent shared prefixes are kept.
In more detail
Exact token matching and prompt layout
Prefix matching requires exact token-for-token identity from the start of the prompt. Inserting even a single changing timestamp, request ID or user name at the beginning of the system prompt invalidates the entire prefix cache downstream; therefore, static instructions and shared documents are best placed first, with dynamic per-user variables at the end.
The real effect on prefill and decode
Because KV cache reuse only eliminates the compute-bound prefill phase for matching prefix tokens, RadixAttention primarily improves Time to First Token (TTFT) and reduces prefill GPU load. The memory-bandwidth-bound decode (token-by-token generation) phase for new output tokens is not accelerated by prefix caching.
Cache-aware scheduling and tiered memory
Beyond tree lookup, SGLang schedules queued requests in a cache-aware order, prioritising requests with longer prefix matches in the radix tree rather than strict FIFO, so shared prefixes are processed together before being evicted under memory pressure. Modern implementations also extend radix trees to hierarchical CPU/NVMe offloading and disaggregated prefill-decode clusters.
Zero-copy sharing for branching, multi-turn chat and agent loops
In multi-turn chat, branching tree-of-thought reasoning and agentic tool loops, requests naturally form a tree where every turn or branch extends a shared parent prefix. A radix tree supports zero-copy branching and prefix sharing across concurrent hypotheses or tool-call steps without duplicating parent KV states.
Commonly confused terms
| Term | How it differs |
|---|---|
| Semantic caching | Semantic prompt caching stores final generated text answers for similar questions in an external store, whereas RadixAttention caches internal transformer Key/Value tensors in GPU/host memory to skip prefill computation while still running fresh decoding. |
Why RadixAttention matters for on-premises AI
In enterprise applications many requests start with the same long system prompt, examples or document, while in multi-step agent flows each step carries the previous context. Recomputing these shared parts wastes time to first token and GPU use. The 2023 paper introducing the technique reported up to 6.4 times the throughput of existing inference systems through cache reuse and structured output optimisations. If the cache is shared across users, isolation must be assessed separately.
All requests to an insurer's in-house assistant start with the same long policy text; an inference engine using RadixAttention computes that shared prefix once and reuses it, while the team tracks the change in time to first token.
Common questions
How does RadixAttention differ from PagedAttention?
PagedAttention manages the KV cache in blocks. RadixAttention tracks those blocks in a prefix tree and reuses them automatically for shared prefixes.
Which workloads benefit from RadixAttention?
Many requests sharing the same system prompt, examples or document, plus multi-step agent flows.
Related terms
Sources
- Zheng et al., SGLang: Efficient Execution of Structured Language Model Programs, 2023
- Kwon et al., Efficient Memory Management for Large Language Model Serving with PagedAttention, 2023
In the glossary: Glossary, R to Z