ZICQ
中 Log in / Sign up
Newsroom Official Compute & Architecture #SGLang #HiCache #KV Cache #Distributed Inference #Context Parallelism

SGLang HiCache Scales KV Reuse Across Parallel and Distributed Serving Topologies

Avatar of Mr.Xu

By Mr.Xu Compiled & Reviewed by Editorial

Published:

中文阅读 (Chinese) English Version
Co-reading Select any sentence in the article to highlight, annotate, or copy a quote card. Join discussion ↓

Summary:SGLang’s engineering team has detailed how HiCache maintains hierarchical KV-cache reuse across context parallelism, pipeline parallelism, speculative decoding, and prefill-decode disaggregation. Its design assigns logical pages to owner ranks, gathers one attention layer at a time, overlaps transfers with computation, and preserves cache ownership while moving KV data between GPU memory, host memory, and external storage. An official production case from Iflytek’s Astron MaaS team reports that


HiCache Moves the Cache Boundary Beyond GPU Memory

Agent requests often contain large, stable prefixes: system prompts, tool definitions, retrieved documents, and prior conversation turns change little between calls. SGLang’s Radix Cache can reuse this prefix KV inside GPU memory, but VRAM capacity, parallel topology, and request diversity quickly constrain the hit rate. HiCache extends the hierarchy to host memory and external storage. The hard problem is not moving bytes; it is preserving agreement across ranks about whether a prefix exists, which rank owns each page, and when the data is safe to consume.

This update focuses on making HiCache work with context parallelism (CP), pipeline parallelism (PP), speculative decoding, a unified KV layout, and prefill-decode disaggregation (P/D), rather than treating hierarchical caching as an isolated optimization.

CP × HiCache: Logical Page Ownership Removes Duplicate KV

Context parallelism divides Prefill computation across ranks, but KV pages may still be replicated. SGLang’s page-based sharding gives every CP rank the same logical Radix Tree and logical page IDs, while the physical KV for each page lives on one owner rank.

For N shard ranks, p tokens per page, and allocated logical slot x, the mapping is:

  • Logical page ID: q = floor(x / p)
  • Owner rank: r = q mod N
  • Rank-local location: ell = floor(q / N) × p + (x mod p)

The arithmetic mapping removes the need for a per-page lookup table. When a request extends a cached prefix, the allocator continues the existing owner rotation and rejects insertions that would produce an incompatible rotation. Computation layouts such as Interleave and Zigzag remain independent of physical page placement, so changing the attention work partition does not directly invalidate the cache tree.

This design removes duplicate KV copies, but every rank still needs to see the complete logical sequence during Attention.

Layer-by-Layer Gathering Saves Recomputation, Not Communication

After sharding, each rank owns only a subset of the prefix pages. To read one layer, the ranks contribute their owned pages through an All-Gather. The resulting owner-ordered buffer is interpreted through a page table that maps physical pages back to the original logical sequence, such as A, B, and C. KV for the current chunk is staged beside the historical prefix at the cache-write boundary.

SGLang alternates between two temporary layer buffers, allowing the next layer’s gather to overlap with the current layer’s Attention computation. Those buffers are included in the scheduler’s cache budget, and a batch is admitted only if both its Attention KV and gather scratch space fit.

The trade-off is fundamental: a prefix hit avoids expensive Prefill computation, but it does not eliminate the cost of assembling the full prefix. Communication grows with prefix length, KV-head count, layer count, and parallel-group size. The extra memory is also larger than the resident cache pages alone. For conventional GQA models, a conservative estimate for the two simultaneously live layer buffers is 2 × prefix_tokens × H_kv × D_head × bytes_per_element, assuming each rank assembles the complete sequence; MLA requires the latent-width equivalent.

On supported configurations, HiCache can use GPU copy engines instead of NCCL SM kernels for parts of the gather, reducing competition with model computation for SM resources. The article provides no bandwidth, latency, or end-to-end comparison for this path, however, so it should not be treated as an unconditional acceleration.

Restore Must Precede Gather, Which Must Precede Attention

When HiCache backs KV up to host or external storage, it must preserve logical page ownership. Otherwise, a restored page could land on a rank that will not contribute it to the next gather. Each rank selects its own source and destination pairs and executes its local GPU-host path through independent transfer queues; physical address changes do not affect the logical tree.

GPU restoration uses a transfer stream, while prefix gathering runs on another stream. Each layer’s gather waits for that layer’s restore-completion event, and Attention waits for the gathered buffer. The dependency is therefore strict:

restore local pages → gather prefix → attention

The scheduler must also reserve gather buffers before queuing a reload, preventing a cache restoration from completing when the compute path cannot start because of insufficient memory.

Integrating PP, Speculative Decoding, and P/D

With pipeline parallelism, cache transfers may complete asynchronously across stages, but the stages still need to agree on which prefix can be reused. Otherwise, a later stage may wait incorrectly or transfer data that is already available. The external-storage path must likewise agree on the cached prefix range so that multiple instances do not repeatedly write the same logical history.

Speculative decoding needs more than the target model’s KV: the draft model’s required state must also be restored. Without it, a cache hit can leave the target and draft models with inconsistent context. SGLang’s unified KV layout allows compatible parallel configurations to share stored KV, but this reuse depends on compatible model architectures, page sizes, KV representations, and parallel topologies; cached pages are not a model-independent universal format.

In a prefill-decode disaggregated deployment, the Decode side can reuse an existing prefix and the Prefill side only transfers missing KV. The benefit still depends on stable prefix matching. If system prompts, tool context, or templates change frequently, external storage adds write and eviction pressure without equivalent compute savings.

Reading the 95% Hit Rate and Sub-3-Second TTFT

The official post cites a deployment by Iflytek’s Astron MaaS team. It combines pipeline parallelism, prefill-decode disaggregation, and MTP to serve GLM-5.1/5.2 CodingPlan workloads. Typical inputs contain 30K–200K tokens, while some reach 1M.

| Metric | Without HiCache | HiCache with external storage | |---|---:|---:| | Cache-hit rate | About 30% | 95% | | Median TTFT | Not reported | Below 3 seconds |

The figures suggest that extending a highly stable agent-workload prefix from GPU memory to a higher-capacity storage tier can improve time to first token and reduce Prefill pressure. But this is a single deployment reported through an official blog, not a controlled benchmark. The post does not disclose the GPU and storage media, network topology, cache capacity, concurrency, request sample size, hit-rate definition, baseline TTFT, P95/P99 latency, or total cost of ownership. The workload also mixes GLM-5.1 and GLM-5.2, leaving model-version effects only partially isolated. It therefore cannot support a fixed acceleration factor for every long-context deployment.

A stronger evaluation should jointly measure hit rate, useful Prefill work avoided, restore bandwidth, gather time, end-to-end TTFT, inter-token latency, throughput, and P99—not the hit rate alone.

Engineering Budgets for Production Deployment

  1. Validate prefix stability first. Measure the shared fraction of system prompts, tool chains, and conversation history on real traffic, and distinguish request hits, token hits, and useful compute saved.
  2. Choose each storage tier deliberately. GPU hits have the shortest path, host memory balances capacity and latency, while external storage maximizes capacity but depends more heavily on PCIe, networking, and storage tail latency. Benchmark GPU-only, host-only, and external-storage configurations separately.
  3. Budget gathering and restoration. Include the two layer buffers, transfer queues, page tables, and external I/O in memory and bandwidth plans. At long prefixes, gather communication can offset part of the Prefill saving.
  4. Maintain a compatibility matrix. Validate each model version, quantization, page size, KV layout, TP/PP/CP combination, speculative-decoding path, and P/D topology. Do not treat cached files as portable across every configuration.
  5. Prevent cache pollution. Apply tenant- and domain-aware eviction, then tune capacity using hot-prefix distribution, write rate, and eviction rate. A higher hit rate with little useful compute reduction usually means the cache is retaining low-value or rapidly invalidated prefixes.
  6. Roll out in stages. Validate page ownership and hit decisions with shadow traffic before enabling P/D and speculative-decoding paths, and compare P50, P95, and P99 rather than relying only on medians.

Debugging with rank_consensus_checker

When ranks disagree about cache hits, page ownership, or restoration state, the symptom is often an occasional incorrect token, abnormal waiting time, or load imbalance rather than a clean crash. SGLang provides rank_consensus_checker to compare cache decisions across ranks and locate disagreement in a distributed topology.

HiCache’s core contribution is not simply another cache level. It integrates page ownership, restoration, gathering, and cross-stage consistency into a distributed execution protocol. Whether that protocol becomes a production win depends on real prefix stability, storage bandwidth, and parallel communication cost. The reported 95% hit rate is compelling, but it does not replace workload-specific benchmarking.


Source: LMSYS / SGLang Blog (2026-11-02)

— END —

Tags: #SGLang #HiCache #KV Cache #Distributed Inference #Context Parallelism

Editorial & Fact-Checking Note: This article is compiled from primary research, official release documentation, and source papers by the ZICQ Newsroom pipeline with automated entity verification and human editorial review. If you notice any technical inaccuracy, please submit a correction via our corrections policy or email our editorial desk directly.

What's your take on this story?
Explore & Submit Works

Community Comments

Loading live comments and annotations…