Skip to main content
← CONCEPTS / AI-MACHINE-LEARNING
An end-to-end domain learning journey

Prefix Caching
& RadixAttention.

Index shared prompt KV-cache blocks in a reference-counted Radix Trie for zero-copy reuse across LLM requests.
Start the journey7 sections· Last modified Nov 22, 2026
FIRST PRINCIPLES. PRODUCTION SCALE.
The idea to keep with you

To keep serving pipelines predictable under bursty prompts, sharing system-prompt KV blocks cuts prefill FLOPs by 85% and TTFT by 21x.

TL;DR30-second simplified summary
▾

In production LLM serving, 85% to 95% of prompt tokens are shared system instructions and tool schemas. RadixAttention stores 16-token KV pages in a Radix Trie so matching prefixes are reused in O(L/B) time without recomputing attention. Reference counting pins active shared blocks while leaf-first LRU eviction safely reclaims idle memory.

Before you begin · Building blocksAlready know these? Jump to Stage 01 ↓
Disaggregated LLM Serving (Prefill vs. Decode Pools)
Disaggregated LLM serving separates prompt prefill (compute-bound TTFT) and autoregressive token decode (HBM-bandwidth-bound ITL) onto independent GPU pools, transferring computed KV-cache blocks over RDMA or NVLink without stalling in-flight decode batches.
Full walkthrough · 7 stages
01
foundation

Stage 1: Core Mental Model.

Why this matters: Establish core mental model invariants for Prefix Caching & RadixAttention.

Think of Stage 1: Core Mental Model as the intuition layer for Prefix Caching & RadixAttention: Establish core mental model invariants for Prefix Caching & RadixAttention.

Stage 1: Core Mental Model establishes how Prefix Caching & RadixAttention behaves under real production load.

Design Trade-Off

Stage 1: Core Mental Model

Before · Static Batch + Raw Prompt
  • Head-of-line blocking on long prompts
  • O(N^2) KV fragmentation
  • Unfiltered RAG leaks ACLs
After · PagedAttention + Guardrails
  • Zero-waste paged KV blocks
  • Pre-retrieval ACL & RRF rerank
  • Continuous batching boosts tok/s
02
foundation

Stage 2: Production Failure Mode.

Why this matters: Establish production failure mode invariants for Prefix Caching & RadixAttention.

Think of Stage 2: Production Failure Mode as the intuition layer for Prefix Caching & RadixAttention: Establish production failure mode invariants for Prefix Caching & RadixAttention.

Stage 2: Production Failure Mode establishes how Prefix Caching & RadixAttention behaves under real production load.

Component Topology

Stage 2: Production Failure Mode

Caller / AgentingressLLM GatewaycomputeRadix / VectorstorageGPU Poolcontrolpromptprefix / RAGbatched decode
Engineering Decision Framework
Problem
How to implement Prefix Caching & RadixAttention without hitting unbounded tail latency, state divergence, or operational fragility.
Naive Solution
Use a single unpartitioned path with unbounded retries and synchronous global coordination.
Why It Fails
Global coordination serializes throughput under load, while unbounded retries amplify transient stalls into full outages.
Alternatives
Compare synchronous strict-consistency paths against bounded asynchronous replication, local caching, or partitioned ownership.
Engineering Decision
To keep serving pipelines predictable under bursty prompts, sharing system-prompt KV blocks cuts prefill FLOPs by 85% and TTFT by 21x.
Trade-Offs
Gains predictable p99 latency and fault isolation in exchange for explicit bounding, observability, and slightly higher implementation complexity.
Decision Exercise · Make the Call

When Prefix Caching & RadixAttention experiences a sudden 5x traffic spike alongside a slow downstream dependency, which engineering choice best protects system stability?

03
intermediate

Stage 3: Naive Baseline & Bottleneck.

Why this matters: Establish naive baseline & bottleneck invariants for Prefix Caching & RadixAttention.

Think of Stage 3: Naive Baseline & Bottleneck as the intuition layer for Prefix Caching & RadixAttention: Establish naive baseline & bottleneck invariants for Prefix Caching & RadixAttention.

Stage 3: Naive Baseline & Bottleneck establishes how Prefix Caching & RadixAttention behaves under real production load.

Lifecycle & Failure Recovery

Stage 3: Naive Baseline & Bottleneck

KV blocks allocatedtoken sampledVRAM > 90%Prefill(Compute-Bound)Decode (Memory-BW)SSE StreamingKV Cache Pressure
04
intermediate

Stage 4: Hardened Architecture.

Why this matters: Establish hardened architecture invariants for Prefix Caching & RadixAttention.

Think of Stage 4: Hardened Architecture as the intuition layer for Prefix Caching & RadixAttention: Establish hardened architecture invariants for Prefix Caching & RadixAttention.

Stage 4: Hardened Architecture establishes how Prefix Caching & RadixAttention behaves under real production load.

05
intermediate

Stage 5: Reference Implementation & Rollback.

Why this matters: Establish reference implementation & rollback invariants for Prefix Caching & RadixAttention.

Think of Stage 5: Reference Implementation & Rollback as the intuition layer for Prefix Caching & RadixAttention: Establish reference implementation & rollback invariants for Prefix Caching & RadixAttention.

Stage 5: Reference Implementation & Rollback establishes how Prefix Caching & RadixAttention behaves under real production load.

06
advanced

Stage 6: Complexity & Capacity Bounds.

Why this matters: Establish complexity & capacity bounds invariants for Prefix Caching & RadixAttention.

Think of Stage 6: Complexity & Capacity Bounds as the intuition layer for Prefix Caching & RadixAttention: Establish complexity & capacity bounds invariants for Prefix Caching & RadixAttention.

Stage 6: Complexity & Capacity Bounds establishes how Prefix Caching & RadixAttention behaves under real production load.

07
advanced

Stage 7: Operational Runbook & Telemetry.

Why this matters: Establish operational runbook & telemetry invariants for Prefix Caching & RadixAttention.

Think of Stage 7: Operational Runbook & Telemetry as the intuition layer for Prefix Caching & RadixAttention: Establish operational runbook & telemetry invariants for Prefix Caching & RadixAttention.

Stage 7: Operational Runbook & Telemetry establishes how Prefix Caching & RadixAttention behaves under real production load.

Request & State Flow

Stage 7: Operational Runbook & Telemetry

User / AgentModel RouterVector / PrefixCacheGPU InferenceWorker1. Submit prompt + ACL context2. Fetch KV prefix / hybrid RAGchunks3. Prefill & continuous-batcheddecode4. Stream tokens via SSE +guardrails
Practice · Explain the consequences

Practice: Make the trade-off yourself.

Question 1 of 3
Score: 0/3

What primary invariant prevents failure in Prefix Caching & RadixAttention (Check 1)?

Recommended Learning Flow