2025-03-05 16:59:18 +08:00

4.6 KiB

TeaCache4Wan2.1

TeaCache can speedup Wan2.1 2x without much visual quality degradation, in a training-free manner. The following video shows the results generated by TeaCache-Wan2.1 with various teacache_thresh values. The corresponding teacache_thresh values are shown in the following table.

https://github.com/user-attachments/assets/5ae5d6dd-bf87-4f8f-91b8-ccc5980c56ad

https://github.com/user-attachments/assets/dfd047a9-e3ca-4a73-a282-4dadda8dbd43

https://github.com/user-attachments/assets/7c20bd54-96a8-4bd7-b4fa-ea4c9da81562

https://github.com/user-attachments/assets/72085f45-6b78-4fae-b58f-492360a6e55e

📈 Inference Latency Comparisons on a Single A800

Wan2.1 t2v 1.3B TeaCache (0.05) TeaCache (0.07) TeaCache (0.08)
~175 s ~117 s ~110 s ~88 s
Wan2.1 t2v 14B TeaCache (0.14) TeaCache (0.15) TeaCache (0.2)
~55 min ~38 min ~30 min ~27 min
Wan2.1 i2v 480P TeaCache (0.13) TeaCache (0.19) TeaCache (0.26)
~735 s ~464 s ~372 s ~300 s
Wan2.1 i2v 720P TeaCache (0.18) TeaCache (0.2) TeaCache (0.3)
~29 min ~17 min ~15 min ~12 min

Usage

Follow Wan2.1 to clone the repo and finish the installation, then copy 'teacache_generate.py' in this repo to the Wan2.1 repo.

For T2V with 1.3B model, you can use the following command:

python teacache_generate.py  --task t2v-1.3B --size 832*480 --ckpt_dir ./Wan2.1-T2V-1.3B --prompt "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage." --base_seed 42 --offload_model True --t5_cpu --teacache_thresh 0.08

For T2V with 14B model, you can use the following command:

python teacache_generate.py  --task t2v-14B --size 1280*720 --ckpt_dir ./Wan2.1-T2V-14B  --prompt "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage." --base_seed 42 --offload_model True --t5_cpu  --teacache_thresh 0.2

For I2V with 480P resolution, you can use the following command:

python teacache_generate.py --task i2v-14B --size 832*480 --ckpt_dir ./Wan2.1-I2V-14B-480P --image examples/i2v_input.JPG --prompt "Summer beach vacation style, a white cat wearing sunglasses sits on a surfboard. The fluffy-furred feline gazes directly at the camera with a relaxed expression. Blurred beach scenery forms the background featuring crystal-clear waters, distant green hills, and a blue sky dotted with white clouds. The cat assumes a naturally relaxed posture, as if savoring the sea breeze and warm sunlight. A close-up shot highlights the feline's intricate details and the refreshing atmosphere of the seaside." --base_seed 42 --offload_model True --t5_cpu --teacache_thresh 0.26

For I2V with 720P resolution, you can use the following command:

python teacache_generate.py --task i2v-14B --size 1280*720 --ckpt_dir ./Wan2.1-I2V-14B-720P --image examples/i2v_input.JPG --prompt "Summer beach vacation style, a white cat wearing sunglasses sits on a surfboard. The fluffy-furred feline gazes directly at the camera with a relaxed expression. Blurred beach scenery forms the background featuring crystal-clear waters, distant green hills, and a blue sky dotted with white clouds. The cat assumes a naturally relaxed posture, as if savoring the sea breeze and warm sunlight. A close-up shot highlights the feline's intricate details and the refreshing atmosphere of the seaside." --base_seed 42 --offload_model True --t5_cpu --frame_num 61  --teacache_thresh 0.3

Acknowledgements

We would like to thank the contributors to the Wan2.1.