{"id":18040,"date":"2026-08-23T22:18:23","date_gmt":"2026-08-23T22:18:23","guid":{"rendered":"https:\/\/techtrendfeed.com\/?p=18040"},"modified":"2026-08-23T22:18:24","modified_gmt":"2026-08-23T22:18:24","slug":"kv-cache-administration-pagedattention-radixattention","status":"publish","type":"post","link":"https:\/\/techtrendfeed.com\/?p=18040","title":{"rendered":"KV Cache Administration: PagedAttention &#038; RadixAttention"},"content":{"rendered":"<p> <br \/>\n<\/p>\n<div id=\"article-start\">\n<p class=\"wp-block-paragraph\">Trendy LLMs depend on quantization, pruning, distillation, and sooner consideration kernels, however manufacturing efficiency usually relies upon most on KV cache administration. As context home windows develop, the cache consumes vital GPU reminiscence, limiting concurrency, throughput, and latency. Two breakthroughs remodeled this problem: PagedAttention improves reminiscence allocation, whereas RadixAttention permits environment friendly prefix reuse.<\/p>\n<p class=\"wp-block-paragraph\">Collectively, these methods make LLM serving sooner and extra memory-efficient. On this article, we look at how PagedAttention and RadixAttention work, why they matter, and the way they permit high-performance LLM serving.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-why-the-kv-cache-is-the-real-bottleneck\">Why the KV Cache Is the Actual Bottleneck<\/h2>\n<p class=\"wp-block-paragraph\">Each transformer generates textual content one token at a time. For every new token, the mannequin should attend to all beforehand generated tokens through the use of their key (Ok) and worth (V) vectors. Recomputing these vectors at each step would make technology prohibitively costly, so serving engines retailer them in reminiscence because the KV cache. This cache eliminates redundant computation and makes autoregressive decoding sensible, nevertheless it introduces a brand new problem: reminiscence consumption grows linearly with sequence size. For long-context fashions, the KV cache usually turns into the most important dynamic client of GPU reminiscence, figuring out what number of requests can run concurrently.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-why-memory-becomes-the-limiting-factor\">Why reminiscence turns into the limiting issue<\/h3>\n<p class=\"wp-block-paragraph\">The scale of the KV cache will depend on the mannequin structure and the variety of tokens saved. The per-token reminiscence requirement is:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2026\/08\/image-1-7eqxqe.webp\" alt=\"Formula for calculating memory usage per token\"\/><\/figure>\n<\/div>\n<p class=\"wp-block-paragraph\">The place:<\/p>\n<div style=\"overflow-x:auto;margin:1em 0;\">\n<table style=\"border-collapse:collapse;width:100%;border:1px solid #cccccc;\">\n<thead>\n<tr>\n<th style=\"border:1px solid #cccccc;padding:8px 10px;background-color:#eeeeee;text-align:left;font-weight:bold;vertical-align:top;\"><strong>Image<\/strong><\/th>\n<th style=\"border:1px solid #cccccc;padding:8px 10px;background-color:#eeeeee;text-align:left;font-weight:bold;vertical-align:top;\"><strong>That means<\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">L<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Variety of transformer layers<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Hkv<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Variety of KV heads<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">D<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Head dimension<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">B<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Bytes per worth (2 for FP16)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p class=\"wp-block-paragraph\">For a Llama-3 8B class mannequin with 32 layers, 8 KV heads, 128-dimensional heads, and FP16 precision, every token occupies roughly 128 KiB of KV cache. A 100,000-token context due to this fact requires practically 12.8 GiB of reminiscence earlier than contemplating batching or extra requests.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-the-two-fundamental-problems\">The 2 elementary issues<\/h3>\n<p class=\"wp-block-paragraph\">As GPU reminiscence fills with KV tensors, serving programs encounter two distinct bottlenecks:<\/p>\n<ul class=\"wp-block-list\">\n<li><strong>Reminiscence fragmentation: <\/strong>This happens when the system allocates KV reminiscence inefficiently, leaving giant parts of GPU reminiscence unusable and decreasing the variety of concurrent requests.<\/li>\n<li><strong>Redundant computation: <\/strong>Equivalent immediate prefixes are repeatedly prefetched and encoded, though their KV states have already been computed.<\/li>\n<\/ul>\n<p class=\"wp-block-paragraph\">These issues are unbiased, and every impressed a unique resolution. PagedAttention addresses environment friendly reminiscence allocation, whereas RadixAttention focuses on reusing beforehand computed KV cache throughout requests. Collectively, they outline the muse of recent LLM serving.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-pagedattention-solving-the-memory-allocation-problem\">PagedAttention: Fixing the Reminiscence Allocation Downside<\/h2>\n<p class=\"wp-block-paragraph\">By 2023, the trade recognized the most important inefficiency in LLM serving because the storage technique of the KV cache relatively than consideration itself. The system allotted one giant contiguous block of GPU reminiscence to carry the whole KV cache for each request. For the reason that serving engine couldn&#8217;t predict how lengthy a response could be, it sometimes reserved area near the mannequin\u2019s most context size. Most of that reminiscence remained unused all through the request, drastically decreasing the variety of sequences that may very well be served concurrently.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-the-problem-with-contiguous-allocation\">The issue with contiguous allocation<\/h3>\n<p class=\"wp-block-paragraph\">Conventional allocation creates two types of fragmentation:<\/p>\n<ul class=\"wp-block-list\">\n<li><strong>Inside fragmentation:<\/strong> A request reserves hundreds of token slots however generates solely a small response, leaving many of the allotted reminiscence idle.<\/li>\n<li><strong>Exterior fragmentation: <\/strong>As requests of various lengths end, scattered gaps seem throughout GPU reminiscence. Though the overall free reminiscence could also be ample, it&#8217;s now not out there as one contiguous block for brand new requests.<\/li>\n<\/ul>\n<p class=\"wp-block-paragraph\">The result&#8217;s poor GPU utilization and decrease throughput, even when loads of reminiscence technically stays out there.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-how-pagedattention-works\">How PagedAttention Works<\/h2>\n<p class=\"wp-block-paragraph\">The core concept behind PagedAttention is easy: allocate KV reminiscence solely when it&#8217;s wanted. As a substitute, the system divides the KV cache into fixed-size blocks (sometimes 16 or 32 tokens) relatively than reserving one giant contiguous buffer for a whole sequence. As technology progresses, new blocks are allotted solely after the earlier one turns into full, permitting reminiscence to develop incrementally relatively than being over-provisioned from the beginning.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-step-1-divide-the-kv-cache-into-blocks\">Step 1: Divide the KV cache into blocks<\/h3>\n<p class=\"wp-block-paragraph\">The system splits every sequence into equal-sized logical blocks, whereas the system can retailer the precise blocks wherever in GPU reminiscence.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2026\/08\/image-2-7eqxqe.webp\" alt=\"Logical and physical memory block mapping\"\/><\/figure>\n<\/div>\n<h3 class=\"wp-block-heading\" id=\"h-step-2-use-a-block-table-for-address-translation\"><strong>Step 2: Use a block desk for handle translation<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">Each request maintains a block desk that maps logical block IDs to their bodily areas in GPU reminiscence. Throughout consideration, the kernel consults this desk to collect the required keys and values, making the sequence seem steady though its knowledge is bodily scattered.<\/p>\n<div style=\"overflow-x:auto;margin:1em 0;\">\n<table style=\"border-collapse:collapse;width:100%;border:1px solid #cccccc;\">\n<thead>\n<tr>\n<th style=\"border:1px solid #cccccc;padding:8px 10px;background-color:#eeeeee;text-align:left;font-weight:bold;vertical-align:top;\"><strong>Logical block<\/strong><\/th>\n<th style=\"border:1px solid #cccccc;padding:8px 10px;background-color:#eeeeee;text-align:left;font-weight:bold;vertical-align:top;\"><strong>Bodily GPU block<\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Block 0<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Reminiscence Block 18<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Block 1<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Reminiscence Block 42<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Block 2<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Reminiscence Block 07<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Block 3<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Reminiscence Block 31<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p class=\"wp-block-paragraph\">Actually, this indirection attracts inspiration from web page tables in working programs: the mannequin operates on a logical sequence, whereas the serving engine manages bodily placement.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-step-3-grow-memory-on-demand\"><strong>Step 3: Develop reminiscence on demand<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">As a substitute of allocating area for hundreds of future tokens, PagedAttention expands the KV cache one block at a time.<\/p>\n<p class=\"wp-block-paragraph\">A request producing 60 tokens occupies solely the blocks required for these 60 tokens. No reminiscence is reserved for tokens which will by no means be produced, which dramatically reduces inner fragmentation.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-step-4-share-blocks-with-copy-on-write\"><strong>Step 4: Share blocks with copy-on-write<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">One of the crucial highly effective options of PagedAttention is block sharing. If a number of requests start with the identical immediate, they reference the identical bodily KV blocks as a substitute of storing duplicate tensors.<\/p>\n<p class=\"wp-block-paragraph\">When two requests finally diverge, the system copies the shared block solely on the level of modification, a mechanism often known as copy-on-write. This makes prefix sharing extremely memory-efficient for beam search, parallel sampling, and concurrent requests with an identical system prompts.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-why-this-changed-llm-serving\"><strong>Why this modified LLM serving<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">PagedAttention doesn&#8217;t change the eye algorithm or the mannequin\u2019s outputs. Its innovation is solely architectural: <em>it replaces inefficient contiguous allocation with a paged reminiscence format.<\/em> The result&#8217;s dramatically decrease reminiscence waste, increased GPU utilization, and the power to serve many extra concurrent requests on the identical {hardware}.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-radixattention-solving-the-prefix-reuse-problem\">RadixAttention: Fixing the Prefix Reuse Downside<\/h2>\n<p class=\"wp-block-paragraph\">PagedAttention made GPU reminiscence environment friendly, nevertheless it left one other main inefficiency untouched: the system nonetheless recomputed an identical prefixes for each new request. In actual manufacturing workloads, requests are hardly ever unbiased. 1000&#8217;s of customers share the identical system immediate, chat conversations repeatedly embrace their whole historical past, and agent workflows repeatedly append to an present context. Consequently, the system spends a lot of the costly prefill part producing KV tensors that exist already.<\/p>\n<p class=\"wp-block-paragraph\">The authors launched RadixAttention to eradicate this redundant computation by turning the KV cache right into a searchable, reusable index relatively than a brief reminiscence buffer.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-the-key-idea-store-prefixes-in-a-radix-tree\">The important thing concept: Retailer prefixes in a radix tree<\/h3>\n<p class=\"wp-block-paragraph\">As a substitute of discarding KV tensors when a request finishes, RadixAttention retains them inside a radix tree a compressed trie the place every edge represents a sequence of tokens. The system shops each distinctive immediate prefix as soon as, whereas completely different requests department solely the place their tokens start to vary.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2026\/08\/image-4-7eqxqe.webp\" alt=\"Radix tree structure for prompt prefixes\"\/><\/figure>\n<\/div>\n<p class=\"wp-block-paragraph\">For instance, three requests could start with the identical system immediate:<\/p>\n<pre class=\"wp-block-preformatted\"><strong>System:<\/strong> You're a useful assistant.<br\/><strong>Consumer:<\/strong> What's AI?<br\/><strong>System: <\/strong>You're a useful assistant.<br\/><strong>Consumer:<\/strong> What's Machine Studying?<br\/><strong>System: <\/strong>You're a useful assistant.<br\/><strong>Consumer:<\/strong> What's Deep Studying?<\/pre>\n<p class=\"wp-block-paragraph\">Relatively than storing three an identical copies of the shared prefix, the radix tree retains it as soon as and creates separate branches just for the ultimate consumer question.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-how-prefix-matching-works\">How prefix matching works<\/h3>\n<p class=\"wp-block-paragraph\">When a brand new request arrives, RadixAttention performs three operations:<\/p>\n<ol class=\"wp-block-list\">\n<li><strong>Match:<\/strong> Discover the longest token prefix already current within the radix tree.<\/li>\n<li><strong>Reuse:<\/strong> Load the present KV tensors for that matched prefix as a substitute of recomputing them.<\/li>\n<li><strong>Insert:<\/strong> Compute solely the unequalled suffix and append it again into the tree for future requests.<\/li>\n<\/ol>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2026\/08\/image-5-7eqxqe.webp\" alt=\"Comparison of KV tensor computation with and without caching\"\/><\/figure>\n<\/div>\n<p class=\"wp-block-paragraph\">The longer the shared prefix, the much less work the mannequin performs throughout prefill. This instantly reduces Time to First Token (TTFT), particularly for lengthy conversations and agentic purposes.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-why-it-matters\">Why it issues<\/h3>\n<p class=\"wp-block-paragraph\">In contrast to PagedAttention, which improves reminiscence utilization, RadixAttention improves computational effectivity. It transforms repeated prompts into cache hits, permitting serving engines to skip hundreds of an identical transformer computations. The profit is largest in workloads with secure system prompts, multi-turn chat, RAG pipelines, coding assistants, and agent loops the place contexts evolve incrementally as a substitute of being rewritten from scratch.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-how-radixattention-works\">How RadixAttention Works<\/h2>\n<p class=\"wp-block-paragraph\">In contrast to PagedAttention, which organizes reminiscence, RadixAttention organizes information. Its purpose solutions one query effectively: How a lot of this immediate has the system already computed? To do this, it maintains a world radix tree that indexes token sequences and their corresponding KV cache entries. Each new request both reuses an present prefix or provides solely the lacking suffix.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-step-1-find-the-longest-matching-prefix\">Step 1: Discover the longest matching prefix<\/h3>\n<p class=\"wp-block-paragraph\">When a request arrives, the serving engine traverses the radix tree token by token to search out the longest prefix that already exists. As a substitute of evaluating whole prompts, it merely follows the matching path by the tree.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2026\/08\/image-6-7eqxqe.webp\" alt=\"Process flow for reusing KV cache with RadixAttention\"\/><\/figure>\n<\/div>\n<p class=\"wp-block-paragraph\">If 1,900 tokens of a 2,000-token immediate exist already, the mannequin instantly reuses these KV tensors and computes solely the remaining 100 tokens.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-step-2-compute-only-the-unmatched-suffix\"><strong>Step 2: Compute solely the unequalled suffix<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">Subsequent, as soon as the system identifies the shared prefix, prefill begins precisely the place the match ends. The system hundreds the reusable KV states from cache, whereas solely the brand new tokens move by the transformer.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2026\/08\/image-7-7eqxqe.webp\" alt=\"KV cache reuse for efficient token computation\"\/><\/figure>\n<\/div>\n<p class=\"wp-block-paragraph\">Because of this RadixAttention primarily improves Time to First Token (TTFT) relatively than reminiscence effectivity it eliminates redundant transformer computation.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-step-3-insert-the-new-path-into-the-tree\"><strong>Step 3: Insert the brand new path into the tree<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">Lastly, after prefill (and later throughout technology), the system inserts the newly computed KV tensors again into the radix tree. Future requests can now reuse this longer prefix, permitting the cache to develop organically as actual site visitors arrives.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2026\/08\/image-8-7eqxqe.webp\" alt=\"Radix tree structure for inserting new KV paths\"\/><\/figure>\n<\/div>\n<p class=\"wp-block-paragraph\">Relatively than treating accomplished requests as disposable, RadixAttention turns them into reusable cache entries for subsequent requests.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-step-4-evict-unused-prefixes-intelligently\"><strong>Step 4: Evict unused prefixes intelligently<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">As a result of GPU reminiscence is finite, the system can not retain each cached prefix eternally. RadixAttention makes use of leaf-based eviction, the place the system removes the least not too long ago used branches first whereas it protects shared inside prefixes.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2026\/08\/image-9-7eqxqe.webp\" alt=\"Least Recently Used cache eviction process\"\/><\/figure>\n<\/div>\n<p class=\"wp-block-paragraph\">This technique preserves the prefixes that profit the most important variety of requests and maximizes cache hit charge over time.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-why-this-changed-llm-serving-0\"><strong>Why this modified LLM serving<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">RadixAttention transforms the KV cache from a brief reminiscence construction right into a persistent prefix cache. As a substitute of accelerating consideration itself, it reduces the quantity of consideration the mannequin must compute. For workloads resembling chatbots, coding assistants, RAG programs, and autonomous brokers the place immediate prefixes repeat continuously the result&#8217;s considerably decrease prefill latency and far increased total throughput.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-pagedattention-vs-radixattention-what-s-the-difference\">PagedAttention vs. RadixAttention: What\u2019s the Distinction?<\/h2>\n<p class=\"wp-block-paragraph\">In distinction, builders usually describe PagedAttention and RadixAttention as competing algorithms, however they remedy fully completely different issues. PagedAttention focuses on how the system shops the KV cache in GPU reminiscence, whereas RadixAttention focuses on how the system reuses beforehand computed KV states throughout requests. One is a reminiscence allocation technique; the opposite is a caching technique. In fashionable LLM serving, they&#8217;re complementary and are ceaselessly used collectively.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-a-side-by-side-comparison\"><strong>A side-by-side comparability<\/strong><\/h3>\n<div style=\"overflow-x:auto;margin:1em 0;\">\n<table style=\"border-collapse:collapse;width:100%;border:1px solid #cccccc;\">\n<thead>\n<tr>\n<th style=\"border:1px solid #cccccc;padding:8px 10px;background-color:#eeeeee;text-align:left;font-weight:bold;vertical-align:top;\"><strong>Characteristic<\/strong><\/th>\n<th style=\"border:1px solid #cccccc;padding:8px 10px;background-color:#eeeeee;text-align:left;font-weight:bold;vertical-align:top;\"><strong>PagedAttention<\/strong><\/th>\n<th style=\"border:1px solid #cccccc;padding:8px 10px;background-color:#eeeeee;text-align:left;font-weight:bold;vertical-align:top;\"><strong>RadixAttention<\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Major purpose<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Eradicate reminiscence fragmentation<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Eradicate redundant prefill computation<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Operates on<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">GPU reminiscence format<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Prefix cache<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Core knowledge construction<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Block desk<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Radix tree<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Unit of storage<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Fastened-size KV blocks<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Token sequence prefixes<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Lifetime<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Lively request<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Persists till eviction<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Foremost profit<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Larger batching &amp; GPU utilization<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Decrease TTFT &amp; sooner repeated prompts<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h3 class=\"wp-block-heading\" id=\"h-think-of-them-as-two-different-layers-radixattention-prefix-cache-amp-reuse\"><strong>Consider them as two completely different layers<\/strong>RadixAttention : Prefix cache &amp; reuse<\/h3>\n<p class=\"wp-block-paragraph\">A helpful means to consider the serving stack is as two layers. PagedAttention sits on the reminiscence layer, deciding the place KV blocks dwell inside GPU reminiscence. RadixAttention sits above it, deciding whether or not these KV blocks exist already and could be reused. The radix tree merely factors to KV blocks which can be managed by the paged allocator.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-a-practical-example\"><strong>A sensible instance<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">Think about three customers begin their conversations with the identical system immediate.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2026\/08\/image-10-7eqxqe.webp\" alt=\"Prefix cache aware router for request distribution\"\/><\/figure>\n<\/div>\n<p class=\"wp-block-paragraph\">With out RadixAttention, the serving engine computes the shared prefix three separate instances. With out PagedAttention, every request additionally reserves an outsized contiguous reminiscence area, losing GPU reminiscence. When each methods are mixed, the shared prefix is computed as soon as, saved effectively in paged KV blocks, and reused by each matching request.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-the-key-takeaway\"><strong>The important thing takeaway<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">PagedAttention improves reminiscence effectivity. RadixAttention improves computational effectivity. Collectively, they handle the 2 greatest bottlenecks in LLM inference: storing the KV cache effectively and avoiding pointless recomputation. Trendy serving frameworks resembling vLLM and SGLang more and more mix these concepts to maximise each throughput and latency.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-how-vllm-implements-prefix-caching\"><strong>How vLLM Implements Prefix Caching<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">A standard false impression is that RadixAttention is the one option to obtain prefix caching. In actuality, vLLM additionally helps automated prefix reuse, nevertheless it makes use of a unique knowledge construction. As a substitute of sustaining a radix tree, vLLM identifies KV blocks utilizing chain hashing, permitting an identical prefixes to be reused with out storing them in a tree.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-the-core-idea-every-kv-block-gets-a-unique-hash\"><strong>The core concept: Each KV block will get a novel hash<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">As a immediate is processed, every accomplished KV block receives a hash generated from three items of knowledge:<\/p>\n<ul class=\"wp-block-list\">\n<li>the hash of its dad or mum block<\/li>\n<li>the block\u2019s personal token IDs<\/li>\n<li>optionally available metadata resembling a LoRA ID or multimodal enter hash<\/li>\n<\/ul>\n<p class=\"wp-block-paragraph\">As a result of every block will depend on its dad or mum, the hash uniquely represents the whole prefix resulting in that block. If one other request produces the identical sequence of tokens, it generates precisely the identical chain of hashes and instantly finds the cached KV blocks.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2026\/08\/image-11-7eqxqe.webp\" alt=\"KV cache lookup process with hit or miss outcomes\"\/><\/figure>\n<\/div>\n<h3 class=\"wp-block-heading\" id=\"h-how-cache-lookup-works\"><strong>How cache lookup works<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">When a brand new request arrives, vLLM computes block hashes so as and checks whether or not each already exists within the world cache.<\/p>\n<ul class=\"wp-block-list\">\n<li>Hash match: Reuse the present KV block.<\/li>\n<li>First miss: Allocate new blocks for the remaining suffix.<\/li>\n<li>Technology: Newly accomplished blocks are added again into the cache for future requests.<\/li>\n<\/ul>\n<p class=\"wp-block-paragraph\">This produces the identical sensible conduct as RadixAttention: repeated prefixes skip costly prefill computation and cut back Time to First Token.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-radix-tree-vs-chain-hashing\"><strong>Radix tree vs. Chain hashing<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">Though each programs obtain automated prefix caching, their underlying designs are completely different.<\/p>\n<div style=\"overflow-x:auto;margin:1em 0;\">\n<table style=\"border-collapse:collapse;width:100%;border:1px solid #cccccc;\">\n<thead>\n<tr>\n<th style=\"border:1px solid #cccccc;padding:8px 10px;background-color:#eeeeee;text-align:left;font-weight:bold;vertical-align:top;\"><strong>Characteristic<\/strong><\/th>\n<th style=\"border:1px solid #cccccc;padding:8px 10px;background-color:#eeeeee;text-align:left;font-weight:bold;vertical-align:top;\"><strong>RadixAttention (SGLang)<\/strong><\/th>\n<th style=\"border:1px solid #cccccc;padding:8px 10px;background-color:#eeeeee;text-align:left;font-weight:bold;vertical-align:top;\"><strong>Chain Hashing (vLLM)<\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Knowledge construction<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Radix tree<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Hash desk<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Lookup<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Longest prefix traversal<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Sequential hash matching<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Finest suited to<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Deeply branching workloads<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Excessive-volume shared prefixes<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Prefix caching<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Sure<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Sure<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p class=\"wp-block-paragraph\">For many purposes, the distinction is basically architectural relatively than practical. Each engines mechanically reuse an identical immediate prefixes, making repeated requests considerably extra environment friendly with out altering mannequin outputs.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-security-considerations-can-prefix-caching-leak-data\"><strong>Safety Issues: Can Prefix Caching Leak Knowledge?<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">Prefix caching is designed to enhance efficiency, nevertheless it additionally introduces an essential safety problem. In a multi-tenant LLM service, cached KV blocks could also be shared throughout requests from completely different customers. If an an identical prefix is served noticeably sooner as a result of it already exists within the cache, an attacker might probably infer whether or not that immediate was processed not too long ago. This is called a prefix cache aspect channel.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-how-the-side-channel-works\"><strong>How the aspect channel works<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">Think about two customers interacting with the identical LLM service.<\/p>\n<p class=\"wp-block-paragraph\">If Consumer B repeatedly sends rigorously chosen prompts and observes unusually low Time to First Token (TTFT), they could infer that Consumer A beforehand submitted the identical prefix. The mannequin\u2019s output isn&#8217;t uncovered, however the cache itself turns into a supply of knowledge leakage.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-cache-salting-prevents-cross-tenant-reuse\"><strong>Cache salting prevents cross-tenant reuse<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">Trendy serving frameworks remedy this by introducing cache salting. As a substitute of hashing solely the immediate tokens, the serving engine additionally features a tenant-specific salt when producing cache identifiers.<\/p>\n<p class=\"wp-block-paragraph\">With cache salting:<\/p>\n<ul class=\"wp-block-list\">\n<li>Requests from the identical tenant reuse cached prefixes usually.<\/li>\n<li>Requests from completely different tenants generate completely different cache keys, even an identical prompts.<\/li>\n<li>Cross-tenant cache hits are eradicated, stopping timing-based info leakage.<\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\" id=\"h-why-it-matters-0\"><strong>Why it issues<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">For single-user or self-hosted deployments, prefix caching is primarily a efficiency optimization. In shared cloud infrastructure, nonetheless, it&#8217;s also a safety function that should be configured accurately. Separating cache entries by tenant preserves the latency advantages of prefix caching whereas guaranteeing that one buyer\u2019s requests can not reveal details about one other\u2019s.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-what-came-next-beyond-paged-and-radix-attention\"><strong>What Got here Subsequent: Past Paged and Radix Consideration<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">PagedAttention and RadixAttention solved the 2 elementary issues of KV cache administration environment friendly storage and prefix reuse. Nonetheless, as context home windows expanded to lots of of hundreds of tokens and LLMs started powering long-running brokers, a brand new problem emerged: the KV cache grew to become too giant to suit fully in GPU reminiscence. Trendy serving programs due to this fact developed from managing a single cache into managing a hierarchy of caches throughout GPUs, CPUs, and distributed storage.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-1-hierarchical-kv-caching\"><strong>1. Hierarchical KV Caching<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">As a substitute of treating GPU reminiscence as the one cache, fashionable engines set up KV knowledge into a number of storage tiers. Often accessed prefixes stay in high-bandwidth GPU reminiscence, whereas older or much less energetic prefixes are moved to host RAM or distant storage and fetched again solely when wanted.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2026\/08\/image-12-7eqxqe.webp\" alt=\"Hierarchical storage levels for KV cache blocks\"\/><\/figure>\n<\/div>\n<p class=\"wp-block-paragraph\">This hierarchy behaves very like a processor cache:<\/p>\n<div style=\"overflow-x:auto;margin:1em 0;\">\n<table style=\"border-collapse:collapse;width:100%;border:1px solid #cccccc;\">\n<thead>\n<tr>\n<th style=\"border:1px solid #cccccc;padding:8px 10px;background-color:#eeeeee;text-align:left;font-weight:bold;vertical-align:top;\"><strong>Tier<\/strong><\/th>\n<th style=\"border:1px solid #cccccc;padding:8px 10px;background-color:#eeeeee;text-align:left;font-weight:bold;vertical-align:top;\"><strong>Storage<\/strong><\/th>\n<th style=\"border:1px solid #cccccc;padding:8px 10px;background-color:#eeeeee;text-align:left;font-weight:bold;vertical-align:top;\"><strong>Function<\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">L1<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">GPU HBM<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Lively KV blocks for ongoing requests<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">L2<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Host RAM<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Just lately used prefixes<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">L3<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Distributed storage<\/td>\n<td style=\"border:1px solid #cccccc;padding:8px 10px;vertical-align:top;\">Lengthy-term shared KV cache<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p class=\"wp-block-paragraph\">The serving engine mechanically migrates KV pages between tiers, permitting a lot bigger efficient context home windows with out requiring monumental GPU reminiscence.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-2-cache-aware-routing\"><strong>2. Cache-Conscious Routing<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">Prefix caching is effective provided that associated requests attain the identical serving duplicate. In a distributed deployment, a standard round-robin load balancer could ship consecutive turns of the identical dialog to completely different GPUs, leading to cache misses regardless of an identical prefixes.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2026\/08\/image-13-7eqxqe.webp\" alt=\"Distributed KV cache architecture with request routing and nodes\"\/><\/figure>\n<\/div>\n<p class=\"wp-block-paragraph\">Cache-aware routing solves this by directing incoming requests towards the duplicate that already accommodates the required KV cache. Relatively than balancing solely by load, the router additionally considers cache locality, decreasing prefill latency and enhancing total throughput.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-3-virtual-memory-based-kv-management\"><strong>3. Digital Reminiscence-Primarily based KV Administration<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">One other course of analysis questioned PagedAttention itself. As a substitute of implementing paging contained in the serving framework, newer approaches use CUDA Digital Reminiscence Administration (VMM) to let the GPU present virtual-to-physical handle translation instantly.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2026\/08\/image-14-7eqxqe.webp\" alt=\"Virtual memory mapping of logical KV blocks to physical memory\"\/><\/figure>\n<\/div>\n<p class=\"wp-block-paragraph\">The concept is easy: <em>preserve a contiguous digital KV cache whereas permitting bodily pages to stay scattered beneath<\/em>. This preserves compatibility with present consideration kernels and reduces the engineering overhead of sustaining specialised paged kernels.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2>\n<p class=\"wp-block-paragraph\">PagedAttention and RadixAttention remedy two completely different however equally essential challenges in fashionable LLM serving. PagedAttention maximizes GPU reminiscence effectivity by changing contiguous KV allocation with a paged reminiscence format, whereas RadixAttention reduces latency by reusing beforehand computed immediate prefixes as a substitute of recomputing them. <\/p>\n<p class=\"wp-block-paragraph\">Collectively, they enhance throughput, enhance concurrency, and decrease the price of long-context inference with out altering mannequin outputs. As LLM purposes proceed to scale, environment friendly KV cache administration has grow to be as essential as mannequin structure itself. For builders, well-structured prompts and secure prefixes are actually real efficiency optimizations.<\/p>\n<p class=\"wp-block-paragraph\"><strong>Learn extra:<\/strong> <a rel=\"nofollow\" target=\"_blank\" href=\"https:\/\/www.analyticsvidhya.com\/blog\/2026\/08\/baidu-unlimited-ocr-technical-breakdown\/\" target=\"_blank\" rel=\"noreferrer noopener\">How Baidu Limitless-OCR Works: Fixing Lengthy-Doc Transcription<\/a><\/p>\n<h2 class=\"wp-block-heading\" id=\"h-frequently-asked-questions\">Often Requested Questions<\/h2>\n<div class=\"schema-faq wp-block-yoast-faq-block\">\n<div class=\"schema-faq-section\" id=\"faq-question-1786946618976\"><strong class=\"schema-faq-question\">Q1. Why is the KV cache thought of a bottleneck for LLMs?<\/strong> <\/p>\n<p class=\"schema-faq-answer\">A. It consumes vital GPU reminiscence that scales linearly with sequence size, limiting what number of concurrent requests a system can course of concurrently.<\/p>\n<\/p><\/div>\n<div class=\"schema-faq-section\" id=\"faq-question-1786946619113\"><strong class=\"schema-faq-question\">Q2. How does PagedAttention enhance reminiscence effectivity?<\/strong> <\/p>\n<p class=\"schema-faq-answer\">A. It makes use of non-contiguous reminiscence blocks and a block desk, just like digital reminiscence in working programs, to eradicate inner and exterior fragmentation.<\/p>\n<\/p><\/div>\n<div class=\"schema-faq-section\" id=\"faq-question-1786946619250\"><strong class=\"schema-faq-question\">Q3. What&#8217;s the major good thing about RadixAttention?<\/strong> <\/p>\n<p class=\"schema-faq-answer\">A. It permits environment friendly reuse of beforehand computed KV states for an identical immediate prefixes, stopping redundant calculations throughout completely different requests.<\/p>\n<\/p><\/div><\/div>\n<div class=\"border-top py-3 author-info my-4\">\n<div class=\"author-card d-flex align-items-center\">\n<div class=\"flex-shrink-0 overflow-hidden\">\n                                    <a rel=\"nofollow\" target=\"_blank\" href=\"https:\/\/www.analyticsvidhya.com\/blog\/author\/janvikumari01\/\" class=\"text-decoration-none active-avatar\"><br \/>\n                                                                       <img decoding=\"async\" src=\"https:\/\/av-eks-lekhak.s3.amazonaws.com\/media\/lekhak-profile-images\/converted_image_ToTu2tx.webp\" width=\"48\" height=\"48\" alt=\"Janvi Kumari\" loading=\"lazy\" class=\"rounded-circle\"\/><br \/>\n                                                                <\/a>\n                                <\/div><\/div>\n<p>Hello, I&#8217;m Janvi, a passionate knowledge science fanatic at present working at Analytics Vidhya. My journey into the world of knowledge started with a deep curiosity about how we will extract significant insights from complicated datasets.<\/p>\n<\/p><\/div><\/div>\n<p><h4 class=\"fs-24 text-dark\">Login to proceed studying and luxuriate in expert-curated content material.<\/h4>\n<p>                        <button class=\"btn btn-primary mx-auto d-table\" data-bs-toggle=\"modal\" data-bs-target=\"#loginModal\" id=\"readMoreBtn\">Hold Studying for Free<\/button>\n                    <\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>Trendy LLMs depend on quantization, pruning, distillation, and sooner consideration kernels, however manufacturing efficiency usually relies upon most on KV cache administration. As context home windows develop, the cache consumes vital GPU reminiscence, limiting concurrency, throughput, and latency. Two breakthroughs remodeled this problem: PagedAttention improves reminiscence allocation, whereas RadixAttention permits environment friendly prefix reuse. Collectively, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":18042,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[55],"tags":[6058,1037,10292,10293],"class_list":["post-18040","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-machine-learning","tag-cache","tag-management","tag-pagedattention","tag-radixattention"],"_links":{"self":[{"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/posts\/18040","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=18040"}],"version-history":[{"count":1,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/posts\/18040\/revisions"}],"predecessor-version":[{"id":18041,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/posts\/18040\/revisions\/18041"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/media\/18042"}],"wp:attachment":[{"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=18040"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=18040"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=18040"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}<!-- This website is optimized by Airlift. Learn more: https://airlift.net. Template:. Learn more: https://airlift.net. Template: 69d9690a190636c2e0989534. Config Timestamp: 2026-04-10 21:18:02 UTC, Cached Timestamp: 2026-08-24 00:38:37 UTC -->