SGLang 推出 EPD 分离架构,为视觉语言模型提供弹性编码器扩容
EPD Disaggregation: Elastic Encoder Scaling for Vision-Language Models in SGLang - LMSYS Org
LMSYS 在 SGLang 中推出 Encoder-Prefill-Decode(EPD)分离架构,将视觉编码从语言处理中拆出,编码器可独立横向扩容,并支持 ZMQ、Mooncake 等传输后端与视觉嵌入向量缓存。在 8× H20、Qwen2.5-VL-72B、每请求约 4 张 1080p 图像的测试中,图像密集场景下 1 QPS 时 TTFT 比同机部署低约 6–8 倍,0.8–1.0 QPS 吞吐约翻倍;图像较少的场景则可能因跨节点传输嵌入向量而变慢。
正文
当前显示原文,中文全文译文尚未就绪。
Contents
TL;DR
We introduce Encoder-Prefill-Decode (EPD) Disaggregation in SGLang, a novel architecture that separates vision encoding from language processing in Vision-Language Models (VLMs). This can enable:
Independent scaling of vision encoding capacity: Encoder servers can be scaled horizontally without affecting language model deployment, enabling better resource utilization for vision-heavy workloads; Compatibility with existing PD disaggregation: EPD can be combined with Prefill-Decode disaggregation for a complete three-tier architecture; Flexible transfer backends: Support for multiple transfer mechanisms (ZMQ, GPU-direct via Mooncake) allows optimization for different deployment scenarios; Vision embedding caching: Frequently used images can be cached at encoder servers, eliminating redundant ViT computations and reducing network transfer overhead
EPD is highly effective in image-heavy scenarios (e.g., multi-image inputs), where the visual encoding process is the primary computational bottleneck. For instance, in these scenarios, we leverage EPD to significantly reduce request TTFT under load—achieving approximately 6–8× lower latency compared to the colocation approach at 1 QPS. Conversely, for image-light scenarios with few images, EPD may be less efficient or even counterproductive. This is because the additional network latency incurred by transmitting embeddings across nodes can outweigh the time saved by offloading the encoding task, potentially resulting in a higher TTFT compared to a colocation approach.
Introduction
Vision-Language Models (VLMs) like Qwen2.5-VL and Llama-Vision combine visual understanding with language generation. However, these models face unique scaling challenges:
Heterogeneous compute needs: Vision encoding (CNN/ViT) requires different computational patterns than language decoding (Transformer); Imbalanced resource usage: Vision processing is compute-intensive but only needed during prefill; Limited flexibility: Traditional monolithic deployments can't independently scale vision and language components; Intra-request parallelism: Different images in one request can be encoded independently; Poor scaling under tensor parallelism: Because the vision encoder has far fewer parameters than the language component, applying tensor parallelism to it is inefficient and generally unnecessary
SGLang's existing Prefill-Decode (PD) disaggregation already separates prefill from decode phases. EPD extends this by further separating vision encoding from language prefill, creating a three-tier architecture.
The Counter-Intuitive Finding
One of the key insights from EPD disaggregation is that Vision Transformers (ViT) do NOT benefit from increased Tensor Parallelism, and can actually become slower with higher TP:
Benchmark on H20 with Qwen2.5-VL-72B (4 images per request):
Why Does This Happen?
Communication overhead dominates execution time; The weight parameters of vision models are usually small
EPD sidesteps this by scaling encoders horizontally instead of increasing TP.
Architecture Overview
The EPD architecture follows a request flow:
Client Request: A multimodal request arrives at the prefill server (via load balancer or direct connection); Image Distribution: The prefill server identifies image inputs and distributes them to one or more encoder servers. Images can be split across multiple encoders for load balancing; Vision Encoding: Encoder servers process images through ViT, generating vision embeddings and image grid metadata. Results are cached if enabled; Embedding Transfer: Vision embeddings are transferred back to the prefill server using the configured transfer backend (ZMQ, Mooncake, etc.); LLM Computation: The prefill server combines vision embeddings with text tokens to form mm_inputs containing pre-computed tensors. The LLM performs Prefill and Decode computation based on these embeddings. If PD disaggregation is enabled, the existing Prefill-Decode transfer logic is reused; otherwise, token generation happens directly on the prefill server
Key Components
Encoder Server (--encoder-only)
Vision-only (no language weights); preprocessing + ViT forward to generate vision embeddings; Prefix multimodal cache support; Scale out for load balancing and parallel multi-image split inference
Prefill Server (--language-only)
Language model only; Receives embeddings from encoder(s); With PD: ships KV to Decode; without PD: decodes locally
Decode Server
Standard decode-only instance; Receives KV cache from prefill
Implementation Details
Image Distribution Strategies
Unlike tensor parallelism which splits a single model across GPUs, EPD uses data parallelism by running multiple independent encoder instances and distributing images among them.
Example distribution:
Transfer Backends
EPD supports three transfer backends for vision embeddings:
zmq_to_scheduler (Default)
Direct ZMQ socket communication; Embeddings sent from encoder to scheduler via RDMA transfer engine; No blocking
zmq_to_tokenizer
Embeddings sent to tokenizer manager; Processed during tokenization phase
mooncake
RDMA-based transfer for multi-node; Registers embeddings in shared memory; High-bandwidth, low-latency transfer
Vision Embedding Cache
The encoder supports prefix multimodal caching to avoid redundant ViT computations:
Eliminates redundant vision encoding; Reduces latency for repeated images; Configurable cache size (default 4GB via SGLANG_VLM_CACHE_SIZE_MB)
Usage Examples
To launch the encoder instance
To launch the prefill instance
To launch the decode instance
To launch minlb
Benchmark
EPD disaggregation targets vision-heavy workloads (multi-image requests) and improves Time To First Token (TTFT) by scaling encoder servers horizontally. Launch bench script:
Experimental Setup
Environment: 8× H20 96GB GPUs
Dataset: Random multimodal dataset
Text tokens: 128 / 256; Images per request: 1-8 images (random count, average ~4 images); Image resolution: 1080p; QPS range: 0.2-1.0
Deployment Configurations:
Colocate: 1 PD instance with tensor-parallel-size=4, uses 4× H20 GPUs; 1E1P (1 Encoder + 1 PD instance): 1 Encoder with tensor-parallel-size=1 + 1 PD instance with tensor-parallel-size=4, uses 5× H20 GPUs; 2E1P (2 Encoders + 1 PD instance): 2 Encoders with tensor-parallel-size=1 each + 1 PD instance with tensor-parallel-size=4, uses 6× H20 GPUs
The higher TPOT observed in 2e1p is attributed to its larger batch size during decoding.
Request Throughput (EPD vs colocate)
Key Findings (vs. colocate)
Encoder/prefill keeps TTFT much lower under load (≈6–8x lower than colocate at 1 qps); TPOT stays far below colocate (≈8–10x lower), indicating much tighter latency; Throughput roughly doubles at higher QPS (≈2x at 0.8–1.0 qps vs. colocate); The dramatic reduction in TTFT is achieved by allocating dedicated GPU resources to the encoder. Despite using 50% additional GPUs (2E1P uses 6× H20 vs. colocate's 4× H20), EPD disaggregation achieves a much higher return on investment (ROI) compared to simply scaling the traditional integrated architecture, with performance gains exceeding the additional resource cost; While highly effective for image-heavy tasks, dedicated encoder GPUs may experience lower utilization (idle time) in image-light scenarios, suggesting that EPD is most resource-efficient when visual processing is the primary bottleneck
Acknowledgment
rednote hilab: Tianyu Guo, a'du, Tianming Xu
AntGroup SCT: Wengang Zheng
Learn more
Roadmap: Encoder Disaggregation (2025 Q4)