Skip to main content
Decode context parallelism (DCP) stripes a request’s MLA KV cache across ranks in an existing tensor-parallel group. With DCP size c, rank r owns position p when p mod c = r, so each rank stores and reads roughly 1/c of the cache. Local attention then sees only part of the context. The MLA path returns a partial output and log-sum-exp (LSE), exchanges both in one packed all-to-all, and merges them exactly. DCP complements TP and attention data parallelism (DPA) rather than replacing them. The primary path is absorbed MLA decode and static target verification. dcp_size=1 retains existing non-DCP behavior. On Kimi K3, DCP applies only to MLA layers. Request-indexed KDA state is unchanged, so DCP grows long-context KV capacity but does not raise the KDA concurrency ceiling.

Enable DCP

A DCP group must fit inside one attention-TP group and one attention-DP replica:
Topology
For example, TP=64, attention DP=4, DCP=16 creates four valid 16-rank attention replicas. DCP=32 would cross replica boundaries and is invalid.
Startup currently checks only tp_size % dcp_size == 0, not the stronger condition above. Until that check is fixed, DPA+DCP deployments must enforce containment when choosing the topology.
MLA decode on DeepSeek-V3.1 with DCP 8 inside TP 8:
Command
Kimi K3 on 32 GPUs with DPA and DCP 8. The model override enables replicated Q by default; the communication backend resolves generically to fi_a2a on MNNVL systems, otherwise a2a:
Command
See the Kimi K3 cookbook for large-scale presets that combine DCP with DPA and expert parallelism.

Why decode context parallelism?

Absorbed MLA shares one latent KV representation across all query heads. TP can split the heads and weights, but not that cache, so every attention-TP rank stores and reads the same context. DCP stripes that cache round-robin by logical token position, keeps a shared virtual index on every rank, runs attention against the owner-local shard, and merges partial outputs by LSE into the usual TP-local head layout.

Architecture

Virtual KV layout

Let each rank have physical token capacity C and physical page size P. DCP exposes a shared virtual allocator:
Layout
Every rank sees the same request-to-token map. On write, it keeps its positions and compacts them into the local physical pool. One widened virtual page maps to one physical page on each rank, so the layout stays balanced to within one token as a sequence grows.

MLA decode dataflow

For context partition r, the kernel returns locally normalized output o_r and lse_r. The global result is lse = logsumexp_r(lse_r) and o = sum_r(exp(lse_r - lse) * o_r). This is exact aside from floating-point reduction order. The merge uses the attention backend’s LSE base, either base-e or base-2.

Query-projection replication

Normally each layer all-gathers its absorbed and rotary query components. --dcp-replicate-q-proj gathers the query-projection and w_kc weights once at startup and computes the full DCP-group query locally. The trade is more weight memory and GEMM work for one fewer collective per layer. w_kc must be BF16/FP16, and the query projection may be unquantized BF16/FP16 or 128x128 block-FP8 (gathered as FP8 weight plus block scales, then post-processed like the per-rank shard so it runs the same GEMM); other layers fall back to the query all-gather.

Communication backends

When --dcp-comm-backend is unset, every DCP launch resolves it the same way: fi_a2a where the DCP group shares one MNNVL domain on Blackwell, otherwise a2a on CUDA/ROCm/XPU, and ag_rs only on platforms without the a2a path. Query replication stays model-resolved: Kimi K3 enables it by default on the a2a family, and its decode backend is cutedsl_mla.

Ascend NPU

A DSA extend on Ascend picks one of two paths per forward. It either gathers the query and merges partial outputs, as decode does, or it all-gathers the cached prefix KV once per layer and attends locally. The query path moves every head’s query plus an FP32 [out, lse] merge per new token. The KV path moves one latent row per prefix token whatever the head count, and nothing at all when there is no cached prefix. Each extend takes whichever moves fewer bytes: for GLM-5.2 (64 heads) that is the KV gather once the new tokens exceed about 1/178 of the cached prefix. Above 4,096 new tokens (SGLANG_NPU_DCP_EXTEND_QUERY_GATHER_MAX_TOKENS) the KV gather is taken regardless, because the query path’s FP32 merge grows with the new tokens and stops fitting beside a long context. The KV path is BF16/FP16 only; any other KV cache dtype keeps the query path. SGLANG_NPU_DCP_EXTEND_GATHER_PIECE_ROWS caps the rows per gather collective, which bounds the scratch buffer next to the gathered context. Size --mem-fraction-static with that buffer in mind: running the KV pool close to full turns the gather into multi-minute stalls rather than a slowdown. DCP adds a context-independent decode collective while cutting context-dependent KV storage and reads by about c. Extend is outside that decode cost model: it may gather cached prefix shards, restore token order, and append new tokens, and that work grows with prefix length.

Compositions

DCP × speculative decoding

The draft KV cache is replicated: every DCP rank stores the full draft context. DCP only stripes the target MLA KV, so it saves target cache, not draft cache. Target verify and decode use the DCP-aware MLA kernel cutedsl_mla. It:
  1. Builds a rank-local page table from the cyclic token map (owner(p) = p mod c).
  2. Runs attention against that shard, passing cp_world, cp_rank, and the global KV lengths so causality still sees the full sequence.
  3. Returns a rank-local (output, LSE) that the usual DCP all-to-all merge combines.
Draft steps use the same backend against the replicated draft cache, so they skip DCP metadata. Kimi K3 DCP selects cutedsl_mla automatically.

DCP × PD disaggregation

A dense prefill page cannot be copied directly into striped decode storage. The PD sender uses the decode rank’s DCP metadata to select and pack the right rows. See PD disaggregation for the transfer engines.
  • Equal DCP sizes require matching DCP ranks and use the existing page path.
  • DCP1 prefill to DCP decode uses token relayout for MLA and hybrid-MLA pools.
  • All other DCP-size transitions are rejected.
The plan includes the exact token count, so stale rows do not leak out of a partial final page. Mooncake and NIXL use the same plan. KDA state keeps its attention-TP mapping and bypasses DCP filtering. This composition requires Mooncake or NIXL, matching physical page size and KV dtype, and prefill attention CP 1. Decode radix cache and HiCache are not supported here.

DCP × HiCache L2

HiCache keeps one widened logical page space across L1 and L2. The controller sees P * c slots, while each GPU and host buffer stores only its P local rows. See HiCache for the cache hierarchy. Before H2D or D2H, both index lists keep positions owned by this rank and map i to floor(i / c). Transfers cover whole widened pages, and every rank moves its shard independently, with no DCP collective. For Kimi K3 this applies to MLA KV; KDA/Mamba state uses its own request-indexed host pool. The current scope is MLA L1/L2. L3, LMCache, HiSparse, non-MLA KV host pools, speculative decoding, and PD decode are not supported in this combination.

DCP × DSA (GLM-5.2, GLM-5.3, Hy4)

DeepSeek Sparse Attention attends over a top-k slice of the context, so DCP keeps the target’s latent KV striped by position while the index-K cache stays replicated on every rank: each rank scores the whole sequence, takes the global top-k, and attends over the selected slots it owns. Decode, target verify and extend all follow the same path, so the prefix KV is never gathered.
  1. The index-K cache is addressed by the widened virtual slot and costs c times its usual share of each rank’s KV budget (about 6% at DCP2 and 17% at DCP4 on GLM-5.3).
  2. Each layer maps the global top-k to rank-local rows with one Triton kernel; layers that share the previous layer’s top-k reuse the mapping.
  3. The TRT-LLM sparse kernel returns the per-head LSE and the usual DCP merge combines the partial outputs.
  4. GLM-5.2 and GLM-5.3 with MTP: the draft (nextn) layer keeps a replicated KV cache over the widened slots and attends without the DCP group, so MTP index share feeds the draft directly.
  5. Hy4: learnable attention sinks add exp(sink) to each head’s softmax denominator. The TRT-LLM kernel takes no sink, so the sink is folded into the partial through the returned LSE. Every rank computes all of its DCP group’s gathered heads but folds only the sinks of its own heads, so the merge counts each sink once.
Requirements for every model in this section: CUDA with the trtllm DSA backends (selected automatically) and attn_tp_size % dcp_size == 0. HiSparse, prefill CP, HiCache, PD disaggregation, unified memory and index_kpool > 1 are not supported in this combination. The models then differ:
  • GLM-5.2, GLM-5.3: SM100/SM103, an fp8_e4m3 or bf16 KV cache, and, with speculative decoding, the checkpoint’s own MTP draft as a single EAGLE chain (--speculative-eagle-topk 1, draft tokens equal to steps + 1).
  • Hy4: SM100/SM103/SM107, a bf16 KV cache, and no speculative decoding. The server refuses Hy4 DCP on SM90 and SM12x, with an fp8_e4m3 KV cache, and with DP-Attention or pipeline parallelism. See the Hy4 cookbook.
GLM-5.3 with its MTP draft:
Command

References