Skip to main content

Overview

Prefill-Decode (PD) Disaggregation separates LLM inference into two specialized instances:
  • Prefill instance: Handles computation-intensive prompt processing
  • Decode instance: Handles memory-intensive token generation
This separation eliminates interference between phases and enables tailored optimizations for each.

Why PD Disaggregation?

Traditional unified engines that process prefill and decode together suffer from two key inefficiencies:

Problem 1: Prefill Interruption

Incoming prefill batches frequently interrupt ongoing decode batches, causing substantial delays in token generation.

Problem 2: DP Attention Imbalance

In data-parallel attention, one DP worker may process prefill while another handles decode simultaneously, leading to increased decode latency.

Solution: Disaggregation

With PD disaggregation:
Benefits:
  • No prefill interruption of decode batches
  • Balanced DP attention workloads
  • Independent optimization per phase
  • Better resource utilization

Architecture

Request Flow

Prefill Instance Lifecycle

  1. Bootstrap Queue:
    • Initialize sender for each request
    • Handshake with decode instance
    • Pre-allocate KV cache on decode side
    • Move to Waiting Queue once complete
  2. Waiting Queue:
    • Pop requests for prefill forward pass
    • Process through model
    • Move to Inflight Queue
  3. Inflight Queue:
    • Non-blocking poll of transfer status
    • Return request once KV cache transfer completes

Decode Instance Lifecycle

  1. Prealloc Queue:
    • Initialize receiver for each request
    • Handshake with prefill instance
    • Pre-allocate KV cache slots
    • Move to Transfer Queue
  2. Transfer Queue:
    • Poll receiver for transfer status
    • Move to Waiting Queue once transfer completes
  3. Waiting Queue:
    • Construct PrebuiltExtendBatch
    • Populate metadata (skip prefill forward)
  4. Running Batch:
    • Merge resolved batch into running batch
    • Execute decode forward passes

Transfer Backends

SGLang supports multiple KV cache transfer backends:

Configuration

Basic Setup with Mooncake (Single Node)

Installation:
Launch servers:

Multi-Node Setup (DeepSeek-V3)

Transfer Backend Details

Mooncake

Requirements:
Features:
  • RDMA-based high-performance transfers
  • NVLink support (recommended for NVL72)
  • Custom memory pools for optimized transfers
NVLink Transport:
Supported memory pools:
  • NVLINK (or True): NVLink transport
  • BAREX: BAR expansion
  • INTRA_NODE_NVLINK: Intra-node NVLink
Environment Variables: Prefill Server: Decode Server: Example (relaxed timeouts for high TTFT):

NIXL

Installation:
Or build from source (if UCX is pre-installed):
Single Node:
Multi-Node: (same as Mooncake, replace --disaggregation-ib-device with --disaggregation-transfer-backend nixl) Backend Selection:

Ascend NPU

Requirements: Option 1: Memfabric Hybrid
Option 2: Mooncake
Set NPU Physical ID (required in containers):
Single Node:
Multi-Node (DeepSeek):

Combining with Other Parallelism

PD + TP + DP + EP (Full Stack)

Recommended production setup for DeepSeek-V3:

PD + Pipeline Parallelism

See Pipeline Parallelism for PP tuning details.

Router Integration

SGLang Model Gateway provides load balancing and fault tolerance for PD disaggregation: Multiple prefill/decode instances:
See SGLang Model Gateway - PD Disaggregation for advanced routing policies.

Profiling

To profile prefill or decode workers separately:
See Benchmark and Profiling Guide for details.

Configuration Summary

Best Practices

  1. Use Mooncake for multi-node deployments with InfiniBand/RoCE
  2. Enable NVLink transport for NVL72 deployments
  3. Set appropriate timeouts based on your TTFT requirements
  4. Use router for load balancing across multiple instances
  5. Monitor transfer bandwidth to ensure optimal performance
  6. Profile instances separately using profiling flags
  7. Combine with DPA + EP for DeepSeek models

Troubleshooting

Transfer Timeout

Symptom: Requests timing out during KV cache transfer Solution: Increase timeouts:

Bootstrap Connection Failed

Symptom: Decode instance can’t connect to prefill bootstrap server Solution: Check network connectivity and IB device:

Low Transfer Bandwidth

Symptom: Slow KV cache transfers Solution: Enable NVLink transport (if available):
Or increase thread pool size:

Memory Cleanup Issues

Symptom: Memory not released after decode instance disconnects Solution: Adjust cleanup interval:

Performance Tips

  1. Use RDMA (InfiniBand/RoCE) for multi-node transfers
  2. Enable NVLink for intra-node high-bandwidth transfers
  3. Tune thread pool size based on available CPU cores
  4. Adjust queue size for concurrent transfer batches
  5. Monitor heartbeat failures to detect network issues early
  6. Use multiple decode instances with router for high availability