TL;DR
This paper introduces DuCa, a novel dual feature caching strategy that iteratively alternates between aggressive and conservative caching to significantly accelerate Diffusion Transformers (DiTs) for image and video generation without sacrificing quality. By questioning the necessity of computing "important" tokens and proposing a diversity-driven token selection, DuCa achieves substantial speedups across various DiT-based models.
What Problem Does This Paper Address?
Diffusion Transformers (DiTs) have revolutionized visual generation, but their computational cost during inference is a major bottleneck, hindering practical deployment. Feature caching, which reuses previously computed features, is a promising acceleration technique. However, existing methods face a trade-off: aggressive caching offers high speedups but degrades generation quality due to accumulated errors, while conservative caching preserves quality but yields lower acceleration. This paper aims to bridge this gap by re-evaluating the effectiveness of token-wise caching and proposing a more balanced approach.
Methods
The core of this paper is the Dual Feature Caching (DuCa) strategy. DuCa addresses the limitations of existing methods by:
- Iterative Aggressive and Conservative Caching: Instead of relying solely on one approach, DuCa alternates between aggressive caching (reusing all cached features) and conservative caching (selectively computing some features to correct errors). This iterative process aims to leverage the speed of aggressive caching while mitigating its quality degradation with the error-correction capabilities of conservative caching.
- Rethinking Token Selection: The paper challenges the assumption that "important" tokens, as defined by traditional metrics like attention scores, are truly beneficial to compute. Through extensive experiments, they discover that random token selection, prioritizing diversity over perceived importance, often leads to better or comparable performance. This approach also offers the advantage of being compatible with efficient attention mechanisms like FlashAttention, which are often incompatible with attention-score-based methods.
- Diversity-Driven Token Selection: The paper argues that selecting tokens with the smallest similarity to others (i.e., maximizing diversity) is more effective than selecting "important" tokens. Random selection naturally achieves this diversity.
Datasets
The paper evaluates its method on several established datasets and benchmarks:
- FLUX.1-dev: Used for text-to-image generation.
- HiDream: Used for text-to-image generation.
- OpenSora: Used for text-to-video generation.
- DiT-XL/2: Used for class-conditional image generation on ImageNet.
The authors also mention using prompts from DrawBench for text-to-image generation and VBench for text-to-video evaluation.
Key Insights and Ideas
- Aggressive caching isn't inherently bad; it just needs correction: The paper's experiments show that aggressive caching doesn't necessarily introduce significantly more error in the immediate caching step. The problem arises from the accumulation of these errors over many steps.
- Conservative caching can fix aggressive caching's mistakes: The iterative nature of DuCa allows the conservative steps to act as a "reset" or correction mechanism for the errors introduced by the aggressive steps.
- "Important" tokens might not be that important: The paper's most surprising finding is that traditional methods for identifying "important" tokens (based on attention scores, etc.) can be less effective than simply picking tokens randomly. This suggests that diversity in cached features is more crucial than focusing on a few "key" features.
- Diversity is key for token selection: The research strongly supports the idea that selecting tokens that are semantically different from each other leads to better caching performance. Random selection is a simple yet effective way to achieve this.
- Compatibility with FlashAttention is crucial for real-world speedups: The paper highlights how their random token selection method seamlessly integrates with FlashAttention, a critical factor for achieving significant latency reductions in practice.
Key Results
DuCa demonstrates significant improvements across various models and tasks:
- Text-to-Image Generation (FLUX.1-dev): Achieves up to 3.45x acceleration with Image Reward scores comparable to the original model, outperforming previous methods like ToCa.
- Text-to-Video Generation (OpenSora): Achieves 2.50x acceleration with a VBench score of 78.83, nearly matching the original model's quality and significantly improving speed over ToCa.
- Class-Conditional Image Generation (DiT-XL/2): DuCa achieves comparable FID scores to other methods while offering higher acceleration ratios.
- Latency Speedup: DuCa achieves a 2.93x latency speedup on FLUX.1-dev due to its compatibility with FlashAttention, surpassing ToCa's 1.59x speedup.
Limitations and Future Work
- Hyperparameter Tuning: While the paper identifies optimal hyperparameters (N=5, R=0.9) for cycle length and cache ratio, further exploration might be beneficial for different model architectures or tasks.
- Generalizability of Token Selection: While random selection proved effective, exploring more sophisticated diversity-aware selection strategies could potentially yield further improvements.
- Future Work: The authors hope their work will encourage more research into simple yet effective feature caching methods, moving away from overly complex solutions. They also suggest that their findings on token diversity could be valuable for other areas of transformer-based research.
Summary updated