Skip to content

PD transport ​

Use this reference to configure prefill/decode (P/D) transport, decode receive capacity, admission, and failed-receive retirement.

Mooncake transport ​

Mooncake key-value (KV) transfer selects ascend_direct on Ascend NPU and rdma on GPU platforms. Install a Mooncake build that supports the selected transport and provides the TokenSpeed C entry points in libtokenspeed_transfer_engine.so, including ts_mooncake_write_pages for page transfers. Both Prefill and Decode engines select their transport from the detected platform. Startup settings pass this protocol to the Rust transfer peer, which keeps it when recreating a session after a memory resume.

Upgrade Prefill and Decode nodes together: cache registrations carry a separate cache identity in a ninth frame, and requests name that identity. Older peers without this field are incompatible. Each Decode cache resume gets a new identity even if its transport IP and port are reused. The sender refreshes cached remote memory keys on address reuse without changing the public address used by EPD.

Decode receive capacity ​

On a decode node, --disaggregation-decode-extra-slots adds shared resident request slots per attention DP rank. If omitted, it defaults to max-num-seqs divided by the attention DP size (integer division). Prefill, fused, and encode nodes default to zero and reject positive values. Explicit values are preserved; zero disables the extra capacity.

If the rank-local execution limit is B = max-num-seqs // attention DP size and the extra count is E, the resident pool has C = B + E real request rows. By default, E=B and C=2B. For example, max-num-seqs=48 with two attention DP ranks gives B=24, E=24, and C=48 on each rank. Setting E=16 instead gives C=40. TP replicas use the same rank-local limits.

The E=B default enables the extra capacity even when the flag is omitted. It targets workloads where a performant execution batch leaves KV headroom, such as long-input, short-output agent traffic: receiving and ready requests can overlap that batch. It does not guarantee a full batch when prefill supplies too little ready work.

Capacity and memory effects ​

A decode engine registers max-num-seqs + E × attention DP size as its request window with the SMG gateway, so P/D admission keeps up to C requests on each rank.

Extra slots increase residency, not KV memory. Receiving, ready, and decoding requests share the same LCM KV pool; E has no separate KV partition. The execution batch, CUDA graph ladder, and single-forward scratch remain sized by B. Request-indexed persistent state grows with C, which can leave less GPU memory for the KV arena. The capacity model also charges C residents' working sets, including state slots, tails, and protected windows. Depending on the model and cache layout, this can reduce the reported token capacity for the same arena. Receiving all C requests at their maximum context length is not guaranteed.

Ready-wait metrics ​

A ready request that waits for an execution permit is a time-to-first-token cost, not a decode cost. The decode role's first-token boundary is its first local decode output, so the wait measured by tokenspeed:decode_ready_wait_seconds and the RequestStats field decode_wait_ms falls inside ttft_ms and outside the window used by decode_tps and TPOT. Compare TPOT across different E values together with those waits and the tokenspeed:num_decode_ready_waiting_reqs gauge.

Capacity-model example ​

For a concrete capacity-model example, fix B=32 and 4,096 usable LCM blocks on a D rank. Use one full-history group with 64-token pages and one State group, both with one child block per LCM block; prefix caching and speculation are disabled, decode width and overlap depth are both 1, and the context limit is 65,536. The model charges ceil(T/64)+C history pages and 2C State blocks for a concurrent token budget T. The following table compares explicit E=0 with the default E=B under these conditions:

Capacity-model metricExplicit E=0Default E=B
Resident requests C3264
Physical request rows, including null and padding3466
Usable LCM blocks4,0964,096
Maximum concurrent token budget T256,000249,856

The token budget decreases by 6,144 (2.4%) in this example, with the same arena and execution limit. These are sizing-model results, not GPU benchmark measurements; they exclude the additional persistent tensors' memory cost. Other cache layouts have different costs.

Snapshot behavior ​

Use an explicit extra count when measuring the feature. Set E=0 at startup to retain C=B; shrinking a live request pool is not supported. A request keeps its original slot when reception completes and waits for an execution permit before its first decode. The default snapshot request limit also grows to C; an explicit positive limit is preserved. For more information about its Host-memory cost and independent image-storage limits, see Retraction snapshot pool.

Version compatibility ​

This capacity API requires matching TokenSpeed runtime and native components, even when E=0. Do not mix runtime or scheduler builds from before this API change with builds that include it. For source deployments, rebuild and install tokenspeed-engine and any standalone tokenspeed-scheduler from the same revision as the Python runtime. The serving host uses the scheduler embedded in tokenspeed-engine; upgrading the standalone scheduler wheel alone does not update that embedded copy.

P/D admission ​

--disaggregation-decode-allocation-policy sets what a request's Decode allocation gates on a prefill server; the other roles refuse the flag. The following policies are available:

  • early (default): Admits the prefill once every Decode rank of the request has allocated its destination, so the KV can stream layer by layer during the forward. Deprecated: early will be removed once deferred supports the layouts that still need it.
  • deferred (experimental): Defers the Decode allocation until the prefill server holds every page of the prompt. The prefill server computes the prompt without waiting for the allocation and holds only its KV transfer. A computed prompt keeps its pages until the destination is allocated.

The deferred policy requires all of the following conditions:

  • Attention TP is 1.
  • You set --kv-parallel-size 1.
  • You set --pipeline-parallel-size 1.
  • You omit --enable-external-encoder.
  • You explicitly set --disaggregation-layerwise-interval 0.
  • The model has no multimodal input, or you set --language-model-only.

Startup rejects any other configuration.

Deferred allocation behavior ​

Under deferred, computed prompts waiting for their destination hold prefill pages. New prompts are admitted meanwhile as under early, so on a tight prefill pool smaller prompts that keep fitting can delay a larger one.

The two servers keep one order under deferred: a request takes every page it needs on the prefill server before its Decode server allocates its destination, so neither holds pages the other waits for. The Decode server announces each request independently of prefill admission. The prefill server can compute before that announcement and tells the Decode server when the request's last chunk is admitted; only then may the Decode server allocate. An announcement arriving later receives this notice immediately. The Decode server's scheduler sees every request whose notice arrived and chooses among them as it chooses among the requests of early prefill servers. Every Decode server of a prefill server that runs deferred must understand the announcement: an older one sends its manifest unannounced and fails each request at once.

Admission timeouts ​

TOKENSPEED_DISAGGREGATION_BOOTSTRAP_TIMEOUT (120 s by default) bounds what a request waits for from its Decode server on the prefill server. Under deferred, the clock starts when the request holds all its prompt pages, whether or not Decode has announced it. The request fails if the destination is not allocated within that timeout. On the Decode server TOKENSPEED_DISAGGREGATION_WAITING_TIMEOUT bounds the wait for the prefill server's notice, which covers the prefill server's queue and computation, and then again the wait for the allocation.

Deferred allocation limits ​

The deferred policy has the following known limits:

  • Prefill pool pressure: With a tight prefill pool, deferred is slower than early even when every Decode server is healthy because prompts wait for destinations with their pages.
  • Independent prefill computation: The prefill server computes requests without waiting for Decode, whether or not that server announces or allocates.
  • Unavailable Decode allocation: A Decode server that does not allocate keeps its computed prompts' pages on the prefill server until each fails, one timeout after it held its pages. Prompts for other Decode servers wait for those pages meanwhile.
  • Timeout coverage: Before a request holds all prompt pages, only its Decode server's waiting timeout bounds the wait. If that server is gone, the prefill-side timeout starts once the request holds its pages.
  • Prefix-cache publication: A computed prompt waiting for its destination publishes its last chunk to the prefix cache only with its transfer. A prompt with the same prefix admitted meanwhile computes that chunk again.
  • Full Decode server: Later smaller requests can be allocated ahead of a larger one, whose prompt keeps its pages on the prefill server until it is allocated or one of the two timeouts fails it.
  • Prefill failure after notice: If a prefill server stops after its notice, the Decode server fails the request at its waiting timeout. Pages it had already allocated go back only when the prefill ranks acknowledge the cancellation, which a dead prefill process never does, as under early.

Failed decode receive retirement ​

After a receive fails or is cancelled, its destination KV pages stay pinned until every writer acknowledges cancellation or the transport establishes a remote-write fence. A request error alone does not permit reuse. RDMA can revoke a registration; TCP cannot currently provide that guarantee when a Prefill process dies before acknowledging.

You can set --disaggregation-retirement-timeout SECONDS on Decode servers to fail the engine if a cancelled receive remains unfenced for that long. The deadline starts at cancellation or failure, not at request arrival. The timeout never releases unfenced pages, and every member of the attention replica agrees to fail. The existing launcher cleans up the engine's ranks; an external supervisor must restart that complete engine. Other requests on that engine can fail as well, so configure routing, retry behavior, and restart budgets together. If you rely on RDMA revocation first, allow more time than TOKENSPEED_DISAGGREGATION_WAITING_TIMEOUT plus transport cleanup.

Omitting this option preserves the existing wait-for-fence behavior. It does not change fused or Prefill serving, normal request timeouts, or successful cancellation. A ts_decode_retirement_timeout error identifies this recovery cause; it is not a successful cancellation acknowledgement.

TokenSpeed documentation