Transferring KVCache Across Data Centers: How Model Design and Scheduling Work Together

    Prefill-Decode disaggregated inference breaks down when KVCache must travel across data centers over ordinary Ethernet. This article walks through a bandwidth estimation for cross-data-center KVCache transfer, explains how hybrid attention architectures such as MLA, GQA, SWA, and linear attention can shrink KVCache traffic by several times, and shows how Prefill-as-a-Service with bandwidth-aware scheduling and a transfer closed loop (validation, retry, and fallback) makes selective offloading practical. Includes illustrative pseudocode for the routing and transfer logic.

    Bandwidth Is the First Barrier to Cross-Data-Center Disaggregation

    In large model inference, it has become common to deploy Prefill and Decode separately. Prefill processes the entire input and is compute-heavy, while Decode generates tokens one at a time and depends more on memory bandwidth. Configuring dedicated hardware for each workload improves resource utilization.

    After disaggregation, however, the KVCache produced by Prefill must be delivered completely to the Decode nodes. This requires sufficiently wide links between the two node types. The conventional approach is to co-locate them within the same data center on RDMA high-speed networks. Ordinary Ethernet links spanning data centers usually cannot carry this traffic, which limits elastic scaling.

    An Illustrative Bandwidth Estimation

    KV throughput (Φkv) is the amount of KVCache data Prefill produces per unit of time. The numbers below are illustrative values based on assumptions, not measured results. Assume a model with 80 layers, 8 KV heads per layer, a head dimension of 128, BF16 storage (2 bytes per element), an input length of 32K tokens, and a Prefill time of roughly 1.4 seconds.

    The KVCache per token is approximately 2 × 80 × 8 × 128 × 2 bytes, or about 320KB. For 32K tokens, that totals roughly 10.7GB. Dividing by 1.4 seconds yields a throughput of about 60 Gbps. Common single-link Ethernet across data centers runs at 10 Gbps or 25 Gbps—far below this figure.

    How Hybrid Attention Shrinks KVCache

    Hybrid attention reduces KVCache mainly along two directions.

    The first category includes attention variants that compress the KV representation, such as Multi-head Latent Attention (MLA) and Grouped Query Attention (GQA). MLA uses low-rank compression to reduce the Key and Value size each layer must store. GQA lets multiple query heads share KV heads. Both directly shrink the per-layer cache footprint.

    The second category includes linear or sparse attention layers, such as Sliding Window Attention (SWA) and Delta-style linear attention. These layers restrict computation to a local window or a recurrent state, so cache size no longer grows linearly with input length. SWA keeps a fixed-length window cache, while linear layers maintain a fixed-size state.

    The two types of layers can be stacked in a hybrid arrangement. Common configurations pair linear layers with full attention layers at ratios of 3:1, 5:1, or 7:1. Only full attention layers have caches that grow linearly with length. At a 3:1 ratio, the number of length-dependent cache layers drops to roughly a quarter of the original; at 7:1, to roughly an eighth. Reusing the example above, 60 Gbps falls to about 15 Gbps or 7.5 Gbps. Layering compression techniques such as MLA on top can push the number down further. This estimate ignores the fixed state overhead of linear layers; actual values should be verified through measurement.

    Prefill-as-a-Service: Selective Offloading

    The idea behind Prefill-as-a-Service (PrfaaS) is to offload long-context Prefill to a remote, compute-rich cluster. The resulting KVCache is sent back over Ethernet to the local PD cluster, which completes Decode locally.

    Not every request is worth offloading. The scheduler can compare the total time of two paths. The local path costs the local queue wait plus local Prefill time. The remote path costs the sum of remote queue wait, remote Prefill time, KVCache transfer time, and round-trip latency. Offloading makes sense only when the remote path is clearly faster.

    A length threshold (such as 16K or 32K) can serve as an initial value, but it should be tuned based on measured Prefill-time and transfer-time curves rather than copied directly. Prefill for short requests is already fast, so transfer overhead dominates, and keeping them local is usually more cost-effective.

    Bandwidth Awareness and the Transfer Closed Loop

    Bandwidth-aware scheduling requires real-time monitoring of available bandwidth and RTT (round-trip time) on the cross-data-center link. When link utilization approaches a threshold, the scheduler should reduce the concurrency of remote Prefill and use a token bucket to limit the KVCache send rate, preventing congestion on ordinary Ethernet.

    The following pseudocode shows the complete path from routing decisions to return-path validation, retry, and fallback.

    ```python

    Illustrative code: bandwidth-aware selective offloading with a transfer closed loop

    import time

    LONG_CONTEXT_THRESHOLD = 32_768
    MIN_REQUIRED_BANDWIDTH_GBPS = 8.0
    REMOTE_TIMEOUT_S = 10.0
    MAX_RETRY = 2

    def estimate_remote_cost(request, network_monitor, remote_cluster):
    bw = network_monitor.get_cross_dc_bandwidth_gbps()
    rtt_ms = network_monitor.get_cross_dc_rtt_ms()
    transfer_s = request.estimated_kv_bytes 8 / (bw 1e9)
    return (remote_cluster.queue_wait_s()

    1. + request.estimated_prefill_s
    2. + transfer_s
    3. + rtt_ms / 1000)

    def route_request(request, local_cluster, remote_cluster, network_monitor):
    bw = network_monitor.get_cross_dc_bandwidth_gbps()

    1. # For short requests or insufficient link bandwidth, execute the full pipeline locally
    2. if request.input_len <= LONG_CONTEXT_THRESHOLD or bw < MIN_REQUIRED_BANDWIDTH_GBPS:
    3. return local_cluster.execute_full_pipeline(request)
    4. local_cost = local_cluster.queue_wait_s() + request.estimated_prefill_s
    5. if estimate_remote_cost(request, network_monitor, remote_cluster) >= local_cost:
    6. return local_cluster.execute_full_pipeline(request)
    7. for attempt in range(MAX_RETRY + 1):
    8. try:
    9. # Remote Prefill returns a handle; KVCache shards are sent back over a rate-limited channel
    10. handle = remote_cluster.execute_prefill(request, timeout=REMOTE_TIMEOUT_S)
    11. kv_cache = network_monitor.receive_kv_chunks(handle, rate_limited=True)
    12. # Validate integrity before entering local Decode
    13. if kv_cache.checksum_ok():
    14. return local_cluster.execute_decode(request, kv_cache)
    15. except