94057c3d3e
PR Test (NPU) / check-changes (push) Has been cancelled
PR Test (NPU) / pr-gate (push) Has been cancelled
PR Test (NPU) / set-image-config (push) Has been cancelled
PR Test (NPU) / stage-b-test-1-npu-a2 (0) (push) Has been cancelled
PR Test (NPU) / stage-b-test-1-npu-a2 (1) (push) Has been cancelled
PR Test (NPU) / stage-b-test-2-npu-a2 (0) (push) Has been cancelled
PR Test (NPU) / stage-b-test-2-npu-a2 (1) (push) Has been cancelled
PR Test (NPU) / stage-b-test-4-npu-a3 (push) Has been cancelled
PR Test (NPU) / stage-b-test-16-npu-a3 (push) Has been cancelled
PR Test (NPU) / multimodal-gen-test-1-npu-a3 (push) Has been cancelled
PR Test (NPU) / multimodal-gen-test-2-npu-a3 (push) Has been cancelled
PR Test (Arm64) / pr-gate (push) Has been cancelled
PR Test (Arm64) / check-changes (push) Has been cancelled
PR Test (Arm64) / build-test (push) Has been cancelled
PR Test (sgl-router) / gate (push) Has been cancelled
PR Test (sgl-router) / tier-1 — lint (push) Has been cancelled
PR Test (sgl-router) / tier-2 — build + test (push) Has been cancelled
PR Test (sgl-router) / tier-3 — docker (placeholder) (push) Has been cancelled
PR Test (sgl-router) / tier-3 — k8s integration (push) Has been cancelled
PR Test (sgl-router) / tier-3 — e2e (push) Has been cancelled
PR Test (sgl-router) / finish (push) Has been cancelled
PR Test (NPU) / single-node-poc (map[name:qwen3_6_27b_w8a8_1p_in64k_out1k_50ms runner:linux-aarch64-a3-2 test_case:test/registered/ascend/performance/qwen3_6_27b/test_npu_qwen3_6_27b_w8a8_1p_in64k_out1k_50ms.py test_type:perf]) (push) Has been cancelled
PR Test (NPU) / pr-test-npu-finish (push) Has been cancelled
PR Test (Xeon) / pr-gate (push) Has been cancelled
PR Test (Xeon) / check-changes (push) Has been cancelled
PR Test (Xeon) / build-test (, xeon-gnr, base-b-test-cpu) (push) Has been cancelled
PR Test (XPU) / check-changes (push) Has been cancelled
PR Test (XPU) / pr-gate (push) Has been cancelled
PR Test (XPU) / stage-a-test-1-gpu-xpu (push) Has been cancelled
PR Test (XPU) / wait-for-stage-a (push) Has been cancelled
PR Test (XPU) / stage-b-test-1-gpu-xpu (push) Has been cancelled
PR Test (XPU) / finish (push) Has been cancelled
CI Model Inventory / build-inventory (push) Has been cancelled
Lint / lint (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark Compilation Check (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark - Manual Policy (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark - Request Processing (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark Summary (push) Has been cancelled
PR Test (SMG) / build-wheel (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on windows (x86_64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on macos (x86_64 - auto) (push) Has been cancelled
PR Test (SMG) / python-unit-tests (push) Has been cancelled
PR Test (SMG) / unit-tests (push) Has been cancelled
PR Test (SMG) / benchmarks (push) Has been cancelled
PR Test (SMG) / chat-completions (push) Has been cancelled
PR Test (SMG) / chat-completions-4gpu (push) Has been cancelled
PR Test (SMG) / e2e (push) Has been cancelled
PR Test (SMG) / docker-build-test (push) Has been cancelled
PR Test (SMG) / k8s-integration (push) Has been cancelled
PR Test (SMG) / finish (push) Has been cancelled
PR Test (SMG) / summarize-benchmarks (push) Has been cancelled
Release SGLang Model Gateway Docker Image / publish (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on macos (aarch64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (aarch64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (x86_64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (aarch64 - musllinux_1_1) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (x86_64 - musllinux_1_1) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / Build SDist (push) Has been cancelled
Release SGLang Model Gateway to PyPI / Upload to PyPI (push) Has been cancelled
Release SGLang Kernels / build-cu129-matrix (aarch64, 12.9, 3.10, arm-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / build-cu129-matrix (x86_64, 12.9, 3.10, x64-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / release-cu129 (push) Has been cancelled
Release SGLang Kernels / build-cu130-matrix (aarch64, 13.0, 3.10, arm-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / build-cu130-matrix (x86_64, 13.0, 3.10, x64-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / release-cu130 (push) Has been cancelled
Release SGLang Kernels / build-rocm-matrix (3.10, 700) (push) Has been cancelled
Release SGLang Kernels / build-rocm-matrix (3.10, 720) (push) Has been cancelled
Release SGLang Kernels / release-rocm700 (push) Has been cancelled
Release SGLang Kernels / release-rocm720 (push) Has been cancelled
Release SGLang Kernels / build-musa43 (43, 3.10) (push) Has been cancelled
Release SGLang Kernels / release-musa43 (push) Has been cancelled
198 lines
7.5 KiB
Plaintext
198 lines
7.5 KiB
Plaintext
---
|
||
title: "EPD Disaggregation"
|
||
metatags:
|
||
description: "SGLang EPD disaggregation: separate encoder, prefill, decode stages for VLM inference. Independent scaling, load balancing, three-tier architecture."
|
||
---
|
||
## Why and What is EPD Disaggregation?
|
||
|
||
In modern Vision-Language Model (VLM) inference, request execution naturally decomposes into three distinct stages: Encoder, Prefill, and Decode.
|
||
The Encoder stage performs vision preprocessing and ViT-based image encoding, which is highly compute-intensive but only required during request initialization. The Prefill stage processes the full multimodal input sequence to initialize the language model’s Key-Value (KV) cache, while the Decode stage is dominated by memory bandwidth and KV cache access for autoregressive token generation.
|
||
|
||
Existing deployments typically colocate these stages within a unified execution engine, or at best apply Prefill–Decode (PD) disaggregation. However, such designs still tightly couple vision encoding with language prefill, leading to inefficient resource utilization, limited scalability for image-heavy workloads, and suboptimal scheduling under load.
|
||
|
||
To address these challenges, we introduce Encoder–Prefill–Decode (EPD) Disaggregation in SGLang. EPD further separates vision encoding from language processing, enabling independent horizontal scaling of encoder servers, improved load balancing for multimodal requests, and seamless integration with existing PD disaggregation to form a fully decoupled three-tier inference architecture.
|
||
|
||
### Usage
|
||
|
||
You can launch a language-only model using `--language-only`, or an encoder-only model using `--encoder-only`.
|
||
When launching a language-only model, you must additionally specify the encoder service endpoints via `--encoder-urls`.
|
||
|
||
We support multiple encoder transfer backends, including zmq_to_scheduler, zmq_to_tokenizer, and mooncake (the default is zmq_to_scheduler). The backend can be selected using `--encoder-transfer-backend`.
|
||
|
||
### Encoder transfer with Mooncake
|
||
|
||
`--encoder-transfer-backend mooncake` controls **how encoder outputs are transferred** between encoder and language/prefill services. It is an encoder transfer option and can be used independently of the global multimodal embedding cache.
|
||
|
||
Example:
|
||
|
||
```bash Command
|
||
# encoder
|
||
python -m sglang.launch_server \
|
||
--model-path Qwen/Qwen3-VL-8B-Instruct \
|
||
--encoder-only \
|
||
--encoder-transfer-backend mooncake \
|
||
--port 30000
|
||
|
||
# language-only server
|
||
python -m sglang.launch_server \
|
||
--model-path Qwen/Qwen3-VL-8B-Instruct \
|
||
--language-only \
|
||
--encoder-urls http://127.0.0.1:30000 \
|
||
--encoder-transfer-backend mooncake \
|
||
--port 30002
|
||
```
|
||
|
||
### Global multimodal embedding cache with Mooncake
|
||
|
||
SGLang also supports a Mooncake-backed **global multimodal embedding cache** for EPD workloads. When enabled on encoder servers, repeated image inputs can reuse previously computed ViT embeddings across instances instead of running the vision encoder again.
|
||
|
||
This feature is useful when:
|
||
|
||
- the deployment serves repeated or overlapping image inputs,
|
||
- encoder compute is the bottleneck, and
|
||
- Mooncake is already available in the cluster.
|
||
|
||
At a high level, the encoder checks whether the image embedding already exists in Mooncake. Cache hits are prefetched from the global store, while misses are encoded normally and inserted into the cache in the background.
|
||
|
||
To enable it:
|
||
|
||
- install and configure Mooncake in the same way as other SGLang Mooncake integrations,
|
||
- add `--enable-mm-global-cache` on the encoder server.
|
||
|
||
`--enable-mm-global-cache` controls **whether multimodal embeddings are looked up and stored in the global Mooncake cache**. It is separate from `--encoder-transfer-backend`, which only controls encoder output transport.
|
||
|
||
For Mooncake deployment and configuration details, see [HiCache best practices](./hicache_best_practices#deployment-with-mooncake) and the [Mooncake backend README](https://github.com/sgl-project/sglang/blob/main/python/sglang/srt/mem_cache/storage/mooncake_store/README.md).
|
||
|
||
Example:
|
||
|
||
```bash Command
|
||
# Shared Mooncake configuration
|
||
export MOONCAKE_TE_META_DATA_SERVER="http://127.0.0.1:8080/metadata"
|
||
export MOONCAKE_MASTER="127.0.0.1:50051"
|
||
export MOONCAKE_PROTOCOL="rdma"
|
||
export MOONCAKE_GLOBAL_SEGMENT_SIZE="4gb"
|
||
|
||
# encoder with global multimodal cache enabled
|
||
python -m sglang.launch_server \
|
||
--model-path Qwen/Qwen3-VL-8B-Instruct \
|
||
--encoder-only \
|
||
--enable-mm-global-cache \
|
||
--port 30000
|
||
|
||
# language-only server
|
||
python -m sglang.launch_server \
|
||
--model-path Qwen/Qwen3-VL-8B-Instruct \
|
||
--language-only \
|
||
--encoder-urls http://127.0.0.1:30000 \
|
||
--port 30002
|
||
```
|
||
|
||
Notes:
|
||
|
||
- This cache is for **multimodal encoder embeddings**, not the language model KV cache.
|
||
- The feature currently uses Mooncake as the shared backing store.
|
||
- It can be enabled regardless of which `--encoder-transfer-backend` you use.
|
||
- It is most relevant for EPD or encoder-disaggregated VLM deployments where the same images are likely to appear across requests or instances.
|
||
|
||
#### Qwen VL
|
||
|
||
- EP Disaggregation
|
||
|
||
```bash Command
|
||
# encoder 0
|
||
python -m sglang.launch_server \
|
||
--model-path Qwen/Qwen3-VL-8B-Instruct \
|
||
--encoder-only \
|
||
--encoder-transfer-backend zmq_to_scheduler \
|
||
--port 30000
|
||
# encoder 1
|
||
python -m sglang.launch_server \
|
||
--model-path Qwen/Qwen3-VL-8B-Instruct \
|
||
--encoder-only \
|
||
--encoder-transfer-backend zmq_to_scheduler \
|
||
--port 30001
|
||
# language-only server
|
||
python -m sglang.launch_server \
|
||
--model-path Qwen/Qwen3-VL-8B-Instruct \
|
||
--language-only \
|
||
--encoder-urls http://127.0.0.1:30000 http://127.0.0.1:30001 \
|
||
--encoder-transfer-backend zmq_to_scheduler \
|
||
--port 30002
|
||
```
|
||
|
||
- EPD Disaggregation
|
||
|
||
```bash Command
|
||
# encoder 0
|
||
python -m sglang.launch_server \
|
||
--model-path Qwen/Qwen3-VL-8B-Instruct \
|
||
--encoder-only \
|
||
--encoder-transfer-backend zmq_to_scheduler \
|
||
--port 30000
|
||
# encoder 1
|
||
python -m sglang.launch_server \
|
||
--model-path Qwen/Qwen3-VL-8B-Instruct \
|
||
--encoder-only \
|
||
--encoder-transfer-backend zmq_to_scheduler \
|
||
--port 30001
|
||
# prefill 0
|
||
python -m sglang.launch_server \
|
||
--model-path Qwen/Qwen3-VL-8B-Instruct \
|
||
--disaggregation-mode prefill \
|
||
--language-only \
|
||
--encoder-urls http://127.0.0.1:30000 http://127.0.0.1:30001 \
|
||
--encoder-transfer-backend zmq_to_scheduler \
|
||
--port 30002
|
||
# decode 0
|
||
python -m sglang.launch_server \
|
||
--model-path Qwen/Qwen3-VL-8B-Instruct \
|
||
--disaggregation-mode decode \
|
||
--port 30003
|
||
# router
|
||
python -m sglang_router.launch_router \
|
||
--pd-disaggregation \
|
||
--prefill http://$PREFILL_HOST:30002 \
|
||
--decode http://$DECODE_HOST:30003 \
|
||
--port 8000
|
||
|
||
```
|
||
|
||
#### gRPC Encoder (EPD)
|
||
|
||
You can run the encoder as a gRPC server while keeping prefill/decode as HTTP.
|
||
When using gRPC encoders, set `SGLANG_ENCODER_MM_RECEIVER_MODE=grpc` for the
|
||
prefill process so it uses the gRPC receiver.
|
||
|
||
```bash Command
|
||
# gRPC encoder
|
||
python -m sglang.launch_server \
|
||
--model-path Qwen/Qwen3-VL-8B-Instruct \
|
||
--encoder-only \
|
||
--grpc-mode \
|
||
--encoder-transfer-backend zmq_to_scheduler \
|
||
--port 30000
|
||
|
||
# prefill (HTTP) - tell it to use gRPC receiver
|
||
SGLANG_ENCODER_MM_RECEIVER_MODE=grpc \
|
||
python -m sglang.launch_server \
|
||
--model-path Qwen/Qwen3-VL-8B-Instruct \
|
||
--disaggregation-mode prefill \
|
||
--language-only \
|
||
--encoder-urls grpc://127.0.0.1:30000 \
|
||
--encoder-transfer-backend zmq_to_scheduler \
|
||
--port 30002
|
||
|
||
# decode (HTTP)
|
||
python -m sglang.launch_server \
|
||
--model-path Qwen/Qwen3-VL-8B-Instruct \
|
||
--disaggregation-mode decode \
|
||
--port 30003
|
||
|
||
# router
|
||
python -m sglang_router.launch_router \
|
||
--pd-disaggregation \
|
||
--prefill http://$PREFILL_HOST:30002 \
|
||
--decode http://$DECODE_HOST:30003 \
|
||
--port 8000
|
||
```
|