SwarmUI Teacache Full Tutorial With Very Best Wan 2.1 I2V & T2V Presets - ComfyUI Used as Backend - 2x and more Speed Up
Video Tutorial Link
Tutorial Info
Teacache is used to speed up AI generations significantly and I will show how to use it in SwarmUI with ComfyUI backend in this tutorial. Moreover, I am sharing presets and full details of how to use Wan 2.1 Text-to-Image and Text-to-Video models properly in SwarmUI with ComfyUI backend so easily and accurately.
🔗Follow below link to download the zip file that contains SwarmUI installer and AI models downloader Gradio App - the one used in the tutorial ⤵️
▶️ How to install SwarmUI main tutorial : https://youtu.be/fTzlQ0tjxj0
▶️ Fast Wan 2.1 Tutorial : https://youtu.be/XNcn845UXdw
🔗Follow below link to download the zip file that contains ComfyUI 1-click installer that has all the Flash Attention, Sage Attention, xFormers, Triton, DeepSpeed, RTX 5000 series support ⤵️
🔗 Python, Git, CUDA, C++, FFMPEG, MSVC installation tutorial - needed for ComfyUI ⤵️
🔗 SECourses Official Discord 10500+ Members ⤵️
🔗 Stable Diffusion, FLUX, Generative AI Tutorials and Resources GitHub ⤵️
🔗 SECourses Official Reddit - Stay Subscribed To Learn All The News and More ⤵️
0:00 Introduction: Teacache & Wan 2.1 Presets for Swarm UI
0:35 Prerequisites: Previous Tutorials & Updating Swarm UI Files
1:09 Running the Swarm UI Update Script
1:21 Importing the New Presets into Swarm UI
1:46 Enabling Advanced Options & Locating Teacache Installer
1:57 Understanding Teacache: Faster Generation, Minimal Quality Loss
2:14 Monitoring Teacache Installation Process via CMD
2:32 Teacache Installed: Preparing for Image-to-Video Generation
2:43 Applying Image-to-Video Preset & Initial Configuration
3:04 Selecting Init Image & Base Model (e.g., Wan 2.1 480p)
3:25 How to Download Models via Swarm UI Downloader
3:52 Choosing Specific Image-to-Video Models (FP16/GGUF Q8)
4:04 Setting Correct Resolution & Aspect Ratio from Model Metadata
4:25 Key Image-to-Video Settings: Model Override & Video Frames
4:42 Optimizing Video Steps (30) & CFG (6) for Teacache
5:01 Configuring Teacache Mode (All) & Threshold (15%)
5:08 Setting Frame Interpolation (2x for 32 FPS) & Duration
5:22 Starting Image-to-Video: Importance of Latest Swarm UI
5:41 Generation Started: Teacache & Step Skipping Explained
6:05 Observing Teacache in Action: Step Jumps & How It Works
6:23 Leveraging Sage Attention & ComfyUI's Automated Setup
6:38 Teacache Performance Boost: Example Speed Increase (IT/s)
6:51 Understanding ComfyUI Block Swapping & Monitoring GPU Usage
7:18 Image-to-Video Generation Complete: Total Time & Output
7:32 Accessing Generated Video & Output Format Options (H.265)
7:55 Text-to-Video: Applying Preset & Adjusting Core Settings
8:13 Configuring Text-to-Video Parameters: Steps (30), FPS, Format
8:27 Selecting Text-to-Video Model (GGUF Q8) & Setting Resolution
8:45 Advanced Settings: UniPC Sampler, Sigma Shift (8), CFG Impact
9:03 Enabling Teacache (15%) for Text-to-Video
9:15 Starting HD Text-to-Video Generation (GGUF Q8 Model)
9:36 Understanding Performance: HD Resolution & Frame Count Impact
9:54 Text-to-Video Complete: Time Taken & Teacache Speedup
10:06 Downloading & Reviewing the Full HD Text-to-Video Result
10:19 Comparing Prompt Effectiveness: Image-to-Video vs. Text-to-Video
10:30 Conclusion: Future Presets & Power of Swarm UI with ComfyUI
TeaCache: Brewing Faster Inference for Diffusion Models
Diffusion models have revolutionized image, video, and audio generation, producing stunningly realistic and creative outputs. However, their iterative denoising process, often involving hundreds of steps, makes inference notoriously slow. Addressing this bottleneck, TeaCache (Timestep Embedding Aware Cache) emerges as an innovative, training-free approach to significantly accelerate these models without substantial degradation in output quality.
The Challenge: The Iterative Nature of Diffusion
At their core, diffusion models work by progressively removing noise from an initial random state over a series of "timesteps." Each timestep involves a computationally intensive pass through a large neural network (often a U-Net or Transformer). The sheer number of these steps is the primary reason for long generation times, hindering rapid prototyping and real-time applications.
How TeaCache Works: The Secret Sauce
TeaCache's brilliance lies in its observation that computations at adjacent timesteps, especially in the later stages of denoising, often produce highly similar intermediate results or "residuals" (the difference between the model's output and its input). Instead of recomputing everything at every step, TeaCache intelligently decides when to reuse cached information.
The "Timestep Embedding Aware" part is crucial. Here's a breakdown of its mechanism:
Timestep Embedding as a Proxy: Diffusion models use timestep embeddings – vector representations of the current denoising step – to guide the model's behavior. TeaCache hypothesizes that the difference between consecutive timestep embeddings can serve as a good indicator of how much the model's internal state (and thus its output) will change.
Predicting Similarity: At each denoising step, TeaCache compares the current timestep embedding with the one from the previously computed step.
Rescaling and Thresholding: This raw difference in embeddings is then rescaled using a model-specific polynomial function (defined by coefficients in the TeaCache implementation for various models). This rescaled difference represents an estimated "relative L1 distance" between the model's potential outputs.
Caching Decision: This estimated distance is compared against a user-defined rel_l1_thresh (relative L1 threshold).
If the distance is below the threshold: It implies that the model's output for the current step is likely to be very similar to the previous one. TeaCache then skips the full, expensive computation for the current step. Instead, it reuses the previously computed residual (the difference between the model's output and its input from the last fully computed step) and applies it to the current step's input.
If the distance is above the threshold (or if it's the first/last step): TeaCache performs the full computation, updates its cache with the new residual, and resets its accumulated distance counter.
Accumulated Distance: The system keeps an accumulated_rel_l1_distance. If several consecutive steps are skipped, this accumulated distance grows. Once it surpasses the rel_l1_thresh, a full computation is triggered.
This adaptive caching strategy allows TeaCache to skip redundant computations while ensuring that the model performs a full update when significant changes are expected, thus maintaining quality.
Key Advantages of TeaCache
Training-Free: One of TeaCache's most significant advantages is that it requires no model retraining or fine-tuning. It can be applied "on top" of existing pre-trained diffusion models.
Significant Speedup: As demonstrated in its repository, TeaCache can provide substantial inference speedups, often in the range of 1.5x to over 2x, depending on the model and the chosen threshold.
Broad Model Compatibility: While initially focused on video diffusion models, TeaCache has shown effectiveness across image and audio diffusion models as well.
User-Controllable Trade-off: The rel_l1_thresh parameter provides a direct way for users to balance inference speed against output quality. Higher thresholds lead to more aggressive caching and faster speeds but might introduce slight quality degradation.
Supported Models
TeaCache offers impressive versatility, with dedicated implementations and support for a growing list of popular diffusion models:
Text-to-Video (T2V):
Wan2.1
Cosmos
CogVideoX1.5
LTX-Video
Mochi
HunyuanVideo
CogVideoX
Open-Sora
Open-Sora-Plan
Latte
EasyAnimate (via community)
FramePack (via community)
FastVideo (via community)
Image-to-Video (I2V):
Wan2.1
Cosmos
CogVideoX1.5
ConsisID
EasyAnimate (via community)
Ruyi-Models (via community)
Video-to-Video (V2V):
EasyAnimate (via community)
Text-to-Image (T2I):
FLUX
Lumina-T2X
Text-to-Audio (T2A):
TangoFlux
Comments (18)
Hi Furkan, another question: I have a 3060 12GB, would it be feasable to put in another card, like the 5060 TI 16GB and run SwarmUI on both cards? Will WAN and image generation be faster and generated on both cards? Like generation on both cards at the same time, or does it not work like that?
nope it wont be faster. but you can generate 2x videos. so a video on each GPU
Now that we can create a very good resemblance video with only one source image from a person, is there a similar tool for image generation? 1 source image --> 1 output image? training full checkpoints yields very good results, but WAN can do it with 1 source image, so i guess there should be a similar good image generation tool?
there are few options but nothing so perfect. you can see this one : https://www.patreon.com/posts/118469722
Has anyone had a problem with a disappearing option? ( TeaCache Mode ) fter installation, it worked, but now it's gone and I don't have it anymore. Even after reinstalling everything, it appears for a minute and then disappears again.
dont forget to click display advanced options i am seeing it right now
how can we use this tool for multiple angle view image generator ai models?
You can fine tune a FLUX model for this task with such dataset. that is best way
Hi can you please make an image on Massed compute, that one can click that will load the newest ComfyUI backend as well as SwarmUI and your downloaderUI (one can choose what models to download), so it will be up and running fast. It is so confusing to try to get this to work on Massed. Thank you very much for your hard work!
hey i will let Massed Compute team to know this.
Hi Furkan, when i set steps to 30 and Video CFG to 6 (like in this latest teacache tutorial, instead of Steps = 8 and CFG = 1, like in your previous video tutorial), the video is very disturbed with artefacts, like burned in, oversaturated. looks similarly like when you generate an image with to high CFG. Do i miss something? teacache is enabled with 0.15. when I use it with steps = 8 and CFG = 1, there are no artefacts and oversaturation.
dont get confused. previous tutorial uses a specific lora so that is different. teacache tutorial is a general logic tutorial. also teacache can be used with other models as well like hidream
How do I add lore to this?
just select lora from your lora tab thats it
Hi Dr. Furkan, First of all, thank you so much for your amazing work — I’ve been testing the tool and getting great results so far. However, I believe I’ve encountered a bug. Whenever I generate a video, it works fine the first time. But if I change the image, prompt, or any other parameter and try to create a new video, it just regenerates the same video — only this time it's extremely fast and very blurry, almost as if it's stuck on the previous image or cache. No matter what changes I make, the only way I’ve found to fix this is by restarting Swarm UI entirely. I’ve had to restart it every single time I want to generate a new video. Let me know if this is something that was reported to you before.
ye looks like a bug in either swarmui or comfyui. try to update both and see still happening. they usually fix bugs in short time
Can I install this on RunPod or does it only work locally? (I have a Mac so have to use RunPod)
we have runpod installer so you can install definitely. i plan to make a new video for runpod as well but older videos and installer still working perfect maybe i can make a video today stay tuned
