1. Quick start
Follow the SGLang Diffusion installation guide for your GPU platform. On CUDA:Command
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. One root checkpoint holds two DiT partitions, which SGLang loads as separate components rather than as separate model IDs:| Partition | Layers | Hidden | Attention | MLP |
|---|---|---|---|---|
| Preview DiT | 40 | 3072 | 24 heads with attention sinks, 4-stream hyper-connections | 12-head MoE over 256 experts, top-6 |
| Refiner DiT | 30 | 4096 | 32 heads, GQA with 8 query groups, block-window local attention in every layer | Dense |
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
| Tier | Delivered geometry | Delivered rate | Passes |
|---|---|---|---|
| Preview only | 896x512 | 12.5 fps | Preview DiT |
| Two-stage 1080p (default) | 1920x1088 | 25 fps | Preview DiT, then refiner |
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:
| Axis | Count | Divided by |
|---|---|---|
| Preview attention heads | 24 | --num-gpus |
| Refiner attention heads | 32 | --num-gpus |
| Refiner key/value heads (GQA) | 8 | --num-gpus |
| Preview MoE heads | 12 | ep_size |
| GPUs | ep_size | Result |
|---|---|---|
| 8 | 4 | 253s, run eager — see below |
| 4 | 4 (default) | 348s compiled, the recommended default |
| 2 | 2 | 689s, requires --dit-layerwise-offload |
| 1 | 1 | out of memory while loading weights |
--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:
| Configuration | Time | Per-rank memory |
|---|---|---|
--ulysses-degree 4 | 124s | 85 GB |
--tp-size 2 --ulysses-degree 2 | 206s | 120-133 GB |
--tp-size 4 --ulysses-degree 1 | 608s | 135 GB |
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
- T2VA
- TI2V
- Preview-only tier
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
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.
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_framesandfpsmust 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-scalesets the video scale only. --num-inference-stepsdefaults 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 offuse_turbo_vaefalls 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:| Phase | 2 GPUs | 4 GPUs | 8 GPUs |
|---|---|---|---|
ep_size | 2 | 4 | 4 |
| Compile | regional | regional | none |
| Offload | layerwise | none | none |
| Preview denoise (100 steps) | 590.4 s | 286.9 s | 183.9 s |
| Preview-to-refiner handoff | <0.2 s | <0.2 s | <0.2 s |
| Refiner denoise (5 steps) | 79.4 s | 41.3 s | 31.6 s |
| Decode (video and audio) | 7.1 s | 8.8 s | 12.2 s |
| Total | 689 s | 348 s | 253 s |
| Peak memory | 132208 MiB | 85274 MiB | 126572 MiB |
| GPU-seconds per clip | 1378 | 1393 | 2028 |
--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 genericSGLDiffusion 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.