Large Language ModelsInference & Performance Optimization
How do distributed position-independent KV caches coordinate remote reuse, parallel prefill, and cluster-wide resource allocation?
Question 304 of 309 · Updated
On this page
- Why distributed position-independent caching is a systems problem
- 1. Prefix caching and position-independent caching solve different reuse problems
- 2. Why worker-local PIC is insufficient
- 3. Treat a PIC segment as a first-class distributed object
- 4. The cluster view must be timely and truthful
- Optimistic accounting alone
- Worker events alone
- Combine predictions with execution events
- 5. Allocate shared cache capacity using workload feedback
- Ghost entries reveal demand after eviction
- Soft allocation avoids disruptive global eviction
- Worked example
- 6. Schedule remote reuse and parallel prefill using end-to-end completion time
- Numerical example
- 7. Greedy planning and execution
- 8. Correctness, failure handling, and operational safeguards
- Cache identity and isolation
- Stale locations and event loss
- In-flight work and cancellation
- Transfer failures and worker loss
- Cache pollution and unfairness
- Tail latency and stragglers
- Model and backend changes
- 9. How to evaluate a distributed PIC deployment
- 10. What the Nebula paper reports—and what it does not prove
- 11. When is distributed PIC worth the complexity?
- 12. Practical design checklist
- Conclusion
Why distributed position-independent caching is a systems problem#
Large language model (LLM) inference spends substantial time in prefill: the model processes the input context and creates the key-value (KV) tensors that autoregressive decoding will reuse. In retrieval-augmented generation (RAG), a request may combine a stable system prompt, several retrieved documents, conversation history, and a question. An agent may combine its instructions with tool outputs, observations, memory files, and messages from other agents. Many of these segments recur across requests even when their surrounding context or absolute position changes.
Traditional prefix caching (PC) reuses KV state only when tokens match a request's initial prefix. This is valuable for repeated conversation histories and stable system prompts, but it cannot directly reuse a document that appears after a different preceding document. Position-independent caching (PIC) broadens reuse by identifying semantically independent segments that may recur at different positions. Because a segment's original KV state can still encode its previous context and position, PIC methods may need correction or selective recomputation before the reused state is safe to consume.
A single-worker PIC algorithm solves only part of the problem. In a multi-worker serving cluster, a reusable segment may be cached on a different worker from the one assigned to the new request. Meanwhile, other workers may be idle and able to prefill uncached segments in parallel. A router that understands only prefixes cannot exploit those remote PIC hits, and a scheduler that treats the request as one indivisible prompt cannot distribute independent work.
The central systems question is therefore not simply, "Can this segment be reused?" It is: where is its KV state, can it be transferred more cheaply than recomputing it, which worker should compute the misses, where should the request be assembled, and will the cluster's view still be correct when execution finishes?
Nebula, described in the November 2026 paper *Nebula: Distributed Position-Independent Caching for LLM Serving*, is a useful case study. It treats PIC segments as first-class distributed cache objects and coordinates remote reuse, parallel prefill, cache management, and scheduling. The paper reports an average 61.4% reduction in median time-to-first-token (TTFT) against its strongest baseline across four models and four RAG/agent workloads. These are results from the paper's evaluated setup, not a universal production guarantee.
1. Prefix caching and position-independent caching solve different reuse problems#
Consider a request assembled as:
- Stable system instructions: 100 tokens
- Retrieved document A: 600 tokens
- Retrieved document B: 500 tokens
- User question: 40 tokens
A later request may contain the same system instructions and document B, but retrieve document C instead of document A and place B before C. Prefix caching can reuse the stable initial instructions, but the changed content breaks the prefix match. The previously cached representation of document B is not a prefix continuation of the new prompt.
PIC can identify B as a reusable segment independently of its location in the prompt. This is especially useful when documents, tool outputs, or shared agent context recur in different combinations.
The distinction matters:
- Prefix cache key: a matching token prefix and its model execution context.
- PIC segment key: an application-defined, semantically reusable segment, plus the model and execution metadata required to interpret its cached representation.
- Prefix cache hit: KV can be reused directly for the matched prefix.
- PIC hit: cached segment KV is available, but the PIC backend may need to correct or recompute parts of it before final assembly.
PIC is not permission to concatenate arbitrary old KV tensors and assume exact equivalence. Causal attention means token representations can depend on preceding context. PIC methods such as CacheBlend, EPIC, A³, and HYPIC address that correctness issue through their own algorithms. A distributed framework should preserve the backend's correctness contract rather than silently replacing it with a raw byte-copy operation.
The two cache types should complement one another. Stable system instructions and growing conversation prefixes can remain in PC, while retrieved documents, tool outputs, and other independent segments can use PIC. A workload dominated by conversation continuation may need more PC capacity; a retrieval-heavy workload may benefit from more PIC capacity.
2. Why worker-local PIC is insufficient#
Imagine three prefill workers:
- Worker W1 holds the system prefix and a cached copy of document A.
- Worker W2 holds a cached copy of document B.
- Worker W3 has spare compute capacity.
A new request needs the system prefix, A, B, C, and a question. W1 can reuse its local prefix and A. A worker-local PIC implementation may not know how to fetch B from W2, and it may compute C on W1 even though W3 is idle.
A distributed PIC system can instead:
- Reuse A locally on W1.
- Fetch B's cached KV from W2.
- Prefill C on W3.
- Transfer C's newly computed KV to a selected assembly worker.
- Combine the required state and perform the remaining prefill and PIC correction.
Two separate capabilities are involved:
Remote PIC reuse finds a cached segment on another worker and transfers its KV to the worker that needs it.
Parallel prefill assigns independent cache-miss segments to multiple workers so that they can be computed concurrently.
They are complementary, not interchangeable. Remote reuse saves computation but adds network transfer. Parallel prefill can reduce compute queueing but may add transfer traffic and synchronization. A useful planner must decide when either operation is worthwhile.
3. Treat a PIC segment as a first-class distributed object#
A cluster-wide PIC cache needs a segment-level identity and directory. It is not enough to extend a prefix trie and hope that arbitrary segments fit its semantics.
A practical segment record can contain:
- A content or segment hash.
- Model identity and exact model revision.
- Tokenizer identity and relevant tokenization configuration.
- Any required adapter, quantization, positional, and attention-mode metadata.
- The PIC backend or representation version.
- Worker and storage-tier locations.
- Residency state, such as expected, confirmed, evicted, or in-flight.
- Size, creation time, and relevant reuse metadata.
The content hash is useful for locating candidate content, but it is not a complete cache-safety key. Two identical text segments can produce incompatible KV state under different model weights, adapters, tokenizer behavior, positional conventions, or cache representations. The identity and compatibility checks must be defined by the serving implementation and PIC backend.
A distributed cache directory should support operations such as:
- Find compatible segment replicas.
- Select a source based on transfer cost and availability.
- Register a planned or in-flight computation.
- Confirm a successful cache store.
- Remove an evicted or invalid location.
- Track the worker's current outstanding prefill load.
- Recover from worker failure or a lost event.
The segment becomes a common unit for lookup, placement, transfer, eviction feedback, and scheduling. This is the architectural change that makes distributed PIC different from simply enabling a PIC algorithm on every worker.
4. The cluster view must be timely and truthful#
Fine-grained PIC introduces many more independently scheduled units than request-level prefix caching. A single request may contain dozens or hundreds of segments. Cache stores, evictions, and computations complete asynchronously. The router's plan and the workers' actual state can therefore diverge.
Two simple synchronization strategies fail in opposite directions.
Optimistic accounting alone#
The router immediately assumes that a segment will be stored on the worker selected for its computation. This makes the planned location visible to subsequent requests, which can avoid scheduling duplicate work while the first computation is still in flight.
But a planned cache insertion is not the same as a completed cache insertion. The task may fail, be cancelled, run out of memory, or produce a result that is evicted before a later request uses it. If the router continues to treat the expected location as a guaranteed hit, it may route work to a cache entry that is not actually usable.
Worker events alone#
The router waits until a worker reports that a segment is resident before advertising it as a cache hit. This avoids many false-positive locations.
However, while the first computation is still queued or running, a second request may arrive and see no cache entry. It can launch the same segment computation again. Event-only accounting may therefore avoid invalid hits but create substantial duplicate prefill.
Combine predictions with execution events#
Nebula's design combines both approaches:
- When it dispatches a plan, the router immediately records expected segment locations and reserves the assigned compute load.
- Subsequent requests can discover and wait for matching in-flight work rather than launching duplicate prefill.
- Workers emit incremental cache-store events to confirm successful residency.
- Eviction events remove locations that are no longer valid.
- Compute-completion events release the corresponding load reservations.
- Unconfirmed location records receive a time-to-live (TTL), so stale predictions do not remain indefinitely.
The important distinction is between an expected location and a confirmed location. The directory can expose both states while allowing the scheduler to apply different confidence rules.
Load reservations need separate treatment from cache-location predictions. A queued task may still be consuming future capacity even if it has not started executing. A reservation should be released only after the router confirms that the task completed or will not execute. Completion reports should be idempotent: a duplicate event must not release the same reservation twice.
This is a general distributed-systems lesson. The router needs optimistic visibility to avoid duplicate work, but worker feedback to correct its model of reality. Neither source is sufficient by itself.
5. Allocate shared cache capacity using workload feedback#
PC and PIC compete for finite GPU, host-memory, or external cache capacity. They may even store different KV representations of related content because PIC can require a corrected representation. If the cache manager does not coordinate them, one cache type can displace valuable entries belonging to the other.
Two straightforward policies are inadequate in different ways:
- Unified LRU: manages a shared pool by recency. It can let a burst of one cache type crowd out frequently reused content from the other.
- Fixed partition: reserves a fixed percentage for PC and PIC. It prevents one type from consuming everything, but can strand capacity when the workload's reuse pattern changes.
A retrieval workload may repeatedly reuse documents under changing prefixes. An agent workload may repeatedly extend a stable conversation prefix. A mixed workload can change its balance over time. The cache allocation should respond to observed reuse demand rather than assume one static ratio works everywhere.
Ghost entries reveal demand after eviction#
A ghost entry records an identifier for content that was evicted, not the cached KV itself. If that identifier is requested again, the cache manager learns that the evicted content still had reuse value.
Maintain four logical sets or queues:
- : currently resident prefix-cache entries.
- : currently resident PIC entries.
- : identifiers of evicted prefix-cache entries.
- : identifiers of evicted PIC entries.
When an entry is evicted, its identifier moves from a resident set to the corresponding ghost set. When a request revisits an evicted identifier, the ghost hit provides evidence that the cache type may deserve more capacity.
Nebula uses the token counts covered by ghost revisits to update a global target share. Let and be the ghost-revisited token counts for prefix and position-independent caching. Let be the target share for PC, with assigned to PIC:
If more PC tokens are being missed after eviction, the target PC share increases. If more PIC tokens are being missed, it decreases. The update is bounded and applied over request windows, rather than changing the whole cache allocation abruptly for every individual request.
The paper initializes at 0.5 and updates it every 16 requests in its default configuration. The exact window and step size are implementation choices that should be validated against workload churn and feedback noise.
Soft allocation avoids disruptive global eviction#
A target share should not force an immediate cache flush. Nebula broadcasts the target ratio asynchronously and applies it as a soft eviction priority on each worker.
If a worker's PC occupancy is above its target fraction of the combined PC/PIC occupancy, it prioritizes PC eviction when reclaiming space. Otherwise, it prioritizes PIC eviction. Updating the ratio changes the priority for future reclamation; it does not immediately evict a large batch of entries.
For tiered storage, each tier can maintain its own feedback and target allocation. GPU HBM, host memory, and a remote shared pool have different capacities and transfer costs, so a single global ratio may not be suitable for every tier.
Worked example#
Assume a worker has 100 GB of cache occupancy: 70 GB PC and 30 GB PIC. The current target PC share is 50%.
The worker is above its PC target, so when it next needs to reclaim space it prioritizes PC entries. If later ghost feedback indicates that PIC entries are more frequently revisited after eviction, the global target can move toward PIC. The worker then changes its future eviction priority without forcing an immediate 20 GB migration.
The important point is that ghost hits estimate unmet demand. They do not prove that every ghost entry should be retained forever. The policy still needs bounded history, workload windows, and monitoring for oscillation or cache pollution.
6. Schedule remote reuse and parallel prefill using end-to-end completion time#
A distributed request may have some segments cached locally, some cached remotely, and others missing everywhere. It must choose:
- A combine home that assembles the request's KV.
- A source worker for each cached segment.
- A compute worker for each cold segment.
- Whether moving a segment is cheaper than recomputing it.
- How many workers should participate.
Choosing the worker with the most local cache hits can be a poor decision if that worker has a long queue. Choosing the least-loaded worker can also be poor if it must transfer a large amount of KV over a slow network.
The planner should estimate the time until all required KV is available at the combine home, then add the remaining combine-prefill work.
For a candidate plan , Nebula models:
where:
- is the set of workers.
- is the combine home.
- is the outstanding queueing work at worker .
- is the prefill computation assigned to worker .
- is the time to transfer the relevant KV from worker to the combine home.
- is the combine-prefill work, including remaining content and PIC correction.
The maximum captures the fact that combine prefill cannot begin until the slowest required worker has made its KV available. The model normalizes queueing, compute, and transfer into equivalent prefill-token costs using offline profiling.
For a cold segment with tokens, assigning it to another worker can reduce compute queueing but adds a KV transfer term. A cache hit also incurs a transfer term if its source is remote. Therefore, a cache hit is not automatically faster than recomputation.
Numerical example#
Suppose a request has three PIC segments:
- Segment A: 400 tokens, cached on W1.
- Segment B: 600 tokens, cached on W2.
- Segment C: 800 tokens, not cached.
- W1 is the combine home candidate.
- W3 is idle; W2 has a long queue.
- Transferring B from W2 to W1 is relatively expensive.
A locality-only planner may choose W1 because it already has A and can combine locally. A load-only planner may move C to W3 and also fetch B from W2, even if both transfers are expensive. A cost-aware planner compares the full completion-time estimate for candidate placements.
For illustration, assume the measured equivalent costs are:
| Operation | Equivalent prefill-token cost |
|---|---|
| W1 outstanding queue | 300 |
| W2 outstanding queue | 900 |
| W3 outstanding queue | 50 |
| Prefill C on W1 | 800 |
| Prefill C on W3 | 800 |
| Transfer B from W2 to W1 | 500 |
| Transfer C KV from W3 to W1 | 200 |
| Combine prefill | 250 |
Plan A computes C on W1 and fetches B from W2. The estimated readiness costs are approximately 300 + 800 for W1 and 900 + 500 for W2; the maximum is 1,400, plus 250 combine cost: 1,650.
Plan B computes C on W3 and fetches B from W2. W3 contributes 50 + 800 + 200 = 1,050, while W2 contributes 900 + 500 = 1,400. The estimate is again 1,400 + 250 = 1,650. In this simplified example, parallelizing C does not improve the predicted completion time because the remote B transfer and W2 queue remain the bottleneck.
If W2's queue were 200 rather than 900, Plan B would complete at approximately 1,250, including combine work, and would be preferable. Conversely, if the transfer from W3 were much slower, computing C on W1 could win. The best plan depends on the joint state, not one local metric.
These numbers are illustrative, not measurements from Nebula. In a real implementation, the cost model must be calibrated using actual model throughput, segment lengths, network bandwidth, transfer setup overhead, worker queue depth, and PIC correction cost.
7. Greedy planning and execution#
Nebula uses a greedy planning strategy to keep plan generation practical:
- Enumerate candidate combine homes.
- Build an initial plan that assigns cache hits to their source workers and cold segments to the combine home.
- Sort cold segments by descending length.
- Consider moving each cold segment to another worker.
- Estimate the revised completion time.
- Accept a move only if the estimated completion time improves.
- Select the best plan among the candidate combine homes.
This approach is not guaranteed to find a globally optimal assignment for every arbitrary workload. It is a practical heuristic that uses the current cluster view to find a better plan without exhaustively searching every possible placement.
Execution has three broad operation types:
Scatter prefill: workers independently compute cold PIC segments assigned to them.
Cache reuse: cached PC/PIC KV is made available at the combine home. If the source is remote, the KV must be transferred.
Combine prefill: the combine home gathers the required KV, invokes the PIC backend, computes remaining unmarked content, and performs necessary correction or recomputation.
The scatter tasks, remote cache transfers, and control messages can overlap. The combine step waits until all required KV is available. Once prefill completes, the request can follow the ordinary prefill-decode disaggregation path; Nebula's design focuses on prefill and does not require changing the decode path.
8. Correctness, failure handling, and operational safeguards#
A cluster-wide PIC system adds new failure modes beyond ordinary prefix caching. A production deployment should explicitly address them.
Cache identity and isolation#
A content hash alone is not enough. Cache entries must be namespaced by all model and execution attributes that affect KV compatibility. Tenant boundaries, adapter identity, model revision, tokenizer version, positional encoding, attention mode, quantization, and backend-specific representation may matter. A cache lookup should fail closed when compatibility cannot be established.
Stale locations and event loss#
A worker may evict a segment while the router still believes it is resident. Events may be delayed, duplicated, or lost. Use confirmed and expected states, bounded TTLs for unconfirmed predictions, idempotent event processing, and a reconciliation path. A failed remote hit should fall back to recomputation rather than make the request fail.
In-flight work and cancellation#
A planned segment may be queued, executing, cancelled, or complete. The router should distinguish these states and deduplicate identical work where safe. Cancellation must release reservations and prevent late completion events from resurrecting invalid state. Late store events should be accepted only when the corresponding cache object remains valid and compatible.
Transfer failures and worker loss#
Remote KV transfer may fail because of worker restart, network congestion, exhausted memory, or destination-buffer errors. The combine home needs a timeout and recovery path. Depending on the remaining deadline, it can retry from another replica, recompute locally, or select a different worker. Retries should be bounded to avoid turning a transient failure into a traffic amplification event.
Cache pollution and unfairness#
PIC can expose many small or low-value segments to the cache manager. Track byte occupancy and token-weighted reuse, not only raw entry counts. Consider admission thresholds, size-aware eviction, tenant quotas, request priority, and protections for frequently reused prefixes. Ghost feedback should be segmented or weighted carefully if a single tenant or burst can dominate the global statistics.
Tail latency and stragglers#
Parallel prefill is gated by the slowest required segment. A plan with excellent average worker utilization can still have poor P99 TTFT if one worker has a long queue or a large segment. Monitor the distribution of segment completion times, not just total GPU utilization or average prefill throughput.
Model and backend changes#
A model rollout or PIC backend update can invalidate a large fraction of cached objects. Version cache keys and plan a safe transition: drain, namespace, or explicitly invalidate incompatible entries. Do not assume that a segment cached under one backend's KV correction policy is reusable by another.
9. How to evaluate a distributed PIC deployment#
A credible evaluation needs to separate cache effectiveness from end-to-end serving performance.
Track at least:
- TTFT: median, P95, and P99, segmented by workload and prompt length.
- TTFT-constrained goodput: requests per second that meet a stated TTFT SLO.
- Cache hit ratio (CHR): fraction of input tokens served from cache.
- Prefix-miss recovery: fraction of PC-missed tokens that PIC successfully reuses.
- Remote reuse rate: remote cached tokens fetched and successfully consumed.
- Transfer cost: bytes, bandwidth, transfer latency, and failed transfers.
- Duplicate prefill: tokens recomputed while equivalent work was already in flight.
- Invalid hits: expected cache hits for which no usable KV exists.
- Compute balance: per-worker queue depth, prefill tokens, and utilization.
- Cache pressure: PC/PIC occupancy, eviction rates, ghost hits, and tier-level occupancy.
- Correctness: output-quality or model-equivalence checks appropriate to the PIC backend.
Use representative traces. A RAG-only test can overstate PIC value for agent traffic, while an agent-only trace can understate it for workloads with independently retrieved documents. Include prompt lengths, segment counts, arrival bursts, repeated content, and changing reuse distributions.
Compare at least three configurations:
- Prefix caching only.
- Worker-local PIC behind a prefix-aware router.
- Distributed PIC with remote reuse and parallel prefill.
For component attribution, disable one Nebula mechanism at a time: event synchronization, self-tuning cache allocation, remote reuse, or parallel prefill. This reveals whether a measured gain comes from the cache algorithm, cluster coordination, or the scheduler.
Report hardware, model, worker count, network topology, request rates, cache warmup policy, and workload traces. Do not compare TTFT numbers without checking whether output length, decode setup, and request arrival patterns were held constant. Nebula's paper limits requests to one generated token in its primary TTFT-focused experiments while retaining a decode worker, so those results should not be read as a complete characterization of long-output decode throughput.
10. What the Nebula paper reports—and what it does not prove#
The paper implements Nebula on SGLang and NVIDIA Dynamo, and integrates several PIC backends, including CacheBlend, A³, EPIC, and HYPIC. Its evaluation uses four models and four public RAG/agent workloads on a seven-prefill-worker, one-decode-worker configuration.
The authors report:
- An average 61.4% reduction in median TTFT versus Local-PIC + Dynamo.
- An average 76.7% reduction in median TTFT versus SGLang + Dynamo.
- An average recovery of 76.1% of tokens missed by prefix caching.
- Better TTFT-constrained goodput in the reported one-second-SLO example.
- Large reductions in invalid hits and repeated computation when combining optimistic accounting with worker events.
These are paper-reported results under its tested configurations. They do not establish that every PIC backend, model family, network topology, or production workload will see the same gains. The evaluation's worker count, GPU type, network, traces, request rates, and output-length setup all matter.
The work also leaves practical questions for deployment teams: how to set tenant-aware cache policy, how to handle model rollouts and backend compatibility, how to tune the cost model under changing network conditions, how to protect against noisy ghost feedback, and how to choose safe fallback behavior when remote cache transfer is slower than recomputation.
The authors state that source code will be released. Treat implementation availability and compatibility as something to verify against the project's current repository and release state rather than assuming the paper's description guarantees a production-ready package.
11. When is distributed PIC worth the complexity?#
Distributed PIC is most promising when:
- Many requests reuse the same independent documents or tool outputs.
- Reusable segments appear at different positions or under different prefixes.
- The cluster has enough workers for parallel prefill to exploit otherwise idle capacity.
- KV transfer is sufficiently fast relative to recomputation.
- The application can identify segment boundaries reliably.
- The serving stack can enforce cache identity and correctness constraints.
It may be less attractive when prompts are short, content rarely repeats, the network is slow, workers are already saturated, or PIC correction consumes much of the saved prefill compute. A high cache hit ratio is not itself the goal: a remote hit that arrives later than recomputation can worsen TTFT.
The key decision is economic and temporal: reuse a cached segment only when the complete path—lookup, queueing, transfer, correction, and combine—beats the best safe alternative.
12. Practical design checklist#
Before deploying distributed PIC, answer these questions:
- Which application segments are truly independent and safe to mark for PIC?
- What complete compatibility key identifies a reusable KV object?
- Which PIC backend performs correction or selective recomputation?
- Can the router distinguish expected, confirmed, evicted, and in-flight locations?
- Are worker events idempotent, recoverable, and reconciled after loss?
- Are compute reservations released exactly once?
- Can the cache manager learn whether PC or PIC needs more capacity?
- Does each storage tier have its own realistic allocation and transfer model?
- Does the planner compare remote transfer with local recomputation?
- Does it account for the slowest segment, queueing, and combine work?
- Is there a safe fallback when a remote hit fails or becomes stale?
- Are TTFT P99 and SLO goodput measured alongside cache hit ratio?
Conclusion#
Position-independent caching expands reuse beyond identical prompt prefixes, but cluster-wide PIC requires more than a segment hash table or a remote KV store. It needs accurate distributed state, in-flight work accounting, adaptive competition between PC and PIC, and scheduling that weighs compute, queueing, and transfer together.
Nebula demonstrates this systems-level approach: treat PIC segments as distributed objects, combine optimistic router accounting with worker-confirmed events, use ghost-hit feedback to tune cache capacity, and choose scatter/remote-reuse plans with an end-to-end prefill completion model. The broader lesson for LLM serving is that cache efficiency is a property of the whole execution path—not merely whether a matching KV tensor exists somewhere in the cluster.
References
- 1.
- 2.NVIDIA Dynamo: Using HiCachedocs.nvidia.com
- 3.NVIDIA Dynamo: KV-cache-aware routingdocs.nvidia.com
- 4.SGLang: Radix Cache Eviction Policiesgithub.com
- 5.SGLang Router referencegithub.com
Related questions
- How does query-side adaptation enable recomputation-free position-independent KV-cache reuse in LLM serving?
- How does overlap-conditioned cache construction reduce boundary errors in position-independent KV reuse?
- How do hybrid-attention LLMs reuse cached segments when linear layers expose recurrent states instead of token KV?
Explore other topics:Deep LearningRetrieval-Augmented GenerationAI Agents