TokenCake: A KV-Cache-centric Serving Framework for LLM-based Multi-Agent Applications
Paper · 2025 · Zhuohang Bian, Feiyang Wu, Zhuoran Li et al.
Summary
An agent that asks a tool to search for a file may have nothing to compute until the search returns. Its place in GPU memory can still be substantial. The agent has a key–value cache, or KV cache, containing attention data from the text it has already processed. Keeping that cache in place makes it cheap to continue from the same text, but leaves fewer blocks for agents that are ready to run. Discarding it frees those blocks at the cost of rebuilding the cache later. TokenCake studies this tradeoff in applications where several agents cooperate and call external tools. In these applications, delaying a single agent can also delay all the work that depends on its result. Transformer and attention
TokenCake gives the serving engine information about both kinds of delay. The developer declares which agents and tool stages depend on each other. When an agent begins a tool call, a temporal scheduler estimates how long the cache will sit idle and checks whether a waiting request could use the space. If the window looks worthwhile, it moves the cache to CPU memory and prepares to bring it back before the result arrives. A spatial scheduler assigns part of GPU memory to agent types whose delays are especially consequential. The schedulers use the same view of memory pressure so that freeing blocks for one request and bringing another request’s cache back can be planned together.
The authors evaluate this design on Code-Writer and Deep-Research, using recorded tool responses and matched tool delays across systems. In the tighter GPU-memory setting, TokenCake reduces average application latency by up to 47.06% against vLLM. On the Qwen2.5-14B Code-Writer experiments, the reported gain in GPU KV-cache utilization reaches 16.9 percentage points. At light load, TokenCake and vLLM have comparable latency. Component comparisons help explain the difference under pressure. Prioritizing agents improves performance by itself, while moving caches without application priorities can generate many transfers and leave typical and tail response times close to the baseline.
The design depends on finding a useful interval between moving a cache out and needing it again. In a sensitivity test, some prediction errors let unhelpful migrations pass the scheduler’s checks and made the full system slower than agent-aware scheduling alone. The measurements therefore show both the opportunity and its condition. A cache can be cheap to move relative to rebuilding it, while the decision to move it still depends on who can use the space, how soon the owner needs it back, and which work the application is waiting for.
Deep dive: TokenCake: A KV-Cache-centric Serving Framework for LLM-based Multi-Agent Applications
TokenCake frees GPU memory while agents wait for tools and reserves cache space for work that determines when an application finishes. · about 37 minutes to read
The problem and its context
A tool call pauses inference while the cache stays in memory
The applications in the paper divide a larger task among specialized agents. A coding workflow can assign implementation, review, and testing to different agents. A research workflow can interleave search, navigation, extraction from sources, and report writing. The serving engine sees requests for inference, while the application sees steps in a larger job. An inference request is ready when its own inputs are available. The job is complete when all the steps needed for its final response have finished. That difference matters when the engine has to choose which request gets memory. The paper situates its coding example among software-agent systems such as MetaGPT, ChatDev, and OpenHands.
Within an agent, a tool call divides inference into intervals. The agent processes its context, produces a call, and waits for the external response. Once that response is available, it becomes additional context for the agent’s next inference. The earlier text is still a prefix, meaning that it appears at the beginning of the expanded context in the same order. Its cached attention keys and values are therefore still useful. They can be restored and used to continue processing, with the new tool response appended. The ability to call a tool supplies the pause. The fact that the agent continues from its existing context supplies a reason to preserve the cache. The paper cites Toolformer and ReAct in its discussion of agent interaction with tools.
The paper calls the idle residency of these caches temporal underutilization. At any instant, a block occupied by a stalled agent accounts for memory usage. Until the tool returns, that same block cannot support inference for its owner. If the pool has ample free space, leaving the cache where it is offers a straightforward way to resume. When requests are waiting for blocks, the cost of leaving it there changes. An active request may have to wait, even though part of the pool contains state that no agent can use at that moment. In the paper’s motivation measurements, stalled agents occupied as much as 18.5% of the GPU cache pool at peak moments.
How long this opportunity lasts depends on the tool. The paper combines information about tools available through the Model Context Protocol with its own timing measurements. Its tool table lists a file-system latency of 100 ms and a web-search range of 1–5 s. The reported variability for web search is 1–10 s. Those entries illustrate the range of timescales facing the serving engine. An interval long enough for one cache to make a round trip through host memory may be too short for a larger cache. A tool with a sufficiently long typical call can still return early on an individual invocation. An offload policy needs both an estimate of the wait and a way to respond when the estimate proves wrong.
The dependency graph changes the cost of a delay
The applications are represented as directed acyclic graphs, or DAGs. A node is an agent or another computational step. A directed edge means that a result from one node is needed by another. Acyclic means that following those dependencies cannot take execution back to its starting node. In the coding example, a review depends on the code it will review, so the availability of the reviewer alone is insufficient. When branches join, the next step can be held up by whichever required branch finishes last.
The critical path is the sequence of dependent work whose timing determines when the whole application can finish. The paper’s priority calculations use graph and runtime signals to identify work important to that outcome. A request may matter because it releases several downstream steps. It may also become important because its parallel branch is falling behind and a join is waiting on it. A memory allocator that sees only individual requests can follow arrival order faithfully while delaying the request that controls the application’s completion time.
The authors use critical inversion for a specific failure of memory allocation. A less consequential agent gets cache space first, then pressure on the pool causes a more consequential agent to lose its resident cache. The latter has to rebuild the state before continuing. The added work occurs on a branch whose delay can propagate beyond the request that was preempted. The paper counts such preemptions over time on Code-Writer as motivation for intervening at the point where blocks are allocated. It calls the competition for those blocks spatial contention. As the authors describe it, temporal underutilization concerns when resident state is useful, while spatial contention concerns which work gets to keep or acquire capacity.
The problems can occur together. A pool can contain a cache belonging to an agent blocked on a tool and another cache belonging to an agent making progress on a branch with slack. A request blocking an imminent join can still be queued. A rule for moving the stalled cache can create an opening. A rule for admitting requests determines whether the opening goes to the branch that is holding up the application. A rule for bringing the stalled cache back then has to account for both decisions. This is the case for treating the movement and allocation of blocks as part of scheduling the application.
What earlier serving systems optimized
As the authors describe it, application-aware schedulers already used information that a general inference server might lack. Parrot, Agentix, and Hermes use workflow dependencies in scheduling, helping address cases where work at the front of a queue holds up other requests. Ayo targets the alternation between inference and tools. It can arrange for computation from one stage to overlap a tool stage elsewhere in the workflow. These approaches give the engine more ways to order work. The paper identifies a remaining issue at the allocator. An improved execution order can still encounter a pool whose blocks are already committed, and overlapping computation with a tool call does not automatically vacate the stalled agent’s cache.
Earlier memory systems addressed a different part of the problem. PagedAttention organizes cache storage in blocks to reduce the internal fragmentation that can come with allocating memory for sequences. SGLang reuses shared prefixes at block granularity. Both capabilities make the underlying pool more practical for inference, and prefix reuse can avoid repeated processing when requests begin with the same text. The decision TokenCake adds concerns whether to keep a specific cache on the GPU during a known pause and whether to keep capacity available for requests that affect the workflow’s finish time. PagedAttention and SGLang
The paper also compares ways of moving or preserving caches. CachedAttention responds to inactivity in a session. Mooncake makes use of host or disaggregated memory and can move cache state under pressure or through eviction. InferCept reacts to intercepted external calls and swaps cache state to CPU memory. The distinction from InferCept is particularly specific, since the call already gives InferCept a point at which to act. TokenCake uses that point to forecast a window, looks in the queue for work that can use it, and considers the importance of the state it would move out. CachedAttention
KVFlow is the closest workflow-aware cache manager identified in the paper. Its Agent Step Graph supports prefetching prefixes already on the CPU. The authors distinguish that use of a workflow graph from their use of tool boundaries to create spare capacity during a call and their use of graph priority to reserve GPU blocks. They also discuss systems that lower the cost of restoring state and work that shrinks the input through prompt compression. Reducing the amount of cached state and choosing when that state should occupy a GPU block address different costs. LongLLMLingua and LLMLingua-2
The method, step by step
Give the engine a description of the application
The frontend is how TokenCake learns that inference requests belong to a larger computation. Before inference requests arrive, the application registers a graph containing the agents, the dependencies between them, and nodes for external calls. The authors illustrate the interface with a workflow for retrieval-augmented generation, in which retrieved material becomes input to later generation. Graph structure exposes where a result will be used. Events from a function node expose when the agent that issued a call can next use its cache. An optional time estimate supplies an initial expectation for the length of that wait. Retrieval-augmented generation
A function node can represent an opaque call or describe sequential stages within it. In the staged case, the start and finish of each stage are visible to the scheduler. That allows it to reconsider timing as the call progresses. An opaque call exposes one larger interval, which gives the scheduler less information about where it is in that interval. The interface includes prepared nodes for operations such as file reading, search, and external testing. They supply default times and, where defined, an internal decomposition. A developer can also pass a time estimate through predict_time. The forecasting procedure then has a way to combine that estimate with timings observed during execution.
There are distinct roles for the graph and the cache prefix. A downstream agent may depend on a result produced by the caller. The cache restored by the Temporal Scheduler belongs to the caller’s inference context, which has the tool response appended to it. The downstream agent builds cache state for its own context, with any ordinary prefix-cache hits applied on that path. A dependency edge describes when a result is available to another agent. It does not assign the originating agent’s cache blocks to the recipient.
Use the same block accounting for both schedulers
The schedulers work from a shared snapshot of memory pressure. It records free blocks in GPU and CPU memory, capacity reserved for particular agent types, demand from queued requests, blocks held by stalled requests that could be moved, and pending upload debt. Upload debt represents the space that returning caches still need. Counting that demand allows the scheduler to see the obligations associated with memory freed by an earlier offload. Tracking waiting demand gives it a corresponding view of who could use a new opening.
The order within a scheduling step is fixed. The engine first updates its view of the applications and builds the snapshot. If the time for a reservation adjustment has arrived, the Spatial Scheduler revises its plan. The Temporal Scheduler then handles space for imminent uploads, transfers caches that are ready to return, and evaluates newly stalled requests for offload. The Spatial Scheduler finally decides which waiting requests can enter the next inference batch. A request can use shared blocks, draw on a reservation for its type, or remain queued. Transfer completion still determines when the blocks released by an offload actually become available.
How TokenCake schedules a batch around tool calls
The steps in order.
The coordination is visible in the authors’ Code-Writer example. A programmer calls FileSearch while another programmer is waiting for cache blocks. The search appears long enough to justify transferring the caller’s state out and back. A pending join increases the waiting programmer’s priority, so the batch decision gives that request access to the released space while a lower-priority task waits. As the search nears its predicted finish, the system prepares for the caller’s return. The result extends the caller’s context, allowing inference to continue with the restored prefix. The example ties the offload decision to an actual use of the memory and ties the upload decision to a specific future request.
Estimate the duration of a stall
The Temporal Scheduler receives call_start when an agent issues a call. The event supplies the inference request’s identifier and an initial timing estimate. It changes the status of the request and makes its cache a candidate for offload. At call_finish, the engine receives the request identifier and the duration actually observed. That duration updates a history for the function type. The history follows an exponentially weighted moving average, which incorporates the newest observation while carrying forward the accumulated estimate.
t_history ← α · t_obs + (1 − α) · t_history
t_history to the left of the arrow is the updated duration estimate for the function type. The same name on the right refers to its value before the update. t_obs is the duration just observed, and α is the weight assigned to that observation. 1 − α gives the weight retained by the previous estimate. The arrow denotes assignment, and the multiplication dots and plus sign describe the weighted contributions that are added together.
When the engine has no observed history, it initializes from a developer estimate if one exists. Otherwise, it starts with a conservative system default. When the developer supplies a time estimate, the scheduler also uses a separate weighted combination to make the forecast:
t_estimate = β · t_user + (1 − β) · t_history
t_estimate is the predicted duration. t_user is the estimate supplied by the developer, and t_history is the estimate derived from history. β gives the weight of the user estimate, and 1 − β gives the weight of the historical contribution. The equality defines the prediction as the sum of the two weighted times. In the evaluation configuration, the history update weight and the weight of the user estimate are both 0.5. They control different operations. One governs how observed calls change the history. The other governs how much that history contributes when a developer estimate is present.
This is an online timing procedure. TokenCake acquires new timing observations when calls finish. The paper describes no training stage for the serving policy. Workload traces collected for the experiments supply the tool responses and timing distributions used during evaluation. The history maintained by the scheduler serves a different purpose. It helps the engine decide what to do with a currently stalled request using observations from earlier calls of its type.
Price the transfer and identify work that fits
An offload involves moving GPU cache blocks into CPU memory. Resuming from that copy involves moving the state back. The paper calibrates the cost of each direction from measured per-block transfer times on the platform where the engine runs. The total cost used in the decision is the sum of the two transfers for the cache under consideration.
T_transfer = T_offload(N_blocks) + T_upload(N_blocks)
T_transfer is the estimated round-trip time. N_blocks is the number of cache blocks in the request being evaluated. T_offload gives the estimated GPU-to-CPU transfer time for that many blocks. T_upload gives the estimate for the return to the GPU. Each function is evaluated at N_blocks, and the plus sign adds the costs. In TokenCake’s setting, the authors treat the transfer time as linear in the block count. Measuring both directions lets the scheduler budget for preserving and restoring the same state.
The next calculation asks how much of the predicted wait remains available after paying for the round trip.
T_window = T_FC − T_transfer
T_window is the time available for other work under the estimate. T_FC is the predicted duration of the function call, and T_transfer is the estimated round trip. The minus sign deducts that round trip from the predicted stall. The basic algorithm rejects the offload if the window is zero or negative. A positive result gives the scheduler a candidate interval in which a request might make productive use of the released blocks.
The scheduler estimates how much work its inference engine can do in that interval.
N_capacity = T_window × v_throughput
N_capacity is the estimated token budget for the window. T_window is the available time, and v_throughput is the observed decode throughput, expressed in tokens per unit of time. The multiplication sign converts the interval into an estimate of how many tokens can be processed at that rate. This budget complements the block check. A queued request has to fit in the cache space made available, and its total work has to fit within the estimated token budget. A request that fits one resource can still exceed the other.
The default queue search is first_fit. It considers waiting requests in queue order and stops at the first eligible request whose memory requirement and work fit the opening. If the search fails, the scheduler keeps the stalled cache on the GPU. Finding an eligible request justifies considering the move. The implementation also checks CPU capacity and the minimum GPU pressure for offloading. The evaluation configuration sets that minimum GPU usage to 0.60. The combination ties migration to demand on both sides of the copy. The GPU space needs a plausible user, and the CPU pool needs room to hold the state.
Decide whether the candidate is worth moving
The paper first describes hard rejections, then a benefit score for candidates that pass them. The hard checks look for sufficient CPU capacity, a useful stall after transfer costs, a fitting waiting request, and enough GPU pressure. This order saves a scoring decision for the cases in which an offload could plausibly help. The later score can account for conditions that come in degrees, such as how well a request fits the opening or how much margin remains for a safe upload.
The score rewards pressure on the GPU pool, fit with waiting work, available host capacity, and room in the timetable for the upload. Offloading a critical request carries a penalty based on the Spatial Scheduler’s importance signal. The score also discourages moving requests that are close to finishing and requests that have already undergone frequent migrations. The authors describe the length of the stall relative to transfer time as the dominant favorable term and criticality as the dominant penalty. They give 1.0 as the default benefit-score threshold. Under severe pressure, the policy can make an exception for an important agent if the expected stall leaves a large margin.
The decision has to account for reentry as well as departure. A move may free enough blocks for a queued request right now, yet make the returning agent wait for a destination. The upload safety terms and shared pressure accounting are ways to account for that future demand. They also explain why importance affects both schedulers. An agent whose delay will hold up the workflow is a less attractive source of temporary blocks and a more urgent candidate once its CPU-resident cache needs to return.
Bring the cache back without taking space too early
If a cache has moved to CPU memory, the scheduler can start preparing its return as the predicted completion time approaches. Preparing early gives it a chance to overlap transfer with the tool call. Reserving the full destination very early would shorten the interval during which other work can use the freed memory. The paper handles this through the ordering of upload candidates and the pacing of destination reservations.
P_upload = I + U
P_upload is the ranking score for an upload candidate. I is normalized request importance from the Spatial Scheduler, and U is urgency derived from closeness to the expected completion of the call. The plus sign combines both contributions. The ranking therefore takes account of an early return deadline and the consequence of delaying the request after that deadline.
The engine calculates how many free GPU blocks can be used for uploads while protecting current demand from critical waiting requests.
B_upload = max(0, B_gpu_free − max(0, D_critical − B_shared_free))
B_upload is the budget for uploads in the current scheduling step. B_gpu_free counts free GPU blocks, D_critical is aggregate block demand from critical waiting requests, and B_shared_free counts free blocks in the shared pool. max returns the larger of its arguments. The inner maximum gives the part of critical demand left uncovered by free shared blocks, with 0 as its floor. The subtraction leaves that many blocks out of the upload budget. The outer maximum floors the result at 0. The equation gives the Temporal Scheduler a budget that reflects a claim the Spatial Scheduler may need to honor in the same step.
The next rule limits how many destination blocks a candidate can reserve in one scheduling step.
B_reserve = min(B_remain, ⌈B_deficit ÷ 2⌉, B_upload)
B_reserve is the number of blocks reserved in the step. B_remain is the candidate’s remaining block requirement considered by the allocator, B_deficit is the deficit in blocks for that candidate, and B_upload is the available upload budget. min returns the smallest of its arguments. The division by 2 and the ceiling brackets give half the deficit rounded upward to a whole block. Together the terms bound the reservation by the candidate’s remaining need, the pacing rule, and the budget that can be spent in the current step.
The tool’s finish event closes the loop. If the cache is already on the GPU, the agent can resume with the returned result. If the result arrives ahead of its forecast and its cache is still on the CPU, the event triggers an immediate upload. The state has to return before inference can use it, so a forecast error can put transfer time on the request’s path to completion. The observed duration then enters the history used for later calls.
Decide who can allocate GPU memory
The Spatial Scheduler divides the pool into shared blocks and blocks reserved for designated agent types. Any agent can compete for the shared portion. Eligibility for the reserved portion depends on a score for the agent’s type. The scheduler reviews the partition periodically. The amount it tries to keep reserved depends on overall block pressure, and the division of that amount among eligible types depends on their priority and memory use.
Before forming each batch, the scheduler refreshes a request-level priority. The paper describes three contributions to that ranking.
P_req = α_struct · f_struct + α_sync · f_sync + α_aging · f_aging
P_req is the priority for an individual request. f_struct measures structural importance, f_sync captures synchronization pressure, and f_aging captures changes in priority as execution and waiting progress. The corresponding α_struct, α_sync, and α_aging are their weights. Each multiplication dot applies the weight to a feature, and the plus signs combine those weighted values. These coefficients belong to the request ranking. The unqualified α in the forecast belongs to the tool-duration update.
Structural importance reflects a node’s location and connections in the graph. Its depth describes where it is in the dependency structure. Its incoming and outgoing degrees count dependencies entering and leaving it. Those signals help estimate how much other work can be released by moving the request forward. Synchronization pressure accounts for the progress of parallel branches. If a merge is waiting for a branch that is falling behind, the lagging branch gains priority. Aging considers time in the queue, the remaining fraction of the graph, and pressure to finish an application already near completion. The evaluation uses bounded aging, including a cap of 60 seconds on the application start-offset term. The implementation also uses graph features measuring similarity and parallelism based on counts of same-type nodes at the same depth.
Reservation is a decision about an agent type across active requests. The score for that decision uses structural role, runtime demand signals, and the cost of losing cache state.
S_a = max(1, w₁ · P_a + w₂ · U_a + w₃ · H_a + w₄ · G_a)
a identifies an agent type, and S_a is its reservation score. P_a is static structural priority, U_a is runtime urgency, H_a reflects recomputation cost, and G_a describes the graph positions of the type’s active requests. w₁, w₂, w₃, and w₄ are the weights for those terms in order. The dots apply the weights, and addition combines the results. max floors the score at 1. The default weights are reported as 2:1:0.5:1.
The paper gives the type score a way to respond when members of the same type have different experiences. A structurally important instance can provide a reason to protect the class. The urgency term uses waiting and preemption counts, weighting preemption more heavily because a preemption directly signals the loss of resident cache space. The default preemption coefficient is 1.5. The recomputation term uses logarithmically compressed information about typical token count, execution time, and throughput. The graph-context term considers average depth and connectivity among active requests of the type. Together these signals allow pressure on a type to affect its reservation even when the graph itself has stayed the same.
Adjust the reservation and apply it to the batch
The reservation update begins with measured GPU usage.
usage = CurrentGpuUsage() ÷ N
usage is the fraction of GPU cache blocks in use. CurrentGpuUsage() gives the occupied block count, and N gives the total GPU block count in the update. The division expresses occupancy relative to capacity. The update compares that fraction with a high and a low watermark. At the high end, it increases the reserved fraction. At the low end, it decreases the fraction, returning capacity to the shared pool. Between the watermarks, the size need not change in that update.
The stated starting reserve fraction is 0.05, the update changes it by 0.05, and the allowed range is [0.05, 0.30]. In the default configuration, 0.75 is the high usage watermark and 0.40 the low one. Once the total reservation has been decided, the scheduler uses the type scores to select the top fraction of active types. The critical-agent ratio is 0.75. The usage watermark and the selection ratio happen to share a value in the configuration, but one compares block occupancy with capacity and the other determines eligibility among agent types.
The allocation algorithm expresses each eligible type’s share as a combination of its usage and its score.
share_a = (1 ÷ 2) · (GpuUsage(a) ÷ N + S_a ÷ Σ(a′ ∈ C) S_a′)
share_a is the share calculated for type a. GpuUsage(a) is the number of GPU blocks it is using, and N is the total GPU block count. S_a is its type score. C is the set selected for critical reservations, a′ ranges over the types in that set, and Σ adds their scores. The membership symbol ∈ specifies which types enter that sum. The two divisions express the type’s current usage relative to total blocks and its priority relative to the selected types’ combined priority. The plus sign adds those contributions and the 1 ÷ 2 factor weights them equally.
reserved[a] = share_a × ρ × N
reserved[a] is the capacity assigned to type a in the update. share_a is the share from the preceding calculation, ρ is the adjusted reserve fraction, and N is the total GPU block count. The multiplications apply the type’s share to the configured reservation capacity. The footprint term directs more space towards types already using more blocks. The relative score gives protection to a high-priority type even if its present footprint is small.
After the reservation is available, the batch decision applies the request scores and memory eligibility together. A high-ranking request can proceed only if the blocks it needs are available to it. Work eligible for reserved capacity gets a route into the batch that lower-ranked work outside the designated types cannot exhaust. At lighter load, reducing the reserve restores more opportunity to the shared pool. The adjustment loop therefore changes how much capacity is protected as well as which types qualify for that protection.
Track each transfer until the blocks are safe to reuse
The engine extends vLLM’s chat completion interface with graph registration and uses an asynchronous manager to handle the tool events. It records whether a request is running, pending offload, offloaded, pending upload, or uploaded. This lifecycle distinguishes a decision to move a cache from the completion of the move. On an offload, the GPU blocks become pending-free when an asynchronous copy is issued. They can only return to the free pool after the copy finishes, since they are still the source of data while it is in flight.
The CPU side uses a pool of reusable, fixed-size blocks. A free list recycles them without repeatedly releasing and reallocating memory through the operating system. The paper reports that this changes worst-case host allocation from nearly a second to consistent sub-millisecond times. The pool also tracks mappings between CPU blocks, GPU blocks, and block hashes. When state becomes CPU-resident, its hash enters a CPU prefix-cache index. A matching lookup can save recomputation, while still creating a host-to-device transfer that has to finish before the request runs. On upload the engine restores the GPU mapping and can reuse the original GPU block when it is available.
For tensor-parallel execution, GPU reservations remain local to each device and admission has to succeed on every participating device. The pressure snapshot includes free blocks, reserves, and pending uploads for the individual GPUs. This extends the same policy to a request whose inference spans multiple GPUs. The paper describes TokenCake as a Python implementation that reuses parts of vLLM, and reports releasing the TokenCake code publicly.
Experiments and results
Workloads, hardware, and comparison systems
The main evaluation uses Code-Writer and Deep-Research to expose different reasons why memory can affect completion time. Code-Writer has 11 agent types and repeatedly calls tools for operations such as file I/O, search, and testing. The concurrent requests and stalled caches put pressure on the block pool. Deep-Research uses fewer agents and longer dependency chains. There, delays can propagate through a sequence of steps, making application completion sensitive to where the delay occurs. Both workloads exercise external calls, while their graph structures give the scheduler different kinds of work to prioritize.
The authors synthesize user requests from ShareGPT and AgentCode. They drive application arrivals according to a Poisson process at different rates, expressed in queries per second, or QPS. They first run the applications against live tool endpoints and record outputs and timing distributions. In the measured comparisons, a server returns the recorded outputs and samples delays using a fixed seed. Changing the serving system therefore leaves the replayed tool behavior and stall times matched, preserving a source of variability that the policy needs to handle while controlling it across implementations.
The principal configurations pair Qwen2.5-14B with an NVIDIA A100 with 80 GB HBM, Qwen2.5-32B with an NVIDIA H20 with 96 GB HBM, and Qwen2.5-72B with NVIDIA H20 GPUs at tensor-parallel degree 2. The configurations allocate 100 GB of CPU memory for offload. The larger tensor-parallel run makes the engine coordinate reservations across devices while handling the same types of tool events and application dependencies. The authors use a fixed default policy configuration across workloads, with separate changes in the experiments designed to test sensitivity.
The standard vLLM baseline is v0.8.6. A separate vLLM-Prefix configuration enables prefix caching to test how much sharing common prompt beginnings can help. Mooncake v0.3.0-beta represents remote cache storage, and Parrot represents application-aware scheduling on its own engine. In the focused Mooncake comparison, the paper uses the vLLM V1 store connector with kv_both semantics. That comparison deliberately restricts the GPU budget. The main end-to-end discussion gives a default setting of 0.8 and separately reports results at gpu_mem_utilization=0.5. This setting controls how much memory is available to the engine. The utilization reported as an outcome concerns occupancy of the resulting cache pool.
The main latency measure starts when an application is submitted and ends when its final response arrives. The mean shows the response time averaged across applications, while tail percentiles show what happens toward the slower end of the distribution. A P90 or P95 result gives the corresponding percentile of response times. Throughput is reported in completed requests per second in the experiments that include it. The cache utilization measure follows occupied GPU KV blocks over time. The paper interprets it alongside the changes in admission and latency, since an occupied block can belong to an agent that is waiting on a tool.
End-to-end latency as load increases
The main latency plots compare the serving systems across different Qwen configurations, both applications, and workloads labeled D1 and D2. At the low rate of 0.05 QPS, the authors report comparable latency for TokenCake and vLLM. There is little competition for blocks in that regime, so moving a dormant cache would frequently create space without advancing another request. At higher arrival rates, the vLLM and vLLM-Prefix curves rise more steeply. In the authors’ interpretation, the pool fills with state from both active and stalled agents, restricting the batches the engine can form. Prefix reuse can reduce duplicated prompt work while leaving the problem of a resident cache during a tool stall in place.
TokenCake has the lowest reported average latency across the configurations in the main plots. One result that exercises its coordination across devices is Code-Writer D2 at 1.0 QPS with Qwen2.5-72B. TokenCake reduces latency there by 20.7% relative to vLLM. Under the tighter memory budget of gpu_mem_utilization=0.5, the paper reports an average latency reduction of up to 47.06% against vLLM. This maximum describes the benefit under memory constraint. The low-load comparison shows how differently the policy can behave when free capacity is already available.
The cache utilization measurements give another view of what happens as pressure rises. On Qwen2.5-14B Code-Writer, TokenCake reports utilization across tested loads of 85.7–87.0%, against 69.9–74.1% for vLLM. The paper gives the largest improvement as 16.9 percentage points. Its explanation is that TokenCake can use more of its pool to support requests ready for computation, while vLLM can have idle resident state preventing further admissions. A higher occupied fraction alongside lower latency is consistent with more work entering the engine. The occupancy percentage by itself cannot reveal the state of every request using those blocks.
The paper gives a separate comparison for Code-Writer D2 at 1.0 QPS with Qwen2.5-32B. In that setting the GPU cache utilization is 53.5% for vLLM and 79.6% for TokenCake. This comparison fixes the application, workload label, Qwen configuration, and arrival rate, so the two percentages refer to the same reported operating point.
GPU KV-cache utilization on Qwen2.5-32B Code-Writer D2 at 1.0 QPS
TokenCake records higher cache-block utilization at the same arrival rate.
The numbers
| System or setting | KV-cache utilization % |
|---|---|
| vLLM | 53.5 |
| TokenCake (this paper) | 79.6 |
Remote cache storage under pressure
The focused Mooncake experiment uses Qwen2.5-7B and a Code-Writer workload of five applications. The tight GPU budget makes this a direct test of whether a remote cache system can solve enough of the problem by itself. At 0.2 QPS, the standard baseline has an average latency of 697 s, Mooncake reaches 524 s, and TokenCake reaches 499 s. The paper reports a 24.8% improvement for Mooncake over the baseline and a further 4.8% improvement for TokenCake over Mooncake. Throughput for Mooncake is 0.0086 req/s, compared with the baseline’s 0.0069 req/s at that load. Remote cache reuse consequently gives a substantial benefit in its own right.
At 0.5 QPS, the average latency comparison moves to 533 s for Mooncake and 384 s for TokenCake. The authors report that TokenCake reduces latency by 28.0% against Mooncake and by 37.0% against the standard baseline. TokenCake reaches 0.0124 req/s while Mooncake reaches 0.0090 req/s, a reported throughput gain of 37.8%. The difference between systems is larger at this load, where the authors identify stronger memory contention. The experiment also includes a configuration that offloads without agent awareness. Its average latency is 577 s at 0.2 QPS and 552 s at 0.5 QPS. At both arrival rates it takes longer than Mooncake, even though the full TokenCake policy is faster.
Average latency on Qwen2.5-7B Code-Writer at 0.5 QPS in the Mooncake comparison
TokenCake completes the workload faster than remote caching or offload without agent awareness.
The numbers
| System or setting | seconds |
|---|---|
| Offload only | 552 |
| Mooncake | 533 |
| TokenCake (this paper) | 384 |
The comparison shows why it matters to name the offload policy when interpreting the result. Remote storage brings a cache-preservation benefit even without the full workflow information. TokenCake additionally uses the tool call to decide whether an idle interval is valuable and uses application priority when deciding who gets the GPU blocks. The performance of Offload only indicates that simply adding another destination for cache state can lead to an outcome quite different from the coordinated policy.
Application-aware scheduling on a separate engine
The Parrot comparison uses D2 on both applications at 0.1, 0.2, and 1.0 QPS. On Code-Writer, Parrot’s mean application latency ranges from 14.3k s to 18.6k s, while TokenCake’s means span 2.0–2.1k s. The paper describes the gap as 7.1–9.0×. On Deep-Research, the reported Parrot means are 3.5–4.2k s and the TokenCake means are 496–646 s, with a reported gap of 6.5–7.0×. The magnitude leads the authors to plot Parrot separately from the primary load curves, where including it would make differences among the other systems harder to see.
The authors interpret these results in light of the memory-allocation problem. Parrot can use dependencies to schedule work, while its execution engine can still face contention from caches of different importance. The comparison measures complete systems on their respective engines. The observed latency gaps therefore combine the effects of cache management and any other differences in the runtimes. The matched component comparisons within the TokenCake implementation provide a more specific test of the contribution of the schedulers.
What the ablations show
How much each scheduler contributes
The component study compares vLLM, spatial scheduling alone, temporal offload without agent awareness, and the full system. The spatial configuration can change priority and reserve memory while leaving stalled caches on the GPU. The offload configuration can move those caches but lacks the application-aware priorities that guide migration and admission in the complete design. The comparison asks both whether the components help individually and whether combining them changes the way cache movement is used.
For Code-Writer with Qwen2.5-14B, 20 applications, 1.0 QPS, and a GPU memory setting of 0.5, the reported total latency is 502.2 s on baseline vLLM. Agent-aware scheduling alone brings it to 424.8 s, a reported reduction of 15.4%. Offload alone brings total latency to 403.1 s. Full TokenCake gives 344.6 s. The total latency metric in this comparison captures a different view of the workload from the average and P90 of application latency. The paper reports all three to show how the configuration affects the overall run and the response times experienced by individual applications.
Total latency on Qwen2.5-14B Code-Writer at 1.0 QPS with constrained GPU memory
The configuration combining agent-aware scheduling and offload records the lowest total latency.
The numbers
| System or setting | seconds |
|---|---|
| vLLM baseline | 502.2 |
| Spatial Scheduler only | 424.8 |
| Temporal offload only | 403.1 |
| TokenCake (this paper) | 344.6 |
The averages and tail results reveal a cost masked by looking only at total latency. Offload alone records mean and P90 latencies of 392.4 s and 397.1 s, which the authors describe as close to the baseline. It also generates 11,339 offloads. Full TokenCake records a mean of 313.7 s and a P90 of 328.3 s, with a reported reduction in swap volume of 51% against offload alone. In this run, the engine that spends less effort migrating state also delivers better application response times. The authors attribute this to directing offloads toward stalled agents of lower importance and giving consequential work better access to the released capacity.
The study also compares the components at 0.2 and 0.5 QPS, using Qwen2.5-14B Code-Writer, 20 applications, and the memory setting of 0.5. At 0.2 QPS, full TokenCake reduces mean latency from 496.9 s to 394.2 s, a reported gain of 20.7%. At 0.5 QPS, mean latency falls from 508.2 s to 406.8 s, a reported reduction of 19.9%, and throughput improves by 26.6%. At both rates the agent-only mode outperforms offload alone, and the complete system produces the lowest average latency and highest throughput of the compared modes. This ordering is specific to these load points and metrics. It can coexist with the lower total latency of offload alone relative to agent-only scheduling in the 1.0 QPS run.
What happens when call times are hard to predict
The sensitivity study uses Qwen2.5-14B on an A100 PCIe platform with a GPU memory setting of 0.5. The authors vary the tool durations by applying multiplicative noise to the timing used in the experiment.
[t · (1 − s), t · (1 + s)]
The brackets give the interval from which actual execution time is drawn. t is the reference call duration and s is the noise scale. The minus and plus signs place the bounds below and above t by changing its multiplier. The multiplication dots apply the respective multipliers to the duration. This setup lets the authors vary how far actual tool times can depart from the reference while measuring the effect on the decision to move state and the timing of its return.
With zero noise, full TokenCake lowers latency by 14.8% against agent-only scheduling. At noise scale 0.25 it becomes slower by 8.3%. The authors explain that some calls still appear to pass the feasibility check, even though the resulting migration and upload timing prove harmful. At noise scale 0.5, the full system again improves latency, this time by 3.4%. The paper attributes the recovery to the stronger rejection of migrations when the estimated windows fail the gate’s checks. These outcomes establish a non-monotonic response in this experiment. They put particular attention on marginal candidates that still look plausible enough to accept.
This matters because a missed offload and a mistimed offload have different consequences. Rejecting a candidate leaves a cache where it is and forgoes a potential opening. Accepting it commits transfer work and creates a subsequent need for destination blocks. If the tool returns too soon, part of the upload may occur on the path to resuming inference. The timing experiment illustrates how an error can be consequential even when a function call offers some real time away from inference. The authors suggest that applications with especially variable tool times should supply wider confidence intervals so that the decision can account for a larger safety margin.
Which waiting request should justify an offload
The authors compare three ways to choose a waiting request that can make use of freed capacity. best_fit favors the request whose demand is closest to the memory being freed. priority_first favors the request with the highest priority. first_fit uses the first eligible match in the existing order. The decision matters at the interface between the two schedulers. A selector that looks sensible from the perspective of a single memory opening can produce different queues and completion patterns from a selector that preserves the ordering of the batch scheduler.
In this comparison best_fit has the highest mean latency, at 187.0 s. The paper attributes the outcome to disruptions of the ordering already determined by the Spatial Scheduler. priority_first gives the lowest mean, at 150.6 s, but has a P95 of 173.2 s. The authors report that this policy skips small requests that would otherwise finish quickly. first_fit reaches a mean of 152.6 s and a P95 of 164.7 s. It also achieves the highest throughput at 0.058 req/s. The choice of first_fit as the default reflects the balance across the mean, tail, and throughput measures in this test. A selection based solely on the mean would favor priority_first in the same comparison.
How selective the pressure gate needs to be
The pressure-threshold sweep changes when a memory opening is considered valuable enough to attempt. At the tested watermarks of 0.05 and 0.06, the authors observe frequent offloads and latencies of about 157 s. At 0.08, no candidates are accepted in that load setting and latency reaches 107.5 s, a reported reduction of 32%. The paper’s explanation is that the available work at that load did not justify the cache moves the more permissive group performed. The result supports making offload conditional even on a machine where the option is available and the scheduler can forecast returns.
These values belong to the sensitivity sweep. The default configuration is reported separately. The paper also observes that on hardware such as H100, the tested configurations can differ less because the gate rejects most offload candidates in that hardware regime. It treats platform behavior as a reason to validate the choice of thresholds on the target system. The threshold experiment measures the combined effect of admission opportunities, workload pressure, and transfer conditions. It does not furnish a single best pressure value for the rest of the evaluation.
What moving a cache costs compared with rebuilding it
The microbenchmark measures CPU migration and recomputation on the A100 PCIe platform with Qwen2.5-14B. The tested contexts range from 1,024 to 5,120 tokens. The paper describes this as 64 to 320 blocks, with 16 tokens/block and 3 MiB/block for bfloat16 cache data. Recording context size alongside timing matters because a larger cache puts more bytes on the transfer path and more context on the recomputation path.
At 4,096 tokens, corresponding to 256 blocks in the test, moving state out takes 32.0 ms and bringing it back takes 31.7 ms. The measured round trip is 63.7 ms. Recomputing the context takes 1,815 ms, which the paper reports as 28.5× slower than migration. Across the tested sizes, the reported recomputation-to-migration gap ranges from 26.8–37.5×. The round trips themselves range from 15.8 to 79.8 ms. The measurements establish that the CPU copy can be much cheaper than losing the prefix and rebuilding it on that platform.
Keeping the cache resident is also a choice available to the scheduler, and it incurs neither a round trip nor a rebuild. The value of an offload in that case is the useful computation made possible by releasing the blocks. Many unnecessary migrations can consume bandwidth and create contention for destination blocks even when each individual transfer looks inexpensive against recomputation. This connects the microbenchmark to the component study. The transfer measurements give a reason to preserve cache state on the CPU when the GPU space can be put to work. The ablations show why a policy also needs to decide whose state to move, at what time, and for whose benefit.
Limitations
Limits the authors identify
TokenCake depends on application information supplied by the developer. The graph and tool types have to be declared, and the engine needs the events surrounding external calls to see the idle intervals it can use. An unannotated call can be treated as an opaque stage with a fallback estimate, but its internal progress is unavailable for timing the upload. The deployment effort thus depends on how much structure the application already exposes. A structured workflow with named tools gives the scheduler a different quality of information from a call whose only visible boundaries are its start and finish.
The evaluation uses static graphs for reproducibility. The implementation can activate a branch at runtime if that branch was declared in advance, and skipped branches never enter the scheduler. Runtime scores then reflect the branches that are running, and the reservation update can change which agent types are designated critical. The authors expect structural signals to remain meaningful when a type keeps a stable prompt, role, and cache footprint within an application. For applications with widely varying graph structure, they discuss probabilistic demand modeling in the style of Hermes as a possible way to improve reservation decisions. They report no evaluation of that extension.
The hardware evaluation stays within one node and reaches two GPUs in a tensor-parallel configuration. That run demonstrates coordinated admission across the participating devices. Cross-node execution and coordination across larger GPU pools are left for future work. The authors also discuss the possibility of using a neighboring GPU connected through NVLink as another destination for a stalled cache. The evaluated offload mechanism uses CPU memory, so the performance of a tiered GPU and CPU hierarchy remains an open question in the paper.
The authors explicitly limit what can be inferred from the Parrot experiment. Since it runs on Parrot’s own engine, they treat it as a comparison of end-to-end systems. A common-engine test would be needed to attribute a measured difference specifically to KV-cache policy. The scale of the reported gap does not remove this qualification. The engine-matched component study offers evidence about how the schedulers contribute inside TokenCake, while the Parrot figures describe what happened when the full systems were run side by side.
Limits of the evidence in these experiments
The workload methodology gives a reproducible comparison by matching tool outputs and sampled durations. It is less informative about feedback between a live tool service and the serving engine. In a deployment where different scheduling decisions send calls at different times, the tool’s own queue, the arrival of results, and the engine’s memory pressure could affect one another. Recorded outputs and seeded delays hold part of that environment fixed. The controlled noise experiment adds evidence about prediction error, but varies it through a specific timing perturbation on a particular hardware setting.
The tested graphs represent two applications with different shapes. Code-Writer puts many concurrent cache states into play, and Deep-Research puts more emphasis on dependency chains. The paper uses a fixed configuration across them, which shows that the measured effects did not depend on a separate reported parameter search for each application. The size and sign of gains on workflows with different mixes of tool calls, contexts, and branching remain uncertain. The loss against agent-only scheduling at noise scale 0.25 is an example of a regime where adding temporal offload can hurt even within the paper’s own tests.
The GPU experiments and the transfer microbenchmark answer related questions at different scales. The multi-device run shows a latency benefit with tensor-parallel admission on the tested hardware. The individual transfer measurements characterize the relative cost of migration and recomputation for measured context sizes on A100 PCIe. Those timing ratios cannot be directly assigned to another interconnect, another host-memory configuration, or an engine handling a different mix of concurrent transfers. The common 100 GB host-memory allocation is also part of the setup. A deployment with a smaller CPU pool could reject more candidates on host capacity alone.
Finally, GPU cache occupancy and useful inference are distinct observables. The paper measures occupied blocks and interprets the improvement using its latency results and the known mechanism for releasing stalled state. An occupancy figure by itself gives no direct breakdown of work performed, time spent waiting at joins, or the residency of idle state throughout a run. Likewise, the 47.06% headline latency reduction is a measured maximum for the constrained setting, while the low-load comparisons show much closer performance. The most specific account of what TokenCake achieves comes from reading the workload, pressure setting, and metric together.
What came after
No subsequent citing work is identified. The follow-on directions the authors describe are to coordinate reservations over larger device pools, consider a neighboring GPU as an additional cache destination, and forecast demand when declared branches are activated dynamically. Each extends a different part of TokenCake’s design. The paper presents them as future work.
Cite
Cite as Zhuohang Bian, Feiyang Wu, Zhuoran Li, Teng Ma and Youwei Zhuo. 2025. TokenCake: A KV-Cache-centric Serving Framework for LLM-based Multi-Agent Applications. arXiv:2510.18586.
@misc{bian2025tokencake,
title = {{TokenCake: A KV-Cache-centric Serving Framework for LLM-based Multi-Agent Applications}},
author = {Zhuohang Bian, Feiyang Wu, Zhuoran Li, Teng Ma and Youwei Zhuo},
year = {2025},
doi = {10.48550/arxiv.2510.18586},
eprint = {2510.18586},
archivePrefix = {arXiv},
url = {https://doi.org/10.48550/arxiv.2510.18586}
}This page in Markdown https://md.research.elamur.ai/free/en/papers/bian-2025-tokencake-kv-cache-centric-serving/