TL;DR
Diffusion Transformers (DiTs) are powerful for image generation but slow during inference. This paper introduces HarmoniCa, a novel feature caching framework that harmonizes training and inference to significantly speed up DiTs. By addressing key discrepancies in existing methods, HarmoniCa achieves substantial latency reductions (over 40%) with minimal impact on image quality, making high-resolution generation more practical.
What Problem Does This Paper Address?
Generating high-quality images with Diffusion Transformers (DiTs) is computationally expensive, especially for high-resolution outputs. While feature caching offers a promising avenue for acceleration by reusing intermediate computations, existing learning-based caching methods suffer from two critical issues:
- Prior Timestep Disregard: During training, these methods often treat each timestep independently, ignoring how caching decisions at earlier steps influence later ones. This mismatch with the inference process, where timesteps are sequential, leads to accumulated errors.
- Objective Mismatch: The training objective typically focuses on minimizing the error in predicting the noise at each step. However, the ultimate goal during inference is to generate a high-quality final image. This discrepancy between training for intermediate noise prediction and inference for final image quality hinders effective learning.
These issues compromise both the performance and efficiency of feature caching for DiTs.
Methods
HarmoniCa tackles these problems with a two-pronged approach:
- Step-Wise Denoising Training (SDT): This novel training paradigm mimics the full denoising trajectory of inference. It uses a student-teacher setup where the student model learns to cache features while the teacher model operates without caching. This ensures that the training process accounts for the sequential nature of caching and feature reuse, aligning it with inference.
- Image Error Proxy-Guided Objective (IEPO): To bridge the gap between training for noise prediction and inference for image quality, IEPO introduces a proxy for the final image error. This proxy efficiently approximates the impact of caching on the final image, allowing the training objective to balance cache utilization with image quality without the prohibitive computational cost of direct final image error calculation during every training step.
These two components work together to harmonize the training and inference processes, leading to more effective and efficient feature caching.
Datasets
The paper uses standard datasets for training and evaluation:
- ImageNet: For class-conditional image generation tasks.
- MS-COCO: For text-to-image generation tasks.
- LSUN-Bedroom, CelebaHQ: Used for additional evaluations.
- MJHQ-30K, sDCI: Used for further T2I generation tests.
Key Insights and Ideas
- The "Prior Timestep Disregard" is a major bottleneck: Existing caching methods fail to account for the sequential dependency of caching decisions across timesteps, leading to significant error accumulation during inference.
- Aligning training objectives with inference goals is crucial: Training solely on intermediate noise prediction is insufficient for optimizing a caching strategy that aims for high-quality final images.
- A proxy for final image error is a practical solution: Directly using the final image error during training is computationally prohibitive. IEPO provides an efficient way to incorporate this crucial information.
- Harmonizing training and inference leads to better DiT acceleration: The proposed SDT and IEPO methods effectively bridge the gap, resulting in substantial speedups with minimal quality degradation.
Key Results
HarmoniCa demonstrates significant improvements across various DiT models and resolutions:
- Latency Reduction: Achieves over 40% latency reduction, translating to up to a 2.07x theoretical speedup on models like PIXART-α.
- Performance Improvement: Outperforms existing methods like Learning-to-Cache, achieving better FID and IS scores, particularly at lower timestep counts. For example, on DiT-XL/2 256x256 with a 10-step sampler, HarmoniCa achieved an FID of 13.35 and an IS of 151.83, surpassing Learning-to-Cache by 1.24 and 6.74 respectively.
- Training Efficiency: The image-free approach reduces training time by 25% compared to previous learning-based methods.
- High-Resolution Generation: For the first time, feature caching is shown to accelerate image generation at a super-high resolution of 2048x2048.
- Robustness: The method is robust across different samplers and resolutions, from 256x256 up to 2K.
Limitations and Future Work
- Focus on Block-wise Caching: The current work focuses on caching at the block level. The authors suggest future work could explore other caching granularities.
- Image Generation Focus: The current framework is applied to image generation. Future work could extend it to video, audio, or 3D generation.
- Sampler Dependency: The paper notes that applying a router trained with one sampler to a different sampler during inference can lead to performance degradation due to discrepancies in sampling trajectories. Future work could explore methods to mitigate this.
- Hyperparameter Tuning: While the method is shown to be robust to the threshold $\tau$, finding the optimal $\beta$ for balancing speed and performance might require further investigation.
Summary updated