Skip to content
SurogateSurogateDocs
↑↓ to move↵ to openesc to close

Dispatch Pipeline Parallelism (dispatch-PP)

Dispatch Pipeline Parallelism lets you train a model whose base weights do not fit on one GPU, on a single PCIe-only multi-GPU machine. It is a model-parallel mode and needs no NVLink or GPU-to-GPU P2P. The data-parallel paths (Multi-GPU / ZeRO) need the base weights to fit on each GPU; dispatch-PP covers the case where they don’t.

The node’s GPUs act as a stateless round-robin compute pool. The model’s transformer blocks are grouped into small contiguous stages, and each stage runs on whichever GPU is next. Its weights stream from pinned CPU memory on demand, and activations and gradients pass from one stage to the next through host memory. A model that runs out of memory under DDP/ZeRO can then train on a box of consumer cards.

Use dispatch-PP when the base model weights alone are larger than one GPU’s memory:

  • ZeRO (even ZeRO-3) can’t train such a model. It rebuilds the full weights with an all-gather during forward/backward, so each GPU has to hold full weight tensors for a moment (see the limitations in Multi-GPU Training).
  • Tensor parallelism is the usual answer, but it needs a fast GPU-to-GPU interconnect.
  • Dispatch-PP needs neither. Stage boundaries cross GPUs through host memory, so it runs on PCIe-only and retail multi-GPU systems without NVLink or P2P.

Validated on:

  • Qwen3.6-27B (~54 GB in BF16, cannot fit on a 32 GB card) trains across 4× 32 GB RTX 5090 with LoRA + FP8 weight streaming.
  • A Qwen3.5-35B-A3B model, from an NVFP4 (compressed-tensors) export, runs GRPO at 131k tokens per row across 8× 32 GB RTX 5090 with stage-local LoRA on the routed and shared experts (see Long sequences).
  • Round-robin stages. Layers are split into small contiguous stages (4 blocks each by default, or an explicit plan). A whole stage stays resident across its microbatches and fits the VRAM budget. Stage s runs on GPU s % gpus, and stages pipeline across the GPUs (N parallel PCIe links). With more stages than GPUs, each GPU interleaves the units of its stages.
  • Per-stage weight streaming. With offload_master (see Offloading), the frozen base weights live in pinned CPU RAM. They stream to the GPU once per step and are reused across all of the step’s microbatches. The trainers size the resident window (SUROGATE_DISPATCH_PREFETCH_BLOCKS) to the layers each GPU runs plus two, so a GPU’s stages stay resident while their units run.
  • Host-staged boundaries. Each stage’s output activations (forward) and input gradients (backward) are copied GPU→host→GPU to the next stage. There is no NCCL or P2P on the hot path, which is why it works without NVLink.
  • Bounded memory. Activation memory is one stage’s worth, and resident base weights are one GPU’s stages. Only the small LoRA adapters stay resident and get optimized, each GPU holding the adapters of its own stages (stage-local LoRA). Peak memory is independent of model depth.

A minimal dispatch-PP run (all keys are in the config reference):

yaml
parallelism: dispatch_pp # opt in to model-parallel mode
offload_master: true # stream the frozen base from pinned CPU per block (required)
gpus: 4 # the round-robin GPU pool
recipe: fp8_hybrid # or bf16
lora: true # frozen base + trained adapters (the supported mode)
lora_rank: 16
lora_alpha: 32
lora_target_modules: [q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj]
KeyMeaning
parallelism: dispatch_ppEnables the mode. Mutually exclusive with ZeRO sharding, cpu_training, and MoE expert parallelism.
offload_master: trueStreams the frozen base weights from pinned CPU per block. Required for models that can’t sit resident; the same scheduler runs without it for models that fit.
gpus#Size of the round-robin pool. More GPUs pipeline more stages concurrently for throughput. gpus: 1 also works (single-GPU streaming).
recipe#bf16 or fp8_hybrid (see below). The online NVFP4 recipe is deferred; a pre-quantized NVFP4 checkpoint loads under bf16 (see Constraints).
gradient_accumulation_steps#Microbatch count — see Effective batch.
SUROGATE_DISPATCH_STAGE_BLOCKS#Env var; blocks per stage (default 4). Larger stages mean fewer cross-stage handoffs but more resident VRAM per stage.
SUROGATE_DISPATCH_STAGE_PLAN#Env var; explicit stage sizes, comma-separated, summing to the layer count (e.g. 6,5,5,5,5,5,5,4). Overrides SUROGATE_DISPATCH_STAGE_BLOCKS, for example to give the stage that also runs the lm-head fewer blocks. A plan may have more stages than GPUs: one task per GPU then interleaves the units of all its stages, taking whichever ready stage is furthest behind.
SUROGATE_DISPATCH_LORA_LOCAL#Env var; 1 (set by both trainers unless already set): stage-local LoRA. 0 replicates every adapter on every GPU.
SUROGATE_DISPATCH_PREFETCH_BLOCKS#Env var; the resident weight window in layers. Both trainers set it to the most layers any GPU runs plus two; the GRPO trainer keeps a value you set yourself, the SFT trainer always sets it. The window must hold all of a GPU’s stages, or each stage re-streams its weights for every microbatch.
sequence_chunks#Runs each row as windows of sequence_len / sequence_chunks tokens through every stage. See Long sequences.

With SUROGATE_DISPATCH_LORA_LOCAL=1 (the default under dispatch-PP), each GPU allocates, trains and checkpoints only the adapters of the stages it runs (stage s on GPU s % gpus). Replicated LoRA (0) keeps every layer’s adapter on every GPU, collects every stage’s gradients on GPU 0, runs the optimizer there and copies the weights back to all GPUs through the host.

  • What it saves. Adapter weights, gradients and optimizer state for the other GPUs’ layers, plus the host round trip on every step. On Qwen3.5-35B-A3B at 131k with expert LoRA (8× RTX 5090), the peak per card goes from 27.3 to 23.9 GB at r8, and r16, out of memory replicated, fits at 24.5 GB. At 4k the r16 train step goes from 5.2 to 1.65 s.
  • What stays the same. Log-probs and exported adapters match the replicated run bit for bit, and grad norms to 6e-7. The LoRA grad norm is summed across the GPUs inside the step, and every GPU applies its own update.
  • Files. The exported adapter is one PEFT file: rank 0 writes the tensors that every rank contributes. A checkpoint holds that adapter plus the optimizer state as one file per rank, and a resume reproduces the next steps exactly.
  • When to use it. Always, with the SFT and GRPO trainers. Only the native API’s one-step-stale mode (dispatch_pp_train_step_multigpu(stale=True), which the trainers do not use) needs replicated LoRA. The stage plan is part of the adapter layout: keep SUROGATE_DISPATCH_STAGE_PLAN (or SUROGATE_DISPATCH_STAGE_BLOCKS) fixed for a run and its resumes. The dispatch-PP entry points refuse a plan whose layers would run on a GPU that does not hold their adapters.

sequence_chunks: N runs each row as N windows of sequence_len / N tokens. Every window passes through every stage, and each stage carries the row’s chunk state from window to window on its own GPU: the attention K/V of the earlier windows, plus the Gated DeltaNet state and conv tails of hybrid models (kept in FP32). Gradients are exact. The backward walks each row’s windows last to first and accumulates dK/dV. A row only costs the windows up to its last target; later windows are skipped in every stage and pass.

yaml
sequence_len: 131072
sequence_chunks: 32 # 32 windows of 4,096 tokens
per_device_train_batch_size: 1
single_sample_bins: true # GRPO: one sample per row (chunked attention has no packed-doc isolation)
lora_dropout: 0.0
  • Requirements. The same as for chunked training in general: per_device_train_batch_size: 1, lora_dropout: 0 and BF16 attention. CUDA graphs are off under dispatch-PP anyway.
  • Chunk state for the backward. Each stage needs a row’s chunk state again before it runs that row’s windows backward, but by then the forward of the later rows has overwritten it. A GRPO log-prob pass that keeps its boundaries also copies each row’s chunk state to pinned host memory, and the train step copies it back. That budget is SUROGATE_DISPATCH_CHUNK_SNAPSHOT_GIB per GPU (default 4; about 0.74 GB per 131k row for a stage with two attention layers). Rows past the budget, and steps without a kept log-prob pass, re-run the stage over the earlier windows instead (SUROGATE_DISPATCH_KV_SWEEP=1 forces that). Both give bit-identical results.
  • Attention backward. The kv-prefix attention backward sums each dQ element over its key blocks in a fixed order (ordered dQ), so chunked steps are bit-reproducible run to run.
  • Memory. The stack also reserves the attention backward’s dK/dV expansion over the whole row: about 2 GiB at 131k.

Production setting on 32 GB cards (a Qwen3.5-35B-A3B model’s NVFP4 export, 8× RTX 5090, GRPO), with the base loaded as described in QLoRA: compressed-tensors NVFP4:

yaml
model: <path to the NVFP4 checkpoint> # pre-quantized base, see QLoRA: compressed-tensors NVFP4
recipe: bf16
parallelism: dispatch_pp
offload_master: true
gpus: 8
sequence_len: 131072
sequence_chunks: 32
single_sample_bins: true
pad_to_multiple_of: 4096
lmhead_chunks: 32
per_device_train_batch_size: 1
lora: true
lora_rank: 16
lora_alpha: 32
lora_dtype: fp32 # see "Adapter precision" below
lora_dropout: 0.0
lora_target_modules: [gate_proj, up_proj, down_proj]
recompute: false
qlora_recompute: false
fp8_weight_cache: off
bash
export SUROGATE_DISPATCH_STAGE_PLAN=6,5,5,5,5,5,5,4 # the lm-head stage keeps one attention layer
export SUROGATE_DISPATCH_PREFETCH_BLOCKS=6 # resident window = the largest stage
export SUROGATE_DISPATCH_LORA_LOCAL=1
32k64k131k
Warm step, 2 rows (log-prob pass + train step)5.48 s11.23 s29.53 s (8,876 tok/s)

The step times were measured with bf16 LoRA; fp32 LoRA steps take the same time.

  • GPU memory. Peaks at 131k are 28.4-30.5 GB per card with bf16 LoRA and 28.8-31.1 GB with fp32 LoRA (the fullest cards keep about 1.5 GB free).
  • Host memory. About 77 KB per token of a dispatch call (see GRPO steps), on top of the pinned base.
  • End to end. A GRPO step of ten 131k rows (1.3M tokens, two dispatch calls, teacher_from_base on, fp32 LoRA) took 186 s.

The stage plan is the setting that matters most. With 8 stages on 8 GPUs, the 6-block first stage and the 4-block lm-head stage balance the critical path. A 16-stage plan (two stages per GPU) needs about 2 GB less memory per card at 131k, but it is not faster at 32-64k.

Dispatch-PP on the 27B is transfer-bound: streaming the base weights over PCIe takes most of each step. With recipe: fp8_hybrid (see Precision & recipes), the frozen matmul base weights are quantized to FP8-E4M3 once, at load, and streamed as FP8. That halves the bytes on the wire and feeds the FP8 GEMM directly. Only the matmul weights are quantized. Conv, norm, A_log and other non-matmul parameters stay BF16, so those kernels lose no precision.

  • The step is ~1.45× faster on the 27B (4× RTX 5090, seq 2048) than with BF16 streaming.
  • Loss matches: FP8-E4M3 base quantization is near-lossless. It also halves the pinned host RAM needed for the base.
  • Set recipe: bf16 to disable and stream BF16 weights.

A dispatch-PP step runs M = gpus × gradient_accumulation_steps microbatches, all accumulated into one optimizer step:

Effective batch = gpus × per_device_train_batch_size × gradient_accumulation_steps

The weight stream costs the same per step, because each stage streams once and every microbatch reuses it. Raising gradient_accumulation_steps spreads that cost over more tokens and keeps the pipeline fuller (fewer bubbles) with no extra peak memory. It sets both your effective batch and your throughput.

GRPO drives the two halves of a dispatch-PP step itself. A staged forward through the loss stage returns the per-token log-probs, Python forms the GRPO per-token gradients from them, and the staged backward is seeded with those gradients. They are normalized by the step’s loss tokens (loss_scale), as on the standard path; the optimizer applies no second token scale. With teacher_from_base: true each call first runs the same pass with the LoRA delta off; its log-probs are the rows’ teacher log-probs (a KL anchor to the base weights, loss.teacher_tau).

The log-prob pass keeps every stage’s output boundary in host memory, so the training step over the same rows skips its own forward (SUROGATE_DPP_REUSE_FORWARD=0 turns this off). A call holds these boundaries until its training step ends: about 77 KB per token of its rows on the 35B-A3B at 131k (57 KB of boundaries over 8 stages, ~20 KB of chunk states). Freed blocks stay in a pinned pool for the next call (SUROGATE_PINNED_POOL_GIB, default 32). A step with more tokens than fit runs as several calls, each with its own log-prob pass and staged backward. The gradients accumulate on the stages’ GPUs and one optimizer update follows the last call, so the step trains exactly as one call would.

Env varMeaning
SUROGATE_DPP_CALL_TOKENS#Tokens per call; a row counts the windows up to its last target. Unset: half of the host’s available memory (MemAvailable) at the start of the step, at SUROGATE_DPP_HOST_BYTES_PER_TOKEN bytes per token (default 120000).

Adapter precision. Use lora_dtype: fp32 (the GRPO default) for expert LoRA. Precision & recipes explains the trade-off. The adapter’s gradients are kept in lora_dtype and summed over every window of every row in the step. With bf16 the running sum is rounded after each window. On a 1.04M-token step whose advantages largely cancel, as a GRPO group’s do, the bf16-summed expert gradient was 41 % off the FP32 one (cosine 0.93); the shared-expert A matrices fared worst. BF16 masters also drop updates smaller than half a bf16 ulp, so at GRPO learning rates the A matrices barely move. FP32 adds 0.6-0.7 GB per card at 131k on the 35B-A3B.

broadcast_dtype: bf16 (the default) writes weight broadcasts as the FP32 masters rounded to BF16 (round to nearest even): the PEFT layout and size of a bf16 adapter (2.53 GB for r16 on the 35B-A3B’s experts), which is what a BF16 serving engine loads. Checkpoints keep the FP32 masters. broadcast_dtype: master broadcasts them as stored.

  • LoRA with a frozen base is the supported training mode. Full fine-tuning runs with M = 1 (cross-microbatch gradient accumulation for FFT is not wired up yet).
  • Can’t be combined with ZeRO sharding (zero_level > 1, shard_weights, shard_gradients), cpu_training, or MoE expert parallelism (ep_size > 1).
  • CUDA graphs are turned off automatically, because per-stage weight streaming can’t be captured.
  • Recipes: bf16 or fp8_hybrid. The online NVFP4 recipe for stage streaming is deferred: the 4-bit base hurts convergence on this architecture, and the block-scaled transpose cancels out the byte savings. A pre-quantized NVFP4 checkpoint loads as the base under recipe: bf16: its experts stream as NVFP4 and are dequantized to BF16 on the GPU (QLoRA).
  • recompute: true (the dispatch default) bounds activation memory by replaying each stage’s forward during the backward pass. recompute: false keeps the stage re-forward’s activations instead, which saves one block forward per backward window (131k: 44.4 -> 37.8 s per step); with a QLoRA or pre-quantized base it also needs qlora_recompute: false.
  • One-step-stale updates (native API only) need replicated LoRA (SUROGATE_DISPATCH_LORA_LOCAL=0).
  • Chunked sequences need per_device_train_batch_size: 1 and lora_dropout: 0.

A complete config for Qwen3.6-27B on 4× 32 GB GPUs ships at examples/sft/qwen35/qwen36-text-lora-fp8-pp.yaml.

yaml
model: Qwen/Qwen3.6-27B
gpus: 4
per_device_train_batch_size: 1
gradient_accumulation_steps: 8 # M = gpus*GA = 32 microbatches/step
sequence_len: 2048
recipe: fp8_hybrid # FP8 weight streaming (half the PCIe bytes)
parallelism: dispatch_pp
offload_master: true # stream the frozen base from pinned CPU
lora: true
lora_rank: 16
lora_alpha: 32
lora_target_modules: [q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj]