Skip to content

Zehong-Ma/MagCache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

47 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MagCache: Fast Video Generation with Magnitude-Aware Cache

Zehong Ma1,2†,Β  Longhui Wei2‑,Β  Feng Wang2,Β  Shiliang Zhang1*,Β  Qi Tian2*
1State Key Laboratory of Multimedia Information Processing,
School of Computer Science, Peking University,Β 
2Huawei Inc.
(† Work was done during internship at Huawei Inc., ‑ Project Leader. * Corresponding author.)

arXiv Home Page License github


Figure 1: Visualization of MagCache on Open-Sora and Wan2.1. MagCache can achieve better visual quality with a comparable or less latency. More demos are shown in the subfolders of each model.

πŸ«– Introduction

We introduce Magnitude-aware Cache (MagCache), a training-free caching approach that estimates and leverages the fluctuating differences among model outputs across timesteps based on the robust magnitude observations, thereby accelerating the inference. MagCache works well for Video Diffusion Models, Image Diffusion models. For more details and results, please visit our project page.


Figure 2: Relationships between output residuals across diffusion timesteps. Magnitude ratio serves as both an accurate and stable criterion for measuring the difference between residuals.

πŸ”₯ Latest News

  • If you like our project, please give us a star ⭐ on GitHub for the latest update.
  • [2025/8/20] πŸ”₯ Support Qwen-Image and Qwen-Image-Edit with 1.5x speedup officially.
  • [2025/8/7] πŸ”₯ Support Wan2.2 with 1.5-2x speedup officially.
  • [2025/7/14] πŸ”₯ Support OmniGen2 with 1.9x speedup officially.
  • [2025/6/30] πŸ”₯ Support Flux-Kontext with 2x speedup officially.
  • [2025/6/19] πŸ”₯ Support FramePack officially.
  • [2025/6/17] πŸ”₯ Support VACE 1.3B&14B officially.
  • [2025/6/17] πŸ”₯ MagCache is supported by ComfyUI-WanVideoWrapper. Thanks @kijai.
  • [2025/6/16] πŸ”₯ Support Chroma officially. Please try it in ComfyUI-MagCache.
  • [2025/6/12] πŸ”₯ Support ComfyUI-MagCache officially. Please have a try!
  • [2025/6/10] πŸ”₯ Support Wan2.1, HunyuanVideo, FLUX, Open-Sora.
  • [2025/6/10] πŸŽ‰ Release the code of MagCache.
  • [2025/6/10] πŸŽ‰ Release the paper of MagCache.

🧩 Community Contributions

If you develop/use MagCache in your projects and you would like more people to see it, please inform us.(zehongma@stu.pku.edu.cn)

ComfyUI

πŸŽ‰ Supported Models

Text to Video

Image to Video

Video Editing

Text to Image

Image Editing

Demos

  • HunyuanVideo T2V 720P
HunyuanVideo_T2V_720P__Two_Astronauts.mp4

Prompt: The video shows two astronauts in bulky suits walking slowly on the moon’s surface.... The video shows two astronauts in bulky suits walking slowly on the moon’s surface, against a vast starry universe. Their steps are heavy and slow, kicking up dust in the low-gravity environment. The scene is silent, mysterious, and evokes the courage and dreams of space exploration.
  • Wan2.1 14B I2V 720P
Wan14B_I2V_720P_A_Woman.mp4

Prompt: A woman in black lace stands confidently in a dim Art Deco interior with polished marble floors.... 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.
  • Wan2.1 14B T2V 720P
Wan14B_T2V_720P_Two_Astronauts.mp4

Prompt: The video shows two astronauts in bulky suits walking slowly on the moon’s surface.... The video shows two astronauts in bulky suits walking slowly on the moon’s surface, against a vast starry universe. Their steps are heavy and slow, kicking up dust in the low-gravity environment. The scene is silent, mysterious, and evokes the courage and dreams of space exploration.
Wan14B_T2V_A_Stylish_Woman_Tokyo.mp4

Prompt: A stylish woman walks down a Tokyo street filled with warm glowing neon.... A stylish woman walks down a Tokyo street filled with warm glowing neon and animated city signage. She wears a black leather jacket, a long red dress, and black boots, and carries a black purse. She wears sunglasses and red lipstick. She walks confidently and casually. The street is damp and reflective, creating a mirror effect of the colorful lights. Many pedestrians walk about.
  • Wan2.1 1.3B T2V 480P
Wan1.3B_T2V_Two_Cat_Boxing.mp4

Prompt: Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage. Prompt: Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage.
OpenSora.mp4

Prompt: A tranquil tableau of an ornate Victorian streetlamp.... A tranquil tableau of an ornate Victorian streetlamp standing on a cobblestone street corner, illuminating the empty night
  • FramePack
framepack_demo.mp4

Prompt: The girl dances gracefully, with clear movements, full of charm. The girl dances gracefully, with clear movements, full of charm.
  • FLUX-dev T2I


Prompt: A photo of a black bicycle. Prompt: A photo of a black bicycle.
  • FLUX-Kontext Image

πŸ€– Instructions for Supporting Other Models

  • Welcome for PRs to support other models.
  • Please implement the magcache_calibration function by referring the code in MagCache4Wan2.1
  • Utilize a random prompt or input to generate the magnitude ratio.
  • Implement the magcache_forward function by adding a few lines into the original forward function.
  • Reuse the default hyper-parameters or set your own hyper-parameters to achieve a trade-off between latency and quality.

πŸ’ Acknowledgement

This repository is built based on VideoSys, Diffusers, Open-Sora, FLUX, Chroma, Wan2.1, HunyuanVideo, FramePack, and TeaCache. Thanks for their contributions!

πŸ”’ License

πŸ“– 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}, 
}

About

The official code for "MagCache: Fast Video Generation with Magnitude-Aware Cache"

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published