Skip to main content
Start with the deployment examples. This page describes the experimental --stage-deployment path; the existing --disagg-role interface is documented under preset roles.

Deployment fields

--stage-node starts every local replica assigned to that label. For replica index i, the base GPU is base_gpu_id + i * num_gpus. Each replica has its own model components, transfer pool, and internal scheduler/master ports. Same-checkpoint workers inherit explicit parent settings and resolve automatic parallelism and placement for their own GPU count. A role specifying server_args.model_path instead builds a fresh model configuration and inherits only disagg_* transport settings; put its precision, backend, and placement overrides in that role’s server_args. Mixed-checkpoint deployments require explicit top-level stage contracts, with matching factories in each selected pipeline. Stage names remain unique across the deployment. For an individually managed role, use its registered endpoint:
This worker uses its own CLI settings, not roles.denoiser.server_args. Do not also run a node launcher for the same endpoint. Stage deployment does not combine with preset --disagg-role, --dp-size > 1, or --batching-max-size > 1; use endpoint replicas for concurrency.

Declaring stage boundaries

Expose stage_specs on the pipeline class, or supply the equivalent contracts in the deployment’s top-level stages array.
  • Stage names must be nonempty, unique, and match add_stage / add_stage_factory exactly, including case. An unnamed add_stage uses its Python class name. Prefer stable semantic names for new contracts.
  • Indices select from the full ordered contract list before role filtering. Names and indices may be mixed, but a stage may only be assigned once. Negative/out-of-range indices and booleans are rejected. "0" is a name.
  • Grouping does not reorder stages. Inserting or reordering contracts changes indices; use names when configurations must survive pipeline updates.
  • Component names must match the pipeline’s module keys. Custom loaders must honor the selected component set, and factories must avoid constructing unselected stages.
Model transforms belong in stages. File saving and HTTP formatting remain at the output boundary. Standard decoding exposes a separate postprocessing stage; specialized decoders need an accurate contract before splitting their internals. See supporting new models for pipeline integration.

Automatic sequential mode

When no stage declares inputs or outputs, every boundary transfers the request context. All stages must be placed, each role must contain consecutive stages, and the original sequential order is preserved. The codec extracts nested tensors, including scheduler tensors, for tensor transport. It also preserves generator state and model-specific request fields. Root tracing, metrics, and model modules remain process-local. Request module maps and nested model modules are rejected. This removes field-by-field payload definitions, not every integration requirement. Custom runtime objects must be serializable; hidden mutable state in a stage instance is not migrated. General overlapping-view/storage aliasing is not guaranteed. Full-context mode does not infer parallel branches or their merge semantics.

Explicit-field graph mode

Use explicit contracts when independent branches need to run concurrently or when you want to minimize transfer volume. Data dependencies still apply when after=(). Reads bind to the latest preceding writer. The stage list must be topologically ordered, and grouping must leave an acyclic role graph. A role cannot supply an earlier version of a field that it overwrites later; split that role instead. Field paths refer to request fields, extra.<key>, or result.<field>. Declared payloads contain tensors and JSON-safe metadata; keep generators, schedulers, modules, and CUDA events local in this mode. Unsupported required fields fail instead of silently disappearing. A stage returning OutputBatch exposes it to later stages. When replacing the output, declare both the request field output and terminal result.output as appropriate. Automatic mode defaults to result.output; explicit mode defaults to the produced result.* fields unless outputs is set.

Parallel-branch placement example

After implementing the matching stage_specs and factories shown in the parallel encoder example, a five-GPU placement could be:
Role names have no scheduling semantics: the contracts define the dependencies. text, image, and vae are independent; generate joins their outputs; output waits for generation. These are illustrative names, not built-in stage aliases or a Wan configuration.

Transport and ports

The coordinator’s --scheduler-port serves internal requests behind HTTP. Worker stage endpoints are explicit. The preset-role result-port offsets (scheduler_port + 1 through +5) are not the stage-deployment protocol. Workers advertise transfer sessions over control RPC, then move tensor data directly through Mooncake. The HTTP coordinator receives the terminal result; it does not relay intermediate GPU tensors. Node launch selects distinct internal scheduler/master ports; external orchestration must reserve them explicitly when launching workers individually. Kernel implementations stay in stages/models. Custom communication engines integrate through the existing transfer-engine factory; both endpoints must obey its registration, buffer ownership, and completion contract.

Memory, failures, and numerics

  • Size transfer pools for simultaneous incoming and outgoing tensors. Retained results own copies of tensor storage so reusable model buffers cannot corrupt earlier requests. Budget those copies in addition to weights and activations.
  • Fan-out results remain leased until consumers finish or the lease expires. An unacknowledged transfer quarantines its receive slot rather than allowing a late sender to overwrite a new request. Resolve the transport error and restart an exhausted worker.
  • Admission and pending work are bounded. Errors propagate to callers; cancellation cleans up pending graph work and late results but does not preempt a running GPU kernel or denoising loop.
  • This is not a durable queue. Failed inference is not automatically replayed, and hosts/resources are not provisioned by the launcher.
  • Each worker serializes computation. Use replicas for concurrent requests; this path does not enable per-worker dynamic batching.
  • TP/SP apply within each worker group. Boundary tensors are complete tensors, not arbitrary shards; incompatible layouts need explicit gather/reshard stages or colocation.
  • Stateful loops and encode-while-decode streaming must stay inside a compatible role. They cannot be split into independently retried operations.
  • The reported peak is the maximum per-worker reserved memory, not the sum of multiple processes sharing one GPU.
For zero-tolerance comparison, match attention backend, precision, numerical flags, and the parallel layout of every stage, including VAE decoding. Automatic VAE memory format can depend on the worker’s local GPU count. Set SGLANG_DIFFUSION_VAE_CHANNELS_LAST_3D consistently to true or false for the baseline and all workers; identical latents alone do not guarantee identical decoded pixels.