Cross-Datacenter KVCache Transfer: Can Long-Context Prefill Offloading Work?
Prefill-decode disaggregation is common in large-scale LLM inference, but it turns KVCache transfer into a fixed cost. This article examines whether long-context prefill offloading across data centers is practical, covering transfer volume, cross-datacenter constraints, selective offloading, model-side and system-side optimizations, benchmark interpretation, feasibility criteria, and engineering deployment considerations.
1. Background: Why PD Disaggregation Creates KVCache Transfer
LLM inference is usually divided into two stages. The prefill stage processes all input tokens at once, involves a large amount of computation, and is mainly compute-bound. The decode stage generates output tokens one by one, reads historical KVCache at every step, and is mainly bound by memory bandwidth. The resource characteristics of the two stages are opposite. Deploying them on different nodes allows each type of hardware to serve one class of workload, improving overall utilization. This approach is known as PD disaggregation, or prefill-decode disaggregation, and it has become a common design for large-scale inference clusters.
Once the stages are separated, a fixed cost appears: the KVCache generated during prefill must be transferred to the decode node before decode can continue generation. The size of KVCache is proportional to input length. Consider the following hypothetical configuration:
- Layers: 64
- KV heads: 8 with grouped attention
- Head dimension: 128
- Data type: BF16, 2 bytes per element
The KVCache size per token is:
bytes_per_token = 2(K and V) × 64(layers) × 8(KV heads) × 128(head dimension) × 2(bytes)= 262144 bytes = 256 KiB
For an input length of 128K tokens, the total KVCache is approximately 256 KiB × 131072 ≈ 32 GiB, or about 34.4 GB. On a 100 Gbps link, the theoretical lower bound for transfer is about 34.4 GB ÷ 12.5 GB/s ≈ 2.75 seconds, before protocol overhead and queuing delay are included. For interactive workloads, this latency is often already higher than local prefill time, so transfer cost must be evaluated separately.
2. Why the Cross-Datacenter Scenario Is Harder
Within the same data center, prefill and decode nodes usually communicate over a dedicated network with high bandwidth and low latency, making KVCache transfer relatively manageable. Once the two ends span data centers, the situation changes significantly:
- Bandwidth is limited. Available bandwidth on cross-region links is usually much lower than that of intra-datacenter networks, and multiple services share it.
- Latency and jitter increase. Wide-area round-trip latency and jitter directly stretch the tail distribution of TTFT, the time to first token.
- Cost is higher. Cross-region traffic is often billed by volume or constrained by dedicated-line capacity, and sustained high-volume transfer can significantly increase operating cost.
- The failure domain expands. When a link is interrupted or congested, remote prefill results cannot be delivered, so the system must have a clear degradation path.
Therefore, the key question for cross-datacenter deployment is not whether transfer is possible, but whether the volume and frequency of transferred data are controllable under a given bandwidth.
3. Basic Approach to Prefill Offloading
Prefill offloading means running part of the long-input prefill computation on a separate high-compute cluster, then sending the generated KVCache back to the local decode cluster. The difference from ordinary PD disaggregation is that offloading is not applied uniformly to every request; it is handled selectively.
3.1 Selective Offloading
Short inputs have short prefill times and small KVCache, so completing them locally is usually more cost-effective. Long inputs are the opposite: computation grows significantly with length, making them suitable for remote clusters. The scheduler needs to decide based on three factors: input length, remote queue status, and link status. Below is an illustrative routing logic:
def route_request(req, local, remote, link):# All times are in milliseconds; bandwidth is in bytes per secondif req.prompt_len < MIN_OFFLOAD_LEN:return "local"if link.utilization() > HIGH_WATERMARK:return "local" # Fall back to local when the link is congestedkv_bytes = KV_BYTES_PER_TOKEN * req.prompt_lentransfer_ms = kv_bytes / link.available_bps() * 1000local_ms = estimate_prefill_ms(req.prompt_len, local)remote_ms = (estimate_prefill_ms(req.prompt_len, remote)+ remote.queue_delay_ms()+ transfer_ms)# Offload only when the total remote cost is clearly lower, leaving a safety marginif remote_ms < local_ms * (1 - MARGIN):return "remote"return "local"
This code is a design sketch. The thresholds and estimation functions need to be calibrated against actual workloads and stress-test data.
3.2 Data Flow
The complete flow of an offloaded request is as follows:
- The local gateway receives the request and performs routing.
- If offloading is selected, the request is sent to the remote prefill cluster.
- The remote side completes prefill and generates KVCache.
- The KVCache is transferred back to the local decode cluster over the cross-region link.
- Local decode completes the remaining generation and returns the result to the user.
The transfer from step 3 to step 4 is the main risk point in the system, so it needs the optimizations described in the next section.
4. Two Supporting Paths: Model Side and System Side
A single technique is rarely enough to make a cross-datacenter design run reliably. In practice, the model side usually reduces KVCache size, while the system side controls transfer timing and volume. The two need to work together.
4.1 Model Side: Reduce KVCache per Token
Common approaches include:
- Grouped-query attention (GQA) and multi-query attention (MQA): multiple query heads share the same group of KV heads, directly reducing KVCache size.
- Sliding-window attention: only KV within the most recent window is retained. This suits tasks with strong local dependencies but loses long-distance information.
- Hybrid attention architectures: some layers use full attention, while others use linear attention or state-space structures. The state size of these layers has a weaker relationship with sequence length, which can effectively compress the cache footprint of long contexts.
- KV quantization: compress cached values from 16 bits to 8 bits or lower. The tradeoff is precision loss, which needs to be validated with evaluation sets.
The benefit of model-side optimization depends directly on model architecture. It must be determined during training or model selection and cannot be changed arbitrarily at deployment time.
4.2 System Side: Control Transfer Timing and Volume
System-side methods are closer to engineering implementation. Common ones include:
- Layer-wise pipelined transfer: while prefill computes layer N, the KVCache of layer N−1 can already be sent, overlapping part of the transfer time with computation.
- Prefix cache reuse: for repeated system prompts or document prefixes, the remote side only needs to compute and transfer once, after which the result can be reused through hash matching.
- Bandwidth-aware scheduling: dynamically decide which requests to offload based on available link bandwidth and the KV size of each request.
- Transfer compression and chunked retry: apply lossless or lossy compression to KV data, transfer it in chunks, and retransmit only the failed chunk when a single chunk fails.
Below is a simplified example of bandwidth-aware scheduling for selecting offload targets under limited bandwidth:
def select_offload_set(candidates, budget_bps):# candidates is a list of requests to offload; each item includes estimated KV bytes and gain# Sort by gain per unit bandwidth in descending order and greedily select within budgetranked = sorted(candidates,key=lambda r: r.gain_ms / r.kv_bytes,reverse=True,)chosen, used = [], 0for r in ranked:rate = r.kv_bytes * r.expected_qpsif used + rate <= budget_bps:chosen.append(r)used += ratereturn chosen
The greedy strategy does not guarantee a global optimum, but it is simple to implement and suitable for online scheduling.
5. How to Interpret Measured Results Correctly
One report shows that, on an internal 1T-parameter hybrid model, a selective offloading design improved throughput by 54% and reduced P90 TTFT by 64% compared with a homogeneous PD deployment. These two numbers describe the overall effect of the design, but several points need attention when interpreting them:
- Baseline configuration. Whether the node count, parallelism strategy, and scheduling strategy of the homogeneous PD deployment match those of the test group determines the comparability of the improvement.
- Workload distribution. The higher the share of long-context requests in total traffic, the greater the offloading benefit. If traffic is dominated by short requests, the benefit will drop noticeably.
- Network conditions. Whether the bandwidth, latency, and jitter of the cross-region link are close to those of the production environment directly affects whether the conclusion can be extrapolated.
- Metric meaning. Throughput improvement reflects the number of requests completed per unit of resource, while P90 TTFT reflects tail user experience. They may improve together or trade off against each other, so they need to be observed separately.
- Model architecture. The hybrid-architecture model itself has a smaller KVCache, which is one precondition for the design to be feasible. The result cannot be directly applied to full-attention models.
The data in the report comes from a specific model and a specific environment and does not represent a general conclusion for all scenarios.
6. Feasibility Criteria
Before deciding whether to introduce cross-datacenter offloading, the following formula can be used for a rough estimate.
Sustained transfer demand:
required_bps = Σ(kv_bytes_i × qps_i) (summed over all offloaded request types)
Using the hypothetical configuration from earlier, if one request with 128K input is offloaded per second, the sustained bandwidth requirement is about 34.4 GB/s, or about 275 Gbps. This value far exceeds the available capacity of most cross-region dedicated links, indicating that under a full-attention, high-KV-footprint configuration, network upgrades alone are unlikely to support large-scale offloading.
Based on this, feasibility can be judged with the following checklist:
| Criterion | Recommended standard |
|---|---|
| Share of long-context requests | Should be clearly higher than the share of requests above the scheduling threshold; otherwise offloading gains are limited |
| Sustained bandwidth headroom | Required bandwidth should be below a certain proportion of available bandwidth, with burst headroom reserved |
| Link latency and jitter | Total remote time should still meet business requirements within the target TTFT percentile |
| Model KV footprint | Per-token cache size must remain acceptable after model-side optimization |
| Fallback capability | The system must be able to switch back to full local processing within an acceptable time when the link fails |
Only when all conditions are met at the same time is the design suitable for a canary rollout.
7. Engineering Deployment Considerations
7.1 Observability
Metrics that need continuous collection include prefill time per request, transferred bytes and transfer time, link utilization, remote queue time, and local decode wait time. These data points can be connected to general monitoring, alerting, and logging services and bucketed by request length, making it easier to determine whether a problem occurs in computation, queuing, or transfer.
7.2 Degradation and Fault Tolerance
- When link utilization exceeds a threshold, new requests automatically fall back to local prefill.
- When transfer is interrupted, completed chunks are retained and only missing parts are retransmitted. If the retry limit is exceeded, the local side recomputes the request.
- When a remote node is unavailable, the routing layer should remove it promptly to avoid request buildup.
7.3 Version Consistency
Both clusters must run the same model weight version and inference configuration. If the remote side is upgraded while the local side is not, the KVCache data layout or values may be incompatible, causing incorrect output. The release process should bind the versions on both sides and perform consistency checks before going live.
7.4 Security
KVCache contains user input, which is directly relevant to the security design of cross-datacenter offloading.
