Skip to content

20.11 Serving layouts: one process, replicas, and distributed pools

Serving architecture decides where weights and request state live and which components communicate on every token. Start with a single process and add distribution when memory, load, latency, or recovery requirements justify it. The right layout follows the workload and model, rather than the provider’s product names.

Concepts from other sections (10)

This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.

Learning objectives

  • Compare in-process inference, a local server, replicas, and model-parallel serving.
  • Account for state transfer in prefill/decode disaggregation.
  • Include admission, routing, and failure handling in capacity design.
LayoutWhere state livesWhen it helpsCost or failure boundary
In-process modelApplication process owns weights and cachesDebugging logits, custom training/evaluation, low-concurrency useApp and model share memory and lifecycle
Local HTTP engineOne service process or engine group owns weights and active KVShared API, streaming, concurrent callersSerialization, bounded admission, process restart loses active state
Independent replicasEvery replica has a complete model or model-parallel groupMore aggregate capacity and failoverDuplicated weights; routing affects prefix-cache locality
Tensor parallelWeight matrices and partial activations span devicesModel/layers do not fit or large-batch work benefitsFrequent collective latency and interconnect pressure
Pipeline parallelLayer ranges on different devicesDistribute large weights with fewer cross-stage tensor exchangesPipeline scheduling, bubbles, and request concurrency
Expert parallelExperts across devicesFit and execute MoE weightsToken dispatch, expert imbalance, and all-to-all traffic
Prefill/decode poolsPrompt processing and token generation on different workersIndependently size phases with different bottlenecksTransfer KV, manage ownership, and preserve request/sampling state
Offline batch queueJobs and results are durable outside the engineThroughput-first workloads with relaxed latencyQueue delay and retry/idempotency semantics

A “replica” may use eight GPUs internally. Eight replicas and TP=8 describe very different memory, request routing, and failure behavior. Quantify both independent replica count and devices per replica.

The prefill worker reads the prompt and creates attention state. The decode worker needs the compatible KV blocks, positions, model/adapter revision, request history, and sampler state. If the first output token was already sampled, specify whether it is transferred or sampled by the receiver. Duplicate sampling changes the RNG stream and can duplicate output.

For an illustrative 2 GiB transfer over an effective 50 GB/s path, the byte-only lower bound is about 43 ms. Allocation, packing, queueing, network contention, synchronization, and any retransmission add to it. If the saved prefill/decode interference is smaller, separating the phases can make latency worse. Reusing compatible cached blocks can reduce transfer, but adds cache identity and ownership logic.

This is the tradeoff studied by DistServe. It is a workload-dependent design, not an automatic improvement over colocated execution. The worked disaggregated engine shows block transfer and cleanup; the capacity parts compare bandwidth and synchronization costs.

Routing and admission are part of performance

Section titled “Routing and admission are part of performance”

Route by enough state to avoid hot spots: queued/running work, prompt/output lengths, available cache blocks, compatible prefix residency, and model/adapter identity where the engine exposes them. Pure request-count balancing treats a 100-token request like a 100,000-token one. Prefix-aware routing can reduce prefill but overload a popular replica. Compare load and locality together.

Bound admission and queue depth. Overload should produce a defined response or deadline outcome rather than unbounded waiting. Propagate cancellations so abandoned requests release KV. Define whether retries restart generation; a process failure normally loses ephemeral KV unless the system explicitly replicates or exports it. Retrying a partially streamed request cannot silently promise the original byte stream.

Warm replicas avoid model download, device allocation, compilation, and graph capture delay. Scale on queueing and sustainable goodput with measured startup lead time. GPU utilization alone cannot distinguish a healthy saturated service from one violating every latency target. Include spare capacity for the failure domain the service must survive, such as one worker group or one node.

The Kubernetes deployment reading connects replicas to pods and failure domains. The model release chapter; record artifact compatibility before routing traffic between revisions.

  • Replica: an independently schedulable copy of the serving model, possibly spread across devices.
  • Disaggregation: placing distinct phases or responsibilities in separate worker pools.
  • State ownership: the rule identifying which worker may mutate or release a request’s cache and sampling state.

Count device groups, state transfers, and restart boundaries. Distribution improves a service only when its added communication and coordination fit the workload’s latency and cost budget.

  1. Why can prefix-aware routing improve TTFT and worsen tail latency at the same time?

    AnswerIt can avoid repeated prefill while concentrating popular prefixes on a busy replica, increasing queueing.
  2. What must a KV handoff preserve beyond tensor bytes?

    AnswerModel and adapter identity, positions, block ownership, committed token history, sampler/RNG state, and the first-token convention.