Wan2.1
Checkpoint and dependencies
Section titled “Checkpoint and dependencies”Use Wan-AI/Wan2.1-I2V-14B-720P-Diffusers or
Wan-AI/Wan2.1-I2V-14B-480P-Diffusers. The Diffusers layout includes
model_index.json and the transformer, text_encoder,
tokenizer, image_encoder, image_processor, vae, and scheduler
directories. Original Wan .pth checkpoints cannot be loaded directly.
Install PyTorch, torch_npu, Diffusers 0.43.0, Transformers, ftfy, and
sentencepiece. Text conditioning uses the UMT5 SentencePiece tokenizer,
image conditioning uses CLIP, and denoising uses the checkpoint’s UniPC
flow-matching configuration.
Server configuration
Section titled “Server configuration”Use this four-device TP2/SP2 configuration once the checkpoint is available:
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3export MODEL_PATH=/path/to/Wan2.1-I2V-14B-720P-Diffusersexport XLLM_BINARY=/path/to/xllmexport OMP_NUM_THREADS=8export HCCL_BUFFSIZE=256
python -m xllm.launch_server serve --binary-path="$XLLM_BINARY" \ --nnodes=4 --backend=dit --model="$MODEL_PATH" --model_id=wan21-i2v \ --model_impl=python --tp_size=2 --sp_size=2 --cfg_size=1 --vae_size=1 \ --text_encoder_tp_size=1 --max_requests_per_batch=1 \ --enable_graph=false --enable_rolling_load=false \ --dit_laser_attention_enabled=false --dit_sparse_attention_enabled=false \ --master_node_addr=127.0.0.1:19885 --host=127.0.0.1 --port=8000 \ --max_body_size=2147483648 --logtostderr=trueSet --model_impl=libtorch to use the libtorch pipeline. The Python pipeline
uses dense eager execution. TP shards attention
and FFN weights; SP shards video tokens. TP * SP must divide the 40
attention heads, and TP must divide the FFN width. Set CFG, DP, VAE, and text
encoder TP to 1. The VAE encodes the full spatial extent in FP32; only the
driver performs decoding after denoising.
Request contract
Section titled “Request contract”POST /v1/video/generation uses the existing video generation protocol:
input.promptand optionalinput.negative_promptare encoded in the server.input.media_sourcescontains exactly one Base64 or binary image source withname="image"andmodality="image".- Optional
input.prompt_embedandinput.negative_prompt_embedaccept floating point UMT5 features of shape[512, 4096], including zero-padded text tokens. The server adds the batch dimension. - Suggested parameters are
num_frames=81,fps=16,num_inference_steps=50,guidance_scale=5.0,max_sequence_length=512,num_videos_per_prompt=1, andseed=42. For 720P, usesize="1280*720"andflow_shift=5.0. For 480P, usesize="832*480"andflow_shift=3.0.
Height and width must be positive multiples of 16. Frames are aligned to
floor(num_frames / 4) * 4 + 1. The request controls flow_shift; omitting it
retains xLLM’s default of 1.0. Results use the existing MP4 encoding and
Base64/binary response contract. This model does not generate audio.
Cache-DiT
Section titled “Cache-DiT”Python Wan2.1 I2V supports Cache-DiT for both 480P and 720P. Install
cache-dit==1.5.1 when building from source; the NPU Docker requirements
already include it. python setup.py install does not install dependencies.
Cache-DiT is disabled by default and requires resident weights and eager execution.
Enable it with --enable_cache_dit=true. --cache_dit_config=/path/to/cache.json
sets service defaults; for example:
{ "Fn_compute_blocks": 1, "Bn_compute_blocks": 0, "max_warmup_steps": 8, "residual_diff_threshold": 0.12, "max_continuous_cached_steps": 2, "enable_taylorseer": true, "taylorseer_order": 1}Each request can override parameters.enable_cache_dit and individual fields
of parameters.cache_dit_params. Explicit false and zero values are preserved.
Fn_compute_blocks must be at least 1, and the sum of Fn and Bn cannot exceed
40 blocks. max_continuous_cached_steps=0 forces full computation;
-1 removes the continuous-hit limit.
The adapter uses Cache-DiT’s Pattern_2 contract. Positive and negative CFG
branches share weights and the first self-attention computation, with separate
residual and TaylorSeer histories. Histories reset for every request, and cache
decisions use global TP/SP statistics. Per-rank Cache-DiT end logs identify
the branch, cache-hit steps and actual block calls.
Caching approximates denoiser outputs. Compare quality on representative inputs
when choosing the residual threshold and TaylorSeer settings. To validate the
integration against Cache-Off, enable caching with
max_continuous_cached_steps=0 and use the same request and seed.