Skip to main content

1. Quick start

Follow the SGLang Diffusion installation guide for your GPU platform. On CUDA:
Command
The 8-GPU recipe reads its expert-parallel degree from a pipeline configuration file, since ep_size has no CLI flag. Create it before launching:
Command

2. Model capabilities

MAGI-2-preview is a 114B-parameter mixture-of-experts diffusion model from SandAI that generates a video and its synchronized stereo soundtrack in one denoising trajectory. Roughly 6B parameters are active per token, so serving cost tracks the active path far more closely than the 114B total. Generation is text-to-video-and-audio, or image-plus-text-to-video-and-audio (TI2V) when a conditioning image is supplied. Audio is not a second pass over a finished video: the video and audio latents share one packed sequence and one denoise loop.
Review the license and usage terms on the MAGI-2-preview model card before production or commercial use. SGLang support does not grant additional model usage rights.
One root checkpoint holds two DiT partitions, which SGLang loads as separate components rather than as separate model IDs:
PartitionLayersHiddenAttentionMLP
Preview DiT40307224 heads with attention sinks, 4-stream hyper-connections12-head MoE over 256 experts, top-6
Refiner DiT30409632 heads, GQA with 8 query groups, block-window local attention in every layerDense
Use the root model ID sand-ai/MAGI-2-preview. SGLang owns the mapping from that root to the preview weights, refiner weights, video VAE, distilled turbo decoder, and audio VAE. Do not point --model-path at a manually downloaded subdirectory.

Quality tiers

TierDelivered geometryDelivered ratePasses
Preview only896x51212.5 fpsPreview DiT
Two-stage 1080p (default)1920x108825 fpsPreview DiT, then refiner
Both tiers produce a 10-second clip with joint stereo audio at 44100 Hz. The default two-stage tier delivers 249 frames: the preview pass generates at 896x512, and the refiner upsamples to 1920x1088 while halving the temporal VAE stride, which doubles the delivered frame rate. The output canvas is 1088 tall rather than 1080 because the VAE stride forces every spatial dimension to a multiple of 16. Only the two resolutions above are accepted; any other width/height pair is rejected before denoising.

3. Parallelism

MAGI-2 layers two parallel decompositions over the same ranks. Ulysses sequence parallelism spans every rank and shards the packed sequence, and expert parallelism shares those same ranks to split the preview MoE by head. Expert parallelism defaults to the world size, but can be sized below it — which is what makes 8 ranks work, since 8 does not divide the 12 MoE heads. --num-gpus must divide every Ulysses head axis, because a rank owns whole heads on all of them. The MoE heads are sharded by ep_size instead, so they are checked against that. All four are checked at launch rather than deep inside a collective:
AxisCountDivided by
Preview attention heads24--num-gpus
Refiner attention heads32--num-gpus
Refiner key/value heads (GQA)8--num-gpus
Preview MoE heads12ep_size
Divisibility alone does not make a count usable, because the expert weights also have to fit. The 114B headline is the preview partition — 113.9B parameters, 228 GB in BF16 — and only its expert tensors shard; the 6.7B refiner is separate and is replicated on every rank. Measured on 143 GB H200 cards, two-stage 1080p tier, 100 preview plus 5 refiner steps, steady-state clip:
GPUsep_sizeResult
84253s, run eager — see below
44 (default)348s compiled, the recommended default
22689s, requires --dit-layerwise-offload
11out of memory while loading weights
Use 4 GPUs unless you have a reason not to. 8 is 1.37x faster per clip but spends 46% more GPU-time to get there, so it buys latency rather than throughput; 2 and 4 cost the same GPU-seconds per clip. Two concurrent 4-GPU deployments beat one 8-GPU deployment on total output.
6 and 12 GPUs satisfy the preview head axes but fail the refiner’s 8 key/value heads, so they are preview-only counts.8 GPUs divides every Ulysses axis but not the preview’s 12 MoE heads, so it needs an explicit ep_size of 4 — two expert-parallel groups of 4 ranks, each holding all 12 heads. It also wants eager mode: torch.compile regresses the preview pass badly at this rank count (335s compiled against 184s eager). The reference implementation instead pads the head axis to 16 and gives the two spare ranks zero-weight experts; SGLang does not need that padding.
The denoise loop runs both CFG branches itself, so SGLang must not also split CFG across ranks. Passing --enable-cfg-parallel is rejected rather than silently double-applied. Data parallelism (--dp-size greater than 1) and every attention backend other than FlashAttention are also rejected at startup. Tensor parallelism is rejected too. No layer in either DiT is column- or row-parallel, so --tp-size shards nothing and only takes ranks away from Ulysses. Measured at 896x512, 20 steps on 4x H200. These are whole-stage times including per-process warmup, so do not divide them into a per-step cost and compare against the 100-step figures in section 8:
ConfigurationTimePer-rank memory
--ulysses-degree 4124s85 GB
--tp-size 2 --ulysses-degree 2206s120-133 GB
--tp-size 4 --ulysses-degree 1608s135 GB
The memory column is per-rank device memory observed during denoise, which is a different metric from the runtime’s own Max peak quoted in section 8; read the rows against each other, not across sections. The --tp-size rows predate the startup rejection and cannot be reproduced without removing that check. Slower and larger, so put the whole degree in --ulysses-degree.

4. Serve MAGI-2-preview

The recommended four-card launch. Ulysses spans all four ranks, and expert parallelism defaults to that same world size, which divides the 12 MoE heads:
4 GPUs recommended
--performance-mode speed keeps components GPU-resident for lowest latency. Use it only after confirming the workload fits; see the offload section below when it does not. Both DiTs use attention sinks and a packed variable-length attention path that are implemented only on the FlashAttention backend. Sink logits are silently dropped on any other backend, so MAGI-2 restricts itself to FlashAttention and does not accept --attention-backend sage_attn. The first launch downloads the checkpoint. If the repository requires authentication, export a Hugging Face token in the server environment.

5. Generate video and audio

Text only. The defaults already describe the two-stage 1080p tier, so a minimal request changes nothing but the prompt and seed.Pass long prompts inline with --prompt. Do not use --prompt-file-path or --prompt-path for a single long caption: both read a file and split it into one request per non-empty line, which turns a wrapped paragraph into many unrelated short prompts.
Command
To skip loading the refiner weights altogether rather than skipping the pass, turn the refiner off in the pipeline configuration. There is no CLI flag for it; see the configuration notes below.

6. Offload

The preview DiT’s expert weights are the memory driver. There are 256 experts per head across 12 heads in each of 36 MoE layers, and they dominate resident footprint even though only 6 experts per head are active for a given token. When a topology cannot hold them, offload the DiT rather than shrinking the topology. On two cards offload is not optional — the expert weights do not fit without it.
4 GPUs with DiT layerwise offload
--dit-layerwise-offload streams DiT blocks with asynchronous host-to-device prefetch overlap and selects only the DiT layerwise group. Measured at 896x512 over 20 steps, it moves peak from 96202 MiB to 83594 MiB and costs 1.5 s — 13% of peak memory for 1.2% of latency, because the prefetch overlaps transfers with compute. This is the lever to reach for first. Raise --dit-layerwise-resident-layers to pin leading blocks on GPU across denoise steps when VRAM allows; resident layers are transferred once instead of being re-streamed every step, which trades memory for latency more efficiently than raising the prefetch size. --cpu-offload-components dit did not reduce peak on the same measurement (96202 MiB either way): the DiT has to be resident through denoise, so whole-component offload has nothing to move. --performance-mode memory likewise lands within a couple of percent of speed on both time and peak. Neither is a substitute for the layerwise flag here. The Qwen3.5 text encoder is 52 GiB and stays on the host regardless of these flags, and its forward runs there too. Staging it onto a card costs 42-84 s for a 3 s GPU forward against 24 s on the CPU, and the transfer spikes 52 GiB on top of the resident DiTs, which is enough to fail the second request of a run. Only one rank encodes; the embedding is broadcast to the others.
Set PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True when running the two-stage 1080p tier. Both DiTs stay resident through decode, and the 1080p window decode requests a single ~9 GiB block; without expandable segments that allocation fails on fragmentation while tens of GiB sit reserved but unallocated.
DiT layerwise offload and cache-dit are mutually exclusive. With SGLANG_CACHE_DIT_ENABLED set and DiT selected for layerwise offload, SGLang raises rather than running: cache-dit may reuse a skipped block whose weights layerwise offload has already released, which surfaces as a shape mismatch. Disable --dit-layerwise-offload, remove dit from --layerwise-offload-components, or unset SGLANG_CACHE_DIT_ENABLED. DiT layerwise offload also disables FSDP inference, with a warning rather than an error.

7. Configuration notes

  • Only 1920x1088 and 896x512 are accepted. The tier is selected by the requested geometry, not by a separate flag.
  • The clip length is fixed at 10 seconds. num_frames and fps must agree with that duration to within one frame, which is why the default is 249 frames at 25 fps rather than a round 250.
  • 249 is (63 - 1) * 4 + 1. The refiner latent has 63 frames and the turbo decoder is causal, so the first latent yields one frame and each later one yields four.
  • Video and audio carry separate guidance scales, and the refiner carries its own pair. The request defaults are 5.0 and 7.0 for the preview pass, and 2.0 and 5.0 for the refiner. These are request fields, not CLI flags; --guidance-scale sets the video scale only.
  • --num-inference-steps defaults to 100 for the preview pass. Neither DiT is step-distilled, so this dominates wall-clock time. The refiner runs 5 steps.
  • The refiner, the expert-parallel degree, and the distilled turbo decoder are pipeline-configuration fields (enable_refiner, ep_size, use_turbo_vae) with no dedicated CLI flags. Set them by passing a JSON file to --pipeline-config-path, for example {"ep_size": 4} for the 8-card launch. Turning off use_turbo_vae falls back to the video VAE decode path and is a configuration-only change.
  • Audio is delivered as stereo at 44100 Hz. The audio VAE decodes at 51200 Hz and is resampled for the container.
  • The text encoder is a Qwen3.5 hybrid backbone loaded through transformers. Prompts are padded to the longest in the batch and truncated at 7000 tokens.

8. Performance

MAGI-2’s cost is dominated by expert-weight movement and by the packed joint audio-video sequence, both of which depend heavily on GPU model, interconnect, offload policy, and the selected quality tier. Benchmark your own topology before sizing a deployment; the figures below are one data point, not a target. Measured on H200 (143771 MiB each), two-stage 1080p tier, 100 preview steps plus 5 refiner steps, one 10-second clip, seed and prompt held fixed. Each column is that topology’s best configuration, and all are steady state, so the first clip of a process costs more while its graphs build:
Phase2 GPUs4 GPUs8 GPUs
ep_size244
Compileregionalregionalnone
Offloadlayerwisenonenone
Preview denoise (100 steps)590.4 s286.9 s183.9 s
Preview-to-refiner handoff<0.2 s<0.2 s<0.2 s
Refiner denoise (5 steps)79.4 s41.3 s31.6 s
Decode (video and audio)7.1 s8.8 s12.2 s
Total689 s348 s253 s
Peak memory132208 MiB85274 MiB126572 MiB
GPU-seconds per clip137813932028
Read the last row before choosing 8 GPUs: it is 1.37x faster per clip but spends 46% more GPU-time, while 2 and 4 GPUs cost the same GPU-seconds. Decode also moves the wrong way with scale, so latency gains come entirely from denoise. Compile is not a free win at every rank count. At 4 GPUs and below, regional compile is worth roughly a quarter of the clip and 46 GiB of peak, so reach for it first. At 8 GPUs it costs more than it saves — the preview pass measures 335 s compiled against 184 s eager — so leave it off there. Plain --enable-torch-compile without --regional-compile compiles the whole transformer and fails on sm90: inductor autotunes the multi-head MoE GEMMs and asks 262144 bytes of shared memory against the 232448 available. Pair the two flags or use neither. Expect a couple of percent of drift between processes on a shared machine; compare configurations within one run rather than against this table. At the preview-only tier the refiner and the larger decode both drop out, which is most of the clip’s second half. Supplying a conditioning image costs a further 17-24 s at either tier, for the extra 1680 patch tokens. Weight loading is separate and paid once per process: roughly 5 minutes for both DiTs, the expert tensors dominating. Text encoding is not in the table because it tracks prompt length rather than rank count. The encoder runs on the host and its weights are memory-mapped from storage, so a short caption costs about a second once those weights are in the page cache, while a 1900-token caption takes about 24 s. The preview pass — 2.9 s/step on four cards, 1.8 s/step on eight — dominates, so step count is the first knob for trading quality against latency; the refiner’s 5 steps are not worth tuning first.

9. Run in ComfyUI

MAGI-2 has no ComfyUI route. The SGLDiffusion plugin ships no MAGI-2 node and no integrated-mode executor for it. The generic SGLDiffusion Generate Video node has not been validated against this model, and its default request of 1280x720 and 120 frames at 24 fps is rejected by the geometry and clip-length checks in section 7. Use sglang serve or sglang generate directly.