Skip to main content
A pipeline defines computation. A deployment decides where it runs. Group consecutive stages into roles, place each role on GPUs, and serve the complete pipeline through one HTTP endpoint. Tensor payloads move directly between workers; the coordinator schedules work and returns the result. Disaggregation lets you place and scale stages independently. It adds communication and is not inherently faster for a single request.

Choose a deployment

Declarative deployment is experimental and opt-in. Pipelines need accurate stage/component declarations and compatible loaders/factories. A placement file does not make every monolithic pipeline splittable. Automatic context transfer currently supports consecutive groups, not automatic parallel-branch merging.

Prerequisites

  • Linux with NVIDIA GPUs and a working SGLang Diffusion installation.
  • Mooncake on every GPU worker: pip install mooncake-transfer-engine. Cross-machine GPU transfers also need a working RDMA fabric.
  • The same SGLang version, model package/revision, and compatible numerical settings on every process. Authenticate for gated models on each host.
  • A trusted private network. Internal RPC uses Python serialization and must not be exposed to untrusted clients.
The examples below use Wan-AI/Wan2.1-T2V-1.3B-Diffusers. The three-group split and mixed TP/SP execution have been validated on H200. Other models need their own exact stage names and component declarations.

Single-machine example

Start here: one encoder, one denoiser, and one decoder on three GPUs.

1. Define stages and placement

Save the following as deployment.json. These are actual Wan pipeline stage names, not aliases. Names and zero-based indices can be mixed. Stages keep their original pipeline order.
deployment.json
No stage declares field-level inputs or outputs, so the framework carries the request context across each boundary, including nested tensors, scheduler state, and generator state. You do not need to list every embedding or mask. Each worker loads only its declared components.

2. Start workers and the coordinator

Run each tab’s command in a separate terminal from the directory containing deployment.json.
This launches all roles assigned to node1 as separate processes, with unique internal scheduler/master ports. It does not start the HTTP API.

3. Send a smoke request

Wait for workers to finish loading, then use the existing generation API:
This small request checks the complete path, not production video quality. Image pipelines use the same coordinator with /v1/images/generations or /v1/images/edits; see the HTTP API.

Multi-machine example

Keep the stage list unchanged and move the same roles onto two machines: Replace the example private addresses below with your routable worker addresses. Create deployment-multi.json from the working single-machine file:
Copy the same generated file to both machines. In each terminal below, cd to its directory first. Replace mlx5_0 with that host’s RDMA device.
Node launch is local process launch, not SSH provisioning. Internal endpoints and Mooncake session addresses must be mutually reachable. Keep advertised stage ports, internal scheduler ports, and distributed master ports distinct.

Configure TP and SP per role

Use the multi-machine manifest above, but give the denoiser four GPUs for TP2 x Ulysses2. This variant uses three GPUs on node A and four on node B: encoder TP2 on node A GPUs 0-1, decoder on node A GPU 2, and denoiser on all four node B GPUs.
Restart all three terminals from the previous example with --stage-deployment deployment-tp-sp.json. Use the same file on both hosts. TP/SP run within a role’s worker group; they do not split pipeline stages between roles. Model head-count and sharding constraints still apply. This is a validated topology, not a claim that it is faster than pure SP for every workload. See parallelism for tuning.

Scale a role with replicas

Replicas serve different requests. They are not a TP or SP group. For four GPUs on one machine, start from deployment.json and give the denoiser two independent one-GPU replicas:
Launch workers and the coordinator as in the single-machine example, replacing the filename with deployment-replicas.json. The node launcher places encoder on GPU 0, the denoiser replicas on GPUs 1 and 2, and decoder on GPU 3. It advances each replica’s base GPU by that role’s num_gpus. The coordinator defaults to round_robin. To prefer a worker with free capacity, add --disagg-dispatch-policy max_free_slots to the coordinator. Each worker executes one request at a time; replica dispatch is not per-worker dynamic batching.

Parallel encoders

Text encoding, an image/VLM encoder, and VAE encoding can run as independent branches only when their actual data dependencies permit it: This requires explicit field contracts; automatic full-context transfer does not merge parallel branches. For example:
These are schematic stage names and fields, not a runnable declaration for an arbitrary model. The pipeline must register matching stage factories, produce/consume these fields, and keep non-transferable runtime state local. Assign each branch to a different role in the placement file; the coordinator runs independent branches concurrently and waits for their results at the join. See the stage deployment reference for a matching placement example, field semantics, and integration requirements.

Encoder-only pools

A deployment can stop at encoding: no denoiser or decoder is required. Use explicit contracts with named tensor outputs, and list those fields in outputs. Each role can have its own checkpoint and replica count. For example, this three-GPU deployment pairs two Z-Image text encoders with one FLUX.2 Klein VAE encoder. It returns the pipelines’ existing conditioning tensors, not a new representation:
encoder-pools.json
Launch the workers and coordinator in separate terminals:
EncodingClient talks to the coordinator’s private scheduler endpoint, not its HTTP port. It selects a pool by role name and pulls named results directly from the selected workers onto the caller’s GPU:
Input URLs or paths must be readable by the workers; image data URLs also work. Do not send client-local filesystem paths unless they are shared. Across machines, replace loopback endpoints with routable private addresses and set --disagg-p2p-hostname on workers and hostname= on the client. Transport requires the same Mooncake setup as other stage deployments.

Bounded prefetch

Use a lazy iterable and a scoped prefetch stream for repeated requests:
Results retain input order. depth bounds lookahead in addition to the current consumer-owned result; max_in_flight bounds active encode calls across the client. Exiting either scope cancels pending work and releases remote result leases. Errors propagate without silently skipping or retrying samples. The consumer must yield the event loop (or run blocking work in another thread) for prefetch to progress; this does not guarantee GPU compute overlap. outputs=[...] narrows exported fields. Without role, it selects deployment outputs and runs their dependency graph; with role, it selects that role’s exports and executes only that role and its required ancestors. Automatic full-context boundaries cannot be used as named encoder outputs. These are frozen, inference-only encoders: no cross-process autograd is provided. Hidden-layer selection, VAE posterior sampling, scaling, packing, and preprocessing remain model-stage semantics. Validate those against the consumer’s expected tensors; separating a stage does not change its semantics.

Before serving production traffic

  • Warm up through the coordinator. Stage workers skip standalone warmup. Send representative shapes and input modes, including to every replica.
  • Budget memory per worker. Weights, activations, retained result copies, and transfer pools all consume memory. Sharing a GPU does not share weights.
  • Compare like-for-like. Match precision, attention backend, each stage’s parallelism, and VAE memory format before judging numerical differences.
  • Plan for errors. Admission is bounded, but this is not a durable queue. Cancellation cleans up pending work; it does not interrupt a running kernel.
Continue with the stage deployment reference for fields, ports, transport options, and limitations, or the preset roles for the existing CLI-only path.