> ## Documentation Index
> Fetch the complete documentation index at: https://docs.m-star.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Wan2.2

> Turn a prompt or first image into a silent MP4.

Wan2.2 TI2V-5B turns text, or text plus a first image, into an MP4. Use this model for silent video. For sound with the same request, choose [LTX-2.5](https://docs.m-star.org/models/ltx2-5.md) or [MiniMax-H3](https://docs.m-star.org/models/minimax-h3.md).

## Install and start

The default uses one GPU. `wan22_dp2.yaml` runs two replicas, while `wan22_cfg_parallel_2gpu.yaml` puts guidance branches on separate GPUs.

### `wan22`

Text, image → video. The default `wan22.yaml` uses 1 GPU. The [weights](https://huggingface.co/Wan-AI/Wan2.2-TI2V-5B-Diffusers) use Apache-2.0.

```bash theme={null}
uv pip install --torch-backend=auto "mstar-ai[wan22]"
mstar serve wan22
```

[Send the request](#generate-video).

## Send a request

Run either client example in a second terminal after `/health` returns 200.

### Generate a clip

These examples save an 81-frame MP4 at 1280×704. To condition it on a first frame, resize the image to exactly 1280×704 before uploading it. Pass the file in `images` with the SDK or as an `image` data URI on `/v1/videos/generations`. If you change the output size, resize the image to match. Both dimensions must be multiples of 32 and the frame count must be of the form `4k + 1`.

**Python SDK**

```python theme={null}
from pathlib import Path
from mstar import MStarClient

client = MStarClient("http://localhost:8000")
reply = client.generate(
    text='A train crosses a stone bridge in mountain fog.',
    output_modalities=('video',),
    height=704,
    width=1280,
    num_frames=81,
)
Path("clip.mp4").write_bytes(next(part["bytes"] for part in reply.raw if part["modality"] == "video"))
```

**curl**

```bash theme={null}
curl -fsS http://localhost:8000/generate \
  --form-string 'text=A train crosses a stone bridge in mountain fog.' \
  --form-string output_modalities=video \
  --form-string streaming=false \
  --form-string 'model_kwargs={"height":704,"width":1280,"num_frames":81}' \
  | python3 -c '
import base64, json, sys

outputs = json.load(sys.stdin)["outputs"]
with open("clip.mp4", "wb") as file:
    for chunk in outputs["video"]:
        file.write(base64.b64decode(chunk["data"]))
'
```

## Deployment configs

| File | GPUs | Parallelism | When to use |
| - | - | - | - |
| `configs/wan22.yaml` | 1 | none | Default. |
| `configs/wan22_cfg_parallel_2gpu.yaml` | 2 | `cfg_size: 2` on the DiT | Lower latency for guided requests: each rank runs one guidance branch. Without guidance both ranks compute the same step. |
| `configs/wan22_dp2.yaml` | 2 | a replica per GPU | Throughput under concurrency; one request takes the one-GPU time. |
| `configs/wan22_cfg2_sp2_4gpu.yaml` | 4 | `cfg_size: 2`, `sp_size: 2` | Lowest latency for one request. Split the guidance branches first, then add `sp_size`. |

`sp_size` must divide the DiT's 24 attention heads.

To use an alternative, pass `--config configs/<file>` after the launcher name. From a wheel installation, [copy the shipped YAML](https://docs.m-star.org/serving.md#custom-configs) and pass its local path.

## Settings and defaults

Requests default to 1280×704 pixels, 81 frames, 50 denoising steps and guidance scale 5. Set `width` and `height` to positive multiples of 32 and match the conditioning image to that exact size. Set `num_frames` to one plus a multiple of four, such as 33 or 81. Use `num_inference_steps` and `guidance_scale` to override the denoising settings.

Set the following deployment options under `model_kwargs` in the config.

| Knob | Default | Effect |
| - | - | - |
| `compile_dit` | `true` | Compile the DiT. Only the shapes in `compile_dit_sizes` run compiled. |
| `compile_dit_sizes` | `["1280x704x81"]` | `WxHxF` shapes that use the compiled DiT, each compiled on first use with and without guidance. Other shapes run eager. |
| `dit_max_batch_size` | `1` | Requests at one latent grid and guidance scale that share a DiT forward. |
| `vae_decode_fast` | `true` | Compiled, channels-last VAE decode for the sizes in `vae_decode_fast_sizes`. |
| `vae_decode_fast_sizes` | `["1280x704"]` | `WxH` sizes the fast decode compiles for. The shipped configs add `832x480`. |
| `vae_decode_tiling` | `auto` | `auto` tiles the VAE decode only when free memory is short; `tiled` or `untiled` forces a path. The `WAN22_VAE_DECODE_TILING` variable overrides it. |
| `max_video_pixels` | `268435456` | Ceiling on `height x width x num_frames`. Larger requests are a 400. |

`backend: sdpa` on the `dit_self_attn` resource runs torch's SDPA instead of the engine's ragged attention.

## Limits

* No video conditioning; `video` in the request body is a 400.
* Each axis must fit the DiT's 1,024 rotary positions (`num_frames` up to 4,093), and height and width are at most 16,384.
* No accelerator-graph capture and no component offload.
* `backend: sdpa` on `dit_self_attn` is refused on SP ranks.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.