页面简介
正文摘录
Split a monolithic text-to-video/image pipeline into independent Encoder, Denoiser, and Decoder roles, each running on its own GPU(s). A central DiffusionServer routes requests through the pipeline. To place arbitrary consecutive stage groups from a deployment file instead of these preset roles, see the experimental stage deployments. Quick Start Disaggregation is controlled by a single flag: --disagg-role. Each component is launched independently, just like LLM PD disaggregation. —disagg-roleWhat it runsmonolithic(Default) Standard single-server modeencoderAll stages with the default RoleType.ENCODER affinity: InputValidationStage, TextEncodingStage (plus ImageEncodingStage / ImageVAEEncodingStage for image-conditioned pipelines), LatentPreparationStage, TimestepPreparationStage, and any model-specific “before denoising” stage (e.g. QwenImageLayeredBeforeDenoisingStage, GlmImageBeforeDenoisingStage).prompt_encoder / image_encoderSeparate text and reference-image encoding stages (currently FLUX.3 Image).denoiserDenoisingStage (and its subclasses: CausalDMDDenoisingStage, DmdDenoisingStage, LTX2AVDenoisingStage, LTX2RefinementStage, Hunyuan3DShapeDenoisingStage, …) — the DiT forward loop plus the scheduler stepping it drives.decoderDecodingStage (VAE decode) and its subclasses (LTX2AVDecodingStage, HeliosDecodingStage, …).serverDiffusionServer head node + HTTP server (no GPU) Each stage declares its role via the role_affinity property on PipelineStage (default ENCODER). Non-monolithic pipelines only instantiate matching stages. The combined encoder role also includes stages with PROMPT_ENCODER or IMAGE_ENCODER affinity. Single-Machine Example (Verified) The following commands have been tested end-to-end on an 8×H200 machine with Wan-AI/Wan2.1-T2V-1.3B-Diffusers. Each role runs on a separate GPU via --base-gpu-id; the server head node requires no GPU. # Terminal 1: Encoder (GPU 0) sglang serve --model-path Wan-AI/Wan2.1-T2V-1.3B-Diffusers \ --disagg-role encoder \ --disagg-server-addr tcp://127.0.0.1:19655 \ --scheduler-port 19000 --master-port 19100 \ --num-gpus 1 --base-gpu-id 0 # Terminal 2: Denoiser (GPU 1) sglang serve --model-path Wan-AI/Wan2.1-T2V-1.3B-Diffusers \ --disagg-role denoiser \ --disagg-server-addr tcp://127.0.0.1:19655 \ --scheduler-port 19001 --master-port 19101 \ --num-gpus 1 --base-gpu-id 1 # Terminal 3: Decoder (GPU 2) sglang serve --model-path Wan-AI/Wan2.1-T2V-1.3B-Diffusers \ --disagg-role decoder \ --disagg-server-addr tcp://127.0.0.1:19655 \ --scheduler-port 19002 --master-port 19102 \ --num-gpus 1 --base-gpu-id 2 # Terminal 4: DiffusionServer head (no GPU, receives HTTP requests) sglang serve --model-path Wan-AI/Wan2.1-T2V-1.3B-Diffusers \ --disagg-role server \ --encoder-urls "tcp://127.0.0.1:19000" \ --denoiser-urls "tcp://127.0.0.1:19001" \ --decoder-urls "tcp://127.0.0.1:19002" \ --host 0.0.0.0 --port 22000 \ --scheduler-port 19655 # Send request (video generation) curl http://127.0.0.1:22000/v1/videos \ -H "Content-Type: application/json" \ -d '{"model": "Wan-AI/Wan2.1-T2V-1.3B-Diffusers", "prompt": "A curious raccoon exploring a garden, cinematic", "size": "832x480"}' Tested result (8×H200): Encoder 2.3 s (TextEncoding) → Denoiser 312.8 s (50 steps, layerwise offload) → Decoder 7.1 s (VAE decode). Total ~322 s for 81-frame 1024×1024 video. Tip: --base-gpu-id controls which physical GPU the role uses. Encoder and Decoder can share a GPU (e.g. both --base-gpu-id 0) to save resources, but make sure the combined GPU memory is sufficient. Multi-Machine Example The exact same CLI pattern — just replace 127.0.0.1 with actual IPs and add RDMA flags for direct transfer: # Machine A (10.0.0.1): Encoder sglang serve --model-path Wan-AI/Wan2.1-T2V-14B-Diffusers \ --disagg-role encoder \ --disagg-server-addr tcp://10.0.0.4:19655 \ --scheduler-port 19000 \ --num-gpus 1 \ --disagg-p2p-hostname 10.0.0.1 --disagg-ib-device mlx5_0 # Machine B (10.0.0.2): Denoiser (4 GPUs with SP) sglang serve --model-path Wan-AI/Wan2.1-T2V-14B-Diffusers \ --disagg-role denoiser \ --disagg-server-addr tcp://10.0.0.4:19655 \ --scheduler-port 19001 \ --num-gpus 4 --denoiser-sp 4 --denoiser-ulysses 2 --denoiser-ring 2 \ --disagg-p2p-hostname 10.0.0.2 --disagg-ib-device mlx5_0 # Machine C (10.0.0.3): Decoder sglang serve --model-path Wan-AI/Wan2.1-T2V-14B-Diffusers \ --disagg-role decoder \ --disagg-server-addr tcp://10.0.0.4:19655 \ --scheduler-port 19002 \ --num-gpus 1 \ --disagg-p2p-hostname 10.0.0.3 --disagg-ib-device mlx5_0 # Machine D (10.0.0.4): DiffusionServer head sglang serve --model-path Wan-AI/Wan2.1-T2V-14B-Diffusers \ --disagg-role server \ --encoder-urls "tcp://10.0.0.1:19000" \ --denoiser-urls "tcp://10.0.0.2:19001" \ --decoder-urls "tcp://10.0.0.3:19002" \ --host 0.0.0.0 --port 30000 \ --scheduler-port 19655 \ --disagg-dispatch-policy max_free_slots ZMQ handles startup order gracefully — instances and head can start in any order. FLUX.3 split encoding FLUX.3 Image supports both the three-role topology above and four independently deployable worker pools: T2I: HTTP head -> prompt_encoder -> denoiser -> decoder -> HTTP head i2i: HTTP head -> prompt_encoder -> image_encoder -> denoiser -> decoder -> HTTP head The prompt encoder loads only the text encoder. The image encoder loads only the VAE for reference-image encoding; the decoder has its own VAE instance. The denoiser loads only the DiT and creates noise from the request seed locally. T2I bypasses the image encoder and goes directly from prompt encoder to denoiser. Stages within one request run sequentially; different requests can occupy different worker pools concurrently. This is not a latency optimization for a single request: separation adds transfers and allows independent placement and scaling. The head still serves complete image-generation requests; this is not a standalone API for returning training embeddings or VAE latents. Use the same FLUX.3 package, variant, and numerical settings on every process. Each host currently needs a complete package on disk, even though a worker loads only its own components into memory. Follow the FLUX.3 cookbook for model access and licensing. For gated checkpoints, authenticate on each host with an authorized account using hf auth login, or provide an accessible local package path. Install the transfer dependencies described below on every worker. For long prompts, increase --disagg-transfer-pool-size on the encoding and denoising workers to cover their largest incoming/outgoing tensors, as well as reserved receive slots; for example, 1073741824 reserves a 1 GiB pool. For a Linux NVIDIA deployment with four GPUs, start the workers in one shell: MODEL_PATH=black-forest-labs/flux-3-image-klein for spec in 'prompt_encoder 0 19000' 'image_encoder 1 19010' \ 'denoiser 2 19020' 'decoder 3 19030'; do read -r ROLE GPU WORK_PORT <<< "$spec" CUDA_VISIBLE_DEVICES="$GPU" sglang serve --model-path "$MODEL_PATH" \ --num-gpus 1 --disagg-role "$ROLE" \ --disagg-server-addr tcp://127.0.0.1:18000 \ --disagg-p2p-hostname 127.0.0.1 \ --scheduler-port "$WORK_PORT" --master-port "$((WORK_PORT + 50))" & done Then start the GPU-less head in another shell: sglang serve --model-path black-forest-labs/flux-3-image-klein \ --disagg-role server --host 127.0.0.1 --port 30000 --scheduler-port 18000 \ --prompt-encoder-urls tcp://127.0.0.1:19000 \ --image-encoder-urls tcp://127.0.0.1:19010 \ --denoiser-urls tcp://127.0.0.1:19020 \ --decoder-urls tcp://127.0.0.1:19030 The existing image API is unchanged: use /v1/images/generations for T2I and multipart /v1/images/edits for references: curl --fail-with-body -sS http://127.0.0.1:30000/v1/images/generations \ -H 'Content-Type: application/json' \ -d '{"prompt":"A sunset over mountains","size":"1024x1024","seed":42,"response_format":"b64_json"}' \ -o flux3-t2i.json curl --fail-with-body -sS http://127.0.0.1:30000/v1/images/edits \ -F 'image=@reference.png' \ -F 'prompt=Turn the scene into a watercolor painting' \ -F 'seed=42' -F 'response_format=b64_json' \ -o flux3-i2i.json Replace reference.png with your input image. Omit size on edits to keep the reference dimensions, including the model’s padding/crop behavior. The head inlines locally uploaded reference files before dispatch, so GPU workers do not need access to the head’s upload directory. URL inputs must remain reachable from the image encoder. Specify both --prompt-encoder-urls and --image-encoder-urls, instead of --encoder-urls. Each accepts semicolon-separated worker endpoints, with the same dispatch policy as the existing pools. Alternatively, use the existing encoder role and --encoder-urls to colocate both encoders in one worker. Image encoder and decoder processes can also share a GPU if their combined weights, transfer pools, and concurrent activations fit. Across machines, replace loopback addresses with routable IPs. Advertise each worker’s IP with --disagg-p2p-hostname, and use that exact work endpoint in the head’s URL list. The head also listens on scheduler port +4 for prompt encoder results and +5 for image encoder results; +1/+2/+3 retain their existing meanings. Keep worker work/control ports (+1), internal scheduler ports, and distributed master ports distinct. Run the internal transport on a trusted private network, not a public interface. The BF16 flow-map package has been validated on H200 with same-node, multi-process Mooncake RDMA: concurrent T2I, reference-size-preserving i2i, and both three-role and four-role topologies matched the monolithic API’s output pixels with quality=exact. Cross-node execution has not been validated. Multiple Instances per Role Use semicolons in --*-urls to register multiple instances: # 2 encoders + 2 denoisers (4-GPU SP each) + 1 decoder sglang serve --model-path ... --disagg-role server \ --encoder-urls "tcp://10.0.0.1:35000;tcp://10.0.0.2:35000" \ --denoiser-urls "tcp://10.0.0.3:35000;tcp://10.0.0.4:35000" \ --decoder-urls "tcp://10.0.0.5:35000" GLM-Image distributed mode GLM-Image