Optimization Examples
Wan 2.1 QAT Attention 14B Inference
Use these files for Wan 2.1 14B inference with the ATTN_QAT_INFER backend:
examples/inference/optimizations/download_14B_qat.shexamples/inference/optimizations/attn_qat_inference_example.py
1. Download the 14B QAT checkpoint
The helper script downloads the QAT safetensors from
FastVideo/14B_qat_400 into checkpoints/14B_qat_400 by default.
Prerequisites:
huggingface_hubinstalled, for example:uv pip install huggingface_hub- access to the model repo if it is private or gated:
huggingface-cli login
Run:
bash examples/inference/optimizations/download_14B_qat.sh
To download into a custom directory, pass it as the first argument:
bash examples/inference/optimizations/download_14B_qat.sh /path/to/14B_qat_400
2. Edit the inference example for Wan 2.1 14B
Open examples/inference/optimizations/attn_qat_inference_example.py and
update these two values:
- Change the base model from
Wan-AI/Wan2.1-T2V-1.3B-DiffuserstoWan-AI/Wan2.1-T2V-14B-Diffusers. - Replace the placeholder
init_weights_from_safetensors="safetensors_path"with the directory that contains the downloaded.safetensorsfiles.
Example:
generator = VideoGenerator.from_pretrained(
"Wan-AI/Wan2.1-T2V-14B-Diffusers",
num_gpus=1,
use_fsdp_inference=True,
dit_cpu_offload=False,
vae_cpu_offload=False,
text_encoder_cpu_offload=True,
pin_cpu_memory=False,
init_weights_from_safetensors="checkpoints/14B_qat_400",
)
The script already sets:
os.environ["FASTVIDEO_ATTENTION_BACKEND"] = "ATTN_QAT_INFER"
3. Run the example
python examples/inference/optimizations/attn_qat_inference_example.py
The generated videos are written to video_samples/ by default.
Notes
ATTN_QAT_INFERrequires the in-repofastvideo-kernelbuild to expose theattn_qat_inferpackage.- If you have not built the kernel yet, run
cd fastvideo-kernel && ./build.shfirst. - If you keep the example on the
1.3Bbase model while loading the 14B QAT weights, the model/config will not match.