TeaCache: Power your ComfyUI up to 2x Faster

faster inference with teacache

Have you ever encountered slow inference speed while handling image or video generation models? The solution is to use TeachCache. Timestep Embedding Aware Cache (TeaCache), a game-changing, training-free caching technique that optimizes performance across timesteps for diffusion models. Whether working with images, videos, or audio, TeaCache significantly accelerates your workflow while maintaining stunning output quality.

TeaCache is now fully integrated into ComfyUI, making it effortlessly compatible with native nodes. Users can incorporate TeaCache into their workflows simply by connecting the designated node to ComfyUI’s native nodes, ensuring an intuitive and streamlined experience. 


teacache speed testing

Most of the project is released under Apache2.0 license. For a more in-depth understanding, people can find access their research paper.


TeaCache generation demonstration

It offers substantial speedups across multiple diffusion models while maintaining high visual fidelity. Depending on the model in use, it delivers up to:

- 1.2x to 1.6x lossless speedup, ensuring zero compromise in output quality.

- 1.7x to 2x accelerated inference, with minimal visual degradation.


Installation

1. New users need to install ComfyUI. Older users have to update ComfyUI from the Manager by clicking on "Update ComfyUI".

2. Now you can install it in two ways.

Automatic Install:

Navigate to ComfyUI Manager and click on Custom nodes Manager. Then just search for "ComfyUI-TeaCache" and at last click on "Install".

Manual Install:

Now, move inside Custom nodes folder. By typing the "cmd" command in the folder address bar, open command prompt. Then, type the following command to clone the repository.

git clone https://github.com/welltop-cn/ComfyUI-TeaCache.git

You also need to install the required dependencies:

For normal ComfyUI users:

pip install -r requirements.txt

For ComfyUI portable users, move inside the "ComfyUI_windows_portable" folder. Open the command prompt and type these command: 

python_embeded\python.exe -m pip install -r requirements.txt


3. Restart ComfyUI to take effect.


Workflow


1. After getting it installed, you will get the workflow inside "ComfyUI/custom_nodes/ComfyUI-TeaCache/examples" folder. All the workflows are as follows:

(a) Teacache_cogvideox.json Workflow
(b) Teacache_flux.json Workflow
(c) Teacache_hunyuanvideo.json Workflow
(d) Teacache_ltx_video.json Workflow
(e) Teacache_pulid_flux.json Workfow

2. Drag and drop into ComfyUI and start generation with efficient speed.
 
TeaCache boosts ComfyUI performance by trading off some image quality. We are using RTX 4090, the base speed is around 3.9 it/s, but with TeaCache:

- rel_l1_thresh 0.4 speeds it up to 7.6 it/s approx

- rel_l1_thresh 0.23 gives 5.5 it/s approx


Normal Image Generation without TeaCache
Normal Image Generation without TeaCache


Image Generation with TeaCache
Image Generation with TeaCache

You will face some quality loss. So, TeaCache is great for quick previews. You can generate images faster, and then disable or reduce them for full-quality output.

It works well with LoRA, Redux (Flux tools), and official Inpainting (Flux tools). This also supports AMD GPUs via ZLUDA, and at 0.25 threshold, it cuts generation time in half. In general, it delivers a 2x speed boost without significant quality loss in testing.