ComfyUI-MagCache  by Zehong-Ma

Accelerating diffusion model inference with caching

Created 7 months ago
261 stars

Top 97.5% on SourcePulse

GitHubView on GitHub
Project Summary

Summary

This repository integrates MagCache, a training-free approach for accelerating video and image diffusion model inference, into ComfyUI. It targets ComfyUI users seeking significant speedups (2x-3x) without extensive retraining, offering a seamless node-based integration for faster content generation.

How It Works

MagCache employs a magnitude-aware caching strategy. It estimates fluctuating differences between model outputs across timesteps by observing output magnitudes. This enables an error modeling mechanism and adaptive caching, accelerating inference without requiring model fine-tuning. The approach is effective for various image and video diffusion models.

Quick Start & Requirements

Installation involves cloning the repository into ComfyUI/custom_nodes/, navigating to the directory, and running pip install -r requirements.txt. Users must prepare ComfyUI-formatted model weights for supported models like Wan2.1, HunyuanVideo, FLUX, Chroma, and Qwen-Image. The Compile Model node, utilizing torch.compile, may incur significant initial compilation times but yields extremely fast subsequent inference. Demo workflows are available in the examples folder.

Highlighted Details

  • Achieves notable speedups, including 1.75x for Qwen-Image, 1.7x for HunyuanVideo-1.5, and 2x for Flux-Kontext, with general gains of 2x-3x.
  • Supports a wide range of models: FLUX, Chroma, Qwen-Image, HunyuanVideo, Wan2.1 (various versions and tasks like T2V, I2V, VACE).
  • Integrates a Compile Model node that leverages torch.compile for optimized inference performance.
  • Actively collecting community-sourced optimal parameter settings via a GitHub discussion.

Maintenance & Community

The project appears actively developed, with frequent updates and model support additions. Community involvement is encouraged through a discussion issue for sharing optimal parameter configurations.

Licensing & Compatibility

The specific open-source license is not explicitly stated in the provided README text. Compatibility is primarily focused on the ComfyUI ecosystem.

Limitations & Caveats

While aiming for acceptable quality loss, users may observe reduced visual fidelity, particularly with Wan2.1 generated videos compared to unquantized outputs. Default parameters are tuned for maximum speed and might cause failures in certain scenarios. Specific calibration workflows are recommended for models like Chroma when inference steps deviate from defaults.

Health Check
Last Commit

1 month ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
1
Star History
9 stars in the last 30 days

Explore Similar Projects

Starred by Yineng Zhang Yineng Zhang(Inference Lead at SGLang; Research Scientist at Together AI), Yaowei Zheng Yaowei Zheng(Author of LLaMA-Factory), and
1 more.

FastVideo by hao-ai-lab

1.4%
3k
Framework for accelerated video generation
Created 1 year ago
Updated 1 day ago
Feedback? Help us improve.