Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 144 additions & 0 deletions README_MagCache.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<!-- ## **MagCache4Wan2.2** -->
# MagCache4Wan2.2

[MagCache](https://github.com/ali-vilab/MagCache) can speedup [Wan2.2](https://github.com/Wan-Video/Wan2.2) 1.5-2x without much visual quality degradation, in a training-free manner. The following video shows the results generated by MagCache-Wan2.2. The corresponding hyper-parameters are shown in the following table, where E006K2R02 denotes magcache_threshold=0.06, magcache_K=2, and retention_ratio=0.2.

## Usage

Follow [Wan2.2](https://github.com/Wan-Video/Wan2.2) to clone the repo and finish the installation, then copy 'magcache_generate.py' in this repo to the Wan2.2 repo.

For TI2V with 5B model, you can use the following command:

```bash
python magcache_generate.py \
--task ti2v-5B --size 1280*704 \
--ckpt_dir ./Wan-AI/Wan2.2-TI2V-5B \
--offload_model True --convert_model_dtype \
--t5_cpu \
--base_seed 42 \
--use_magcache \
--magcache_thresh 0.06 \
--magcache_K 2 \
--prompt "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage"

python magcache_generate.py --task ti2v-5B --size 1280*704 \
--ckpt_dir ./Wan2.2-TI2V-5B --offload_model True \
--use_magcache \
--magcache_thresh 0.06 \
--base_seed 42 \
--convert_model_dtype --t5_cpu --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."

```

For T2V-A14B model, you can use the following command:

```bash
python magcache_generate.py --task t2v-A14B \
--size 832*480 --ckpt_dir /data/mzh/pretrained_weights/Wan-AI/Wan2.2-T2V-A14B \
--t5_cpu \
--use_magcache \
--magcache_thresh 0.06 \
--retention_ratio 0.4 \
--offload_model True --convert_model_dtype \
--base_seed 42 \
--prompt "A man is talking to a woman in the office room."
```

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

```bash
python magcache_generate.py --task i2v-A14B \
--size 832*480 \
--ckpt_dir /data/mzh/pretrained_weights/Wan-AI/Wan2.2-I2V-A14B \
--image examples/wan_i2v_2.png \
--offload_model True --convert_model_dtype \
--use_magcache \
--magcache_thresh 0.06 \
--magcache_K 2 \
--retention_ratio 0.1 \
--t5_cpu \
--base_seed 42 \
--prompt "A woman in black lace stands confidently in a dim Art Deco interior with polished marble floors. Stark chiaroscuro lighting highlights her sharp features as she tilts her head, crimson lips parting in a knowing smile. Her smoldering gaze meets the viewer while she turns gracefully, lace casting shifting shadows on the walls. A medium shot with a subtle dolly zoom, framed by velvet drapes, adds depth. The mysterious, refined atmosphere blends modern elegance with vintage Hollywood glamour, rendered in 8K hyper-realistic detail, metallic gold accents glowing in the soft light."
```


## 📈 Inference Latency Comparisons on a Single L20

### Wan2.2 TI2V 5B 720p

| Wan2.2 TI2V 5B 720p | MagCache (E006K2R02) |
|:--------------------------:|:----------------------------:|
| ~10min39ss | ~5min24s |

<div align="center">
<video src="https://github.com/user-attachments/assets/e06df62b-7655-42c0-9ae6-666a32257f42" width="100%" poster=""> </video>
</div>
<!-- <div class="content has-text-centered">
<img src="../assets/Wan_14B_T2V_720P_header1.jpg" style="width: 100%"><br>
</div> -->
<details style="width: 100%; margin: auto;">
<summary>Prompt: Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage
</details>


<div align="center">
<video src="https://github.com/user-attachments/assets/ce9a3700-75f4-4177-81ec-d51572282324" width="100%" poster=""> </video>
</div>
<details style="width: 100%; margin: auto;">
<summary>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.
</details>

### Wan2.2 T2V A14B 480p

| Wan2.2 T2V A14B 480p | MagCache (E006K2R04) |
|:--------------------------:|:----------------------------:|
| ~27min09ss | ~18min10s |

<div align="center">
<video src="https://github.com/user-attachments/assets/84643b62-d42b-4d26-aabc-6f4a57ee2f6e" width="100%" poster=""> </video>
</div>
<!-- <div class="content has-text-centered">
<img src="../assets/Wan_14B_T2V_720P_header2.jpg" style="width: 100%"><br>
</div> -->
<details style="width: 100%; margin: auto;">
<summary>Prompt: A man is talking to a woman in the office room.
</details>

### Wan2.2 I2V A14B 480p

| Wan2.2 T2V A14B 480p | MagCache (E006K2R01) |
|:--------------------------:|:----------------------------:|
| ~26min43ss | ~20min05s (In work) |



<div align="center">
<video src="https://github.com/user-attachments/assets/37f8faf0-60b1-4fef-b45d-f39c4b77bc0d" width="100%" poster=""> </video>
</div>
<!-- <div class="content has-text-centered">
<img src="../assets/Wan_1.3B_T2V_480P_header.jpg" style="width: 100%"><br>
</div> -->
<details style="width: 100%; margin: auto;">
<summary>Prompt: A woman in black lace stands confidently in a dim Art Deco interior with polished marble floors. Stark chiaroscuro lighting highlights her sharp features as she tilts her head, crimson lips parting in a knowing smile. Her smoldering gaze meets the viewer while she turns gracefully, lace casting shifting shadows on the walls. A medium shot with a subtle dolly zoom, framed by velvet drapes, adds depth. The mysterious, refined atmosphere blends modern elegance with vintage Hollywood glamour, rendered in 8K hyper-realistic detail, metallic gold accents glowing in the soft light.
</details>


## Citation
If you find MagCache is useful in your research or applications, please consider giving us a star 🌟 and citing it by the following BibTeX entry.

```
@misc{ma2025magcachefastvideogeneration,
title={MagCache: Fast Video Generation with Magnitude-Aware Cache},
author={Zehong Ma and Longhui Wei and Feng Wang and Shiliang Zhang and Qi Tian},
year={2025},
eprint={2506.09045},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2506.09045},
}
```

## Acknowledgements

We would like to thank the contributors to the [Wan2.2](https://github.com/Wan-Video/Wan2.2).
Loading