Choose a deployment
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.
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 asdeployment.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
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 containingdeployment.json.
- GPU workers
- HTTP coordinator
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:/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. Createdeployment-multi.json from the working single-machine file:
cd to its directory first. Replace mlx5_0 with that host’s RDMA device.
- Node A workers
- Node B workers
- Coordinator on node A
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.--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 fromdeployment.json and give the
denoiser two independent one-GPU replicas:
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: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 inoutputs. 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
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:
--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: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.
