In this series / On this page· 8 of 18
Serving in Production
  1. 1. Disaggregated Serving: Dynamo, llm-d, and When Splitting Prefill from Decode Pays
  2. 2. TTFT, ITL, Goodput: Measuring What Users Feel
  3. 3. Benchmark an Inference Server Without Lying to Yourself
  4. 4. Expert Parallelism, and What DeepEP Does for It
  5. 5. Serving Kimi K3.1 Pro: The State per Request, the Indexer's Cost, and Where 1M Tokens Fit
  6. 6. Other Users' Data in the KV Cache: What Cloudflare's GLM-5.3 Incident Teaches Operators
  7. 7. Flow Control in the Serving Stack: What llm-d, Dynamo and AIBrix Do When the Fleet Is Full
  8. 8. Context Parallelism for Long-Context Serving: PCP and DCP in vLLM and SGLang
  9. 9. Several Models, One GPU: Time-Slicing, MPS, MIG, and What CUDA 13.4's Memory Caps Change
  10. 10. Serving Mistral Large 4: What Its Cache Costs and Where It Fits
  11. 11. Prefix-Aware Routing Across Replicas: Kubernetes Service, Dynamo's KV Router, the llm-d EPP and Kinference
  12. 12. Serving Ripple-65B: What a Dense Model with 1M Context Costs, and When It Beats an MoE
  13. 13. Cost per Million Tokens, Computed: GPU-Hours, Utilization, and the Cache
  14. 14. Kinference at alpha.7: What Buoyant's Inference Control Plane Does, and What It Reuses
  15. 15. Splitting Off the Vision Encoder: When Encoder Disaggregation Pays in vLLM
  16. 16. The Cache Hit That Changed the Answer
  17. 17. Prefix Caches That Collapse Under Bursts, and the Session Cap That Prevents It
  18. 18. MLPerf Endpoints v1.0: How to Read an Agentic Inference Benchmark
8 of 18

Context Parallelism for Long-Context Serving: PCP and DCP in vLLM and SGLang

Tensor parallelism copies an MLA cache onto every GPU; how PCP and DCP split long contexts by token in vLLM and SGLang, and when DCP pays.

23 min readUpdated

On a model with latent attention, tensor parallelism splits the heads but not the cache: TP8 stores the same KV cache on all eight GPUs. One 1M-token GLM-5.3 request is 53.4 GiB of FP8 cache, on each GPU, and in the vLLM team's 16-H200 deployment each GPU had about 15 GiB left for it, so adding GPUs added no room. Context parallelism splits by token instead, in two kinds that are easy to confuse: decode context parallelism (DCP) divides the stored cache, prefill context parallelism (PCP) divides the prompt's compute, and only the first adds room.

Tensor parallelism copies the cache

TP gives each GPU a slice of the attention heads, and a GPU only needs the KV of the heads it computes. So the cache splits as far as there are distinct KV heads, and no further. Past that point, every extra TP rank holds a copy.

For grouped-query attention the duplication factor is TP / KV heads once TP exceeds the KV head count. Qwen3-235B-A22B has 4 KV heads: at TP8 each pair of GPUs holds the same quarter of the heads, so the cache exists twice. Its 94 layers store 188 KiB per token in BF16 (the formulas are in The KV Cache, Sized); one 256K-token request is 47.0 GiB in all and 11.75 GiB per GPU at TP8, twice what eight GPUs would need without the copy.

For latent attention (MLA) the factor is the full TP size. Every head reads the same compressed latent per token (see When Most Layers Stop Caching), so every rank stores all of it. GLM-5.3, read from its config.json and vLLM's FP8 layout: 78 MLA layers at 656 bytes per token, 21 indexer layers at 132 bytes (GLM-5.3 uses DeepSeek Sparse Attention, DSA, whose indexer picks the top-k tokens for each query and keeps its own keys), and one multi-token-prediction layer at 788 bytes, for 54,728 bytes per token. At 1,048,576 tokens that is 53.45 GiB, on each of the eight GPUs. With 15 GiB of room per GPU, not one such request fits.

Three panels of 8 tokens on 4 GPUs. TP4 on MLA: every GPU holds latent rows 0 to 7. DCP4 with interleave 1: GPU r holds tokens r and r+4, so each holds a quarter. PCP4 zigzag: the prompt's query blocks are paired early with late, q0 with q7 on GPU 0, and each GPU gathers the other tokens' keys and values to attend; with PCP alone every GPU keeps the whole cache.Three panels of 8 tokens on 4 GPUs. TP4 on MLA: every GPU holds latent rows 0 to 7. DCP4 with interleave 1: GPU r holds tokens r and r+4, so each holds a quarter. PCP4 zigzag: the prompt's query blocks are paired early with late, q0 with q7 on GPU 0, and each GPU gathers the other tokens' keys and values to attend; with PCP alone every GPU keeps the whole cache.

Figure 1: TP copies the cache, DCP divides it. PCP divides the prompt's work: each rank gathers the layer's keys and values to attend, and in vLLM keeps a whole copy afterwards unless DCP also spans the PCP ranks.

Two splits by token

DCP divides what is stored, PCP divides what is computed, and they cost different things: DCP adds no GPUs and one exchange per layer; PCP adds GPUs in vLLM and a per-layer all-gather of the context. The versions below are vLLM v0.32.0 and SGLang v0.5.22.

DCP stores token p on DCP rank p mod c, where c is the DCP size. The ranks are the TP ranks you already have: "Without PCP, DCP reuses TP ranks" (parallel.py), so DCP adds no GPUs and divides the stored cache by c. vLLM can also stripe tokens in blocks rather than one at a time (cp_kv_cache_interleave_size); SGLang always stripes token by token and widens each page to P x c.

PCP splits a prompt's queries across ranks instead. SGLang's zigzag strategy cuts the prompt into 2c blocks and gives rank r blocks r and 2c-1-r, so every rank gets equal causal work; its interleave strategy is the one for DSA models. Each layer then all-gathers the keys and values into a temporary full copy, attends for its own queries, and frees the copy. PCP cuts time to first token on long prompts. It does not shard what is stored: after prefill each PCP rank holds the whole cache ("PCP-only execution replicates the KV cache", parallel.py). That is why vLLM's GLM-5.3 prefill engine pairs PCP8 with DCP8 on the same eight GPUs: PCP splits the prompt's work, DCP then splits what it leaves behind.

The two engines also disagree on what PCP costs in GPUs. In vLLM, PCP multiplies the world size: TP x PCP x PP GPUs (parallel.py). In SGLang, --attn-cp-size subdivides the TP world: TP = attention DP x attention CP x attention TP. "PCP8" means eight more GPUs in one engine and a relabelling of eight existing ones in the other.

Don't read too much into the names: the vLLM team's GLM-5.3 post calls them "historical". DCP also shards the prefill engine's cache, and in v0.32.0 PCP also gives each decode request a single owner rank (#52162).

One decode step, and why the merge is exact

At decode there is one query token per request, so the only thing worth splitting is the cache. Each rank attends over its shard and the partial results are combined:

One decode step in one MLA layer on a DCP4 group, as four stages. 1: the query is all-gathered across the group, or skipped when the small query projection is replicated. 2: each GPU attends over its quarter of the tokens and returns a partial output and its log-sum-exp. 3: the group exchanges partials, either an LSE all-gather plus an output reduce-scatter or one packed all-to-all. 4: the exact merge. A side column marks which stages grow with context: only stage 2, divided by 4.One decode step in one MLA layer on a DCP4 group, as four stages. 1: the query is all-gathered across the group, or skipped when the small query projection is replicated. 2: each GPU attends over its quarter of the tokens and returns a partial output and its log-sum-exp. 3: the group exchanges partials, either an LSE all-gather plus an output reduce-scatter or one packed all-to-all. 4: the exact merge. A side column marks which stages grow with context: only stage 2, divided by 4.

Figure 2: DCP replaces reading the whole cache with reading a quarter of it, plus an exchange whose size doesn't depend on context.

A softmax over a shard is exact once you know the shard's log-sum-exp. If rank r returns its normalized output o_r and lse_r = log Σ exp(s) over its scores, the full result is o = Σ_r exp(lse_r − lse) · o_r with lse = log Σ_r exp(lse_r). This is the core of lse_merge_check.py, which shards one attention call shaped like GLM-5.3's absorbed decode (64 query heads over one 576-dimension latent) and compares the merge with unsharded attention:

# lse_merge_check.py (excerpt; shards(), err() and the driver loop omitted, full script attached)
def attend(q, k, dtype):
    # one shard: normalized partial output o_r and its log-sum-exp lse_r (natural log)
    if k.shape[0] == 0:
        return torch.zeros(q.shape[0], H, DV, device=dev), torch.full((q.shape[0], H), -math.inf, device=dev)
    s = (q.to(dtype) @ k.to(dtype).T).float() / math.sqrt(DK)        # [B, H, n]
    lse = torch.logsumexp(s, dim=-1)                                   # [B, H]
    p = torch.exp(s - lse[..., None])
    return (p.to(dtype) @ k[:, :DV].to(dtype)).float(), lse

def merge(parts, base2=False):
    o_r = torch.stack([o for o, _ in parts])                          # [c, B, H, DV]
    lse_r = torch.stack([l for _, l in parts])                        # [c, B, H]
    if base2:                                                         # bug: base-2 LSE merged as base e
        lse_r = lse_r / math.log(2)
    lse = torch.logsumexp(lse_r, dim=0)
    return (torch.exp(lse_r - lse)[..., None] * o_r).sum(0)

Run on one GPU (an NVIDIA GB10, torch 2.13.0), python lse_merge_check.py prints, for 131,072 tokens and in part:

n=  131,072 bfloat16 unsharded           rel 2.0e-02
n=  131,072  float32 DCP2 round-robin rel 1.4e-06
n=  131,072  float32 DCP8 block-64    rel 4.4e-06
n=  131,072 bfloat16 DCP8 block-64    rel 2.1e-02
  wrong merge, plain average (DCP4):  rel 6.5e-01
  wrong merge, base-2 LSE (DCP4):     rel 1.9e-01

In FP32 the merge matches unsharded attention to within 1e-5 relative error at every DCP size, both layouts, a context that doesn't divide evenly (1,000,003 tokens), and a 3-token context where some ranks hold nothing (their lse is −∞ and they drop out; vLLM masks these explicitly, mask_dcp_empty_shards_). In BF16 the sharded error stays at BF16's own level (1.1e-2 to 2.1e-2, against 0.9e-2 to 2.2e-2 unsharded). The two deliberate bugs show why the LSE matters: averaging the partials is off by 49% to 86%, and mixing a base-2 LSE with a base-e merge by 15% to 22%, the mistake vLLM's lse_base_on_e comment warns "silently corrupts the cross-shard softmax denominator".

The cost model follows from the shapes. The exchange per layer is the size of the output, heads x head dimension x batch, whatever the context; the read and the storage are divided by c. How many collectives that takes depends on the backend: SGLang's table counts three per MLA layer for ag_rs (query all-gather, LSE all-gather, output reduce-scatter), two for a2a with a gathered query, one for a2a with a replicated query projection; Figure 2 counts the exchange alone. vLLM v0.32.0 offers ag_rs (default) and a2a, and replicates the query with --dcp-q-replicate (SGLang: --dcp-replicate-q-proj); GLM-5.x defaults to a2a with a replicated query (models/config.py).

GLM-5.3's sparse attention adds one wrinkle: its indexer must pick the top-k tokens over the whole context, not per shard. The engines solve it differently, and it shows in the memory. vLLM shards the indexer's keys too and has each rank send its local top-k candidates, which is exact because a token in the global top-k is in its owner's local top-k (sparse_attn_indexer.py). SGLang keeps the indexer keys, and the MTP layer's cache, whole on every rank.

Size it for your model

Per-GPU cache per session is a sum over layer groups: each group's bytes per token x context, times the share of it one GPU holds. MLA latent: 1 / DCP. GQA: the GPU's share of KV heads, divided by DCP. Parts an engine keeps whole: 1. Per-session recurrent state (Kimi K3's linear-attention layers): 1 / TP, never divided by DCP. vLLM's scheduler does the same arithmetic (kv_cache_interface.py).

The calculator below does it for three models and checks the topology against both engines' rules:

Interactive widget: cp-kv-sizer. Open this page in a browser with JavaScript to use it.

Three things to try:

  1. GLM-5.3, 1M tokens, TP8, 15 GiB free. Zero sessions fit. DCP4 fits one, DCP8 two in vLLM (6.68 GiB each) and one in SGLang (8.88 GiB), because SGLang's indexer keys and MTP cache stay whole. SGLang also flags the topology: its DCP on DSA models needs SM100-class GPUs (B200, B300) and its trtllm backends, so it won't run this on an H200.
  2. Kimi K3, 1M tokens, BF16, TP8. Its 24 MLA layers drop from 27.0 GiB per GPU to 3.4 GiB at DCP8, while the state of its 69 linear-attention layers, 449 MB per session at vLLM's default FP32 recurrent state (232 MB in BF16), stays split by TP only (56 MB per GPU at TP8). DCP raises how long a context fits, not how many sessions' state slots exist. Then set DCP back to 1 and PCP to 2: vLLM rejects it, because Kimi K3's MLA asserts PCP is 1, and SGLang doesn't document it.
  3. Qwen3-235B-A22B, 256K tokens, BF16. TP8 is 11.75 GiB per GPU with two copies; DCP2 halves it to 5.88 GiB and removes the copy. DCP4 is rejected by vLLM, whose cap is TP / KV heads = 2, and accepted by SGLang, which then spreads the heads across only TP / DCP = 2 groups: each GPU holds two heads for a quarter of the tokens, still 5.88 GiB. Past TP / KV heads, more DCP saves nothing.

Bars of per-GPU FP8 cache for one 1M-token GLM-5.3 request at DCP 1, 2, 4 and 8, vLLM and SGLang side by side, against a line at 15 GiB. vLLM: 53.45, 26.72, 13.36, 6.68 GiB. SGLang: 47.27, 25.34, 14.37, 8.88 GiB.Bars of per-GPU FP8 cache for one 1M-token GLM-5.3 request at DCP 1, 2, 4 and 8, vLLM and SGLang side by side, against a line at 15 GiB. vLLM: 53.45, 26.72, 13.36, 6.68 GiB. SGLang: 47.27, 25.34, 14.37, 8.88 GiB.

Figure 3: per-GPU cache falls as 1/DCP until the parts kept whole dominate; only DCP4 and up fit one request. SGLang's lower start is its 576-byte FP8 row (the trtllm layout DCP needs there, drawn at every DCP size) against vLLM's 656; the 15 GiB line is vLLM's H200 deployment, and SGLang runs DCP on DSA only on B200/B300-class GPUs.

What each engine accepts

Rule vLLM v0.32.0 SGLang v0.5.22
DCP flag --decode-context-parallel-size (-dcp) --dcp-size
PCP flag --prefill-context-parallel-size (-pcp) --enable-prefill-cp --cp-strategy {zigzag,interleave} --attn-cp-size N
GPUs TP x PCP x PP; DCP adds none inside the TP world; DCP adds none
DCP on MLA tp % dcp == 0 (parallel.py) attn_tp % dcp == 0; startup checks only tp % dcp (dcp.mdx)
DCP on GQA TP > KV heads, DCP ≤ TP / KV heads, query heads per KV head divisible by DCP (model.py) heads spread over TP / DCP groups (model_config.py); not in the docs, tested in CI with the triton backend
PCP with DCP DCP ∈ {1, PCP, TP x PCP}, and only for DSA attention (DeepSeek V3.2, GLM-5.x) rejected (parallel_hook.py)
PCP scope MLA backends only zigzag for GQA, interleave for DSA with attention CP = TP
Comm backend, replicated query --dcp-comm-backend ag_rs (default) or a2a; --dcp-q-replicate ag_rs, a2a, fi_a2a; --dcp-replicate-q-proj
Not with DCP HiSparse (vllm.py), dual-batch overlap; NIXL P/D needs MLA and DCP in (1, max(TP, PCP)) HiSparse, LMCache; on DSA also HiCache, P/D, prefill CP; DSA needs SM100/SM103 and trtllm
Kimi K3 DCP on the MLA layers; PCP rejected DCP on the MLA layers; PCP not documented

Picking a size. On MLA, any DCP that divides TP (in SGLang, that divides attention TP when attention DP is on). On GQA in vLLM, TP must exceed the KV heads, DCP can be at most TP / KV heads, and it must divide the query heads per KV head; SGLang accepts more, but past TP / KV heads it saves nothing, so for Qwen3-235B at TP8 DCP2 is the useful maximum.

Launch lines, checked against each engine's argument parser at those versions. DCP needs two GPUs or more, so none of these ran here:

# vLLM, GLM-5.3: shard the cache 8 ways inside TP8
$ vllm serve zai-org/GLM-5.3 \
    --tensor-parallel-size 8 \
    --decode-context-parallel-size 8

# vLLM, the GLM-5.3 prefill engine's key flags as the vLLM team published them (PCP8 x DCP8 x EP8 on 8 GPUs)
$ vllm serve zai-org/GLM-5.3 \
    --prefill-context-parallel-size 8 \
    --decode-context-parallel-size 8 \
    --dcp-comm-backend ag_rs \
    --enable-expert-parallel \
    --attention-config '{"sparse_mla_force_mqa":true}'

# vLLM, GQA: Qwen3-235B-A22B, DCP2 removes TP8's duplicate copy
$ vllm serve Qwen/Qwen3-235B-A22B-Instruct-2507 \
    --tensor-parallel-size 8 \
    --decode-context-parallel-size 2

# SGLang, GLM-5.3 on B200/B300: DCP2 with MTP, from SGLang's DCP docs
$ sglang serve --model-path zai-org/GLM-5.3 --trust-remote-code \
    --tp-size 8 \
    --dcp-size 2 \
    --speculative-algorithm EAGLE \
    --speculative-num-steps 5 \
    --speculative-eagle-topk 1 \
    --speculative-num-draft-tokens 6

In the prefill engine, PCP8 and DCP8 on eight GPUs means TP is 1 and DCP equals PCP, one of the three allowed cases, and ag_rs overrides GLM's a2a default. The sizes above assume an FP8 cache: vLLM v0.32.0 picks FP8 for GLM-5.x with --kv-cache-dtype auto only on SM100-class GPUs, so on an H200 ask for it (--kv-cache-dtype fp8_ds_mla).

What DCP costs: capacity, not speed

Where the cache is the limit, DCP buys capacity; where it isn't, the published numbers show it costing throughput. None of these runs was reproduced here.

Source Hardware, engine Model, workload Result
vLLM DCP blog (2026-08-07) 8x B200, vLLM (version not stated) Kimi K2.6 NVFP4, agentic trace (median input ~67K, tail ~1M), 16 to 512 concurrent TP plateaus at 1,863 tok/s/GPU with the cache full at 64; DCP reaches 6,091 at 512 (3.3x)
vLLM GLM-5.3 Part 2 (2026-10-23) 2x 8x H200, prefill/decode split, vLLM main at 9e38b4111a ("Everything runs on vLLM v0.32.0 or later") GLM-5.3, Claude Code traces (AgentX), 8 to 64 concurrent at 142K and 8 to 32 at 1M PCP8 x DCP8 prefill against a DP8 prefill node, up to 32 concurrent: 1.7x to 3.2x P90 interactivity at equal throughput, median TTFT 1.5-5.2 s to 0.8-0.9 s; DCP8's all-gather 6% of a prefill step up to 64K cached, 15% at 248K
SGLang #43735 (2026-10-13, in v0.5.22) 8x B300, SGLang GLM-5.3 FP8, TP8, AIME26, up to 64 running requests aggregate generation tok/s, Figure 4

Grouped bars of AIME26 generation throughput for GLM-5.3 FP8 on 8x B300, published by the SGLang team in PR 43735. Without MTP: TP8 1,140, DCP2 1,041, DCP8 838 tokens per second. With MTP: TP8 not run, DCP2 1,876, DCP8 1,784.Grouped bars of AIME26 generation throughput for GLM-5.3 FP8 on 8x B300, published by the SGLang team in PR 43735. Without MTP: TP8 1,140, DCP2 1,041, DCP8 838 tokens per second. With MTP: TP8 not run, DCP2 1,876, DCP8 1,784.

Figure 4: DCP alone cost 9% to 26% of throughput; the headline 2.1x is MTP on top of DCP8, and the table has no TP8 + MTP run to compare it with.

SGLang's release notes summarize that PR as DCP with MTP decoding "up to 2.1x faster". The 2.1x is 1,784 against 838: MTP's gain on top of DCP8. Without MTP, DCP lowered aggregate generation throughput by 9% at DCP2 and 26% at DCP8. Our reading: AIME26 contexts are short, so at 64 running requests the cache almost certainly fit at TP8 already, and DCP added a collective per layer without lifting a constraint; the PR doesn't report KV usage, so that part is inference. And the decode node of vLLM's 16-GPU GLM-5.3 deployment doesn't use DCP at all: at v0.32.0 HiSparse and DCP can't be combined (vllm.py), and the team used HiSparse for decode. DCP's headline result in that post is on the prefill engine.

The rule. Turn on DCP when sessions x per-GPU cache at your TP exceeds the free KV memory, or when one request at your longest context doesn't fit. Pick the smallest DCP that reaches your target concurrency: each doubling halves the cache and adds no GPUs, but the per-layer exchange stays. Keep the DCP group inside one NVLink domain (vLLM's deployment docs run Kimi-K2 at TP16 with DCP8 for that reason), and prefer the replicated-query path, which saves a collective per layer at the cost of a copy of the small query projection on each rank (in SGLang only for unquantized BF16/FP16 layers; others fall back to the all-gather). If the cache already fits, leave DCP at 1: in SGLang's run it cost 9% to 26% of throughput; get more from replicas or speculative decoding. Add PCP when long-prompt time to first token, not memory, is the complaint.

Gotchas

SGLang's startup check is weaker than its rule. It checks tp % dcp, but with attention data parallelism the real constraint is attn_tp % dcp. A TP64, attention-DP4, DCP32 server starts and builds DCP groups that cross replicas; its own docs say to enforce the rule yourself.

vLLM's GQA rule is not the one in its blog. At v0.32.0 the code requires TP strictly above the KV head count, DCP at most TP / KV heads, and query heads per KV head divisible by DCP; the August post states (tp // kv_heads) % dcp == 0. Trust the error text.

What stays whole doesn't shrink. SGLang's indexer keys and MTP cache on DSA models, a separate draft model's cache, and Kimi K3's linear-attention state are kept whole or split only by TP. Past DCP4 they are a growing share of what's left: 3.4 GiB of SGLang's 8.88 GiB per GPU at DCP8 in Figure 3.

PCP with DCP is narrower than it reads. vLLM allows only DCP = 1, PCP, or TP x PCP, and only on DSA attention; plain MLA raises "does not support PCP+DCP", Kimi K3 refuses PCP entirely, and GQA models have no PCP backend. SGLang refuses the pair outright.

Blocks get wider. Under DCP a scheduler block covers block_size x DCP tokens, the interleave size must divide the block size, and with NIXL prefill/decode vLLM sets the interleave to the block size unless you set it explicitly. Prefix-cache hits and any tool that counts blocks see the wider block.

The GLM-5.3 prefill engine runs PCP8 x DCP8 next to EP8: Expert Parallelism, and What DeepEP Does for It covers how the expert layers split across those same GPUs, and GLM-5.3 Architecture the model's full layout.

Sources

  1. Quantization in PracticeQuantizing the KV Cache: FP8 and Below
  2. Inference EnginesvLLM 0.34: Three Changes to Re-check Before You Upgrade
  3. The GPU for Inference EngineersMegakernels for Decode: What a Kernel Boundary Costs, and When Fusing a Layer Pays

Inference Notes

Once a week: what changed in serving AI models, and what it means if you build, run or pay for them, in about five minutes.

Read past issues