Introduction
Generating high-resolution images with diffusion models is computationally intensive, primarily due to the attention mechanism. As resolution and token length increase, the cost of calculating attention grows quadratically, creating a significant latency bottleneck in inference. While various acceleration methods exist, many require expensive retraining or are architecture-specific. This paper introduces TGATE (Temporally Gating the Attention), a training-free, "plug-and-play" solution that accelerates models by 10%–50% with minimal impact on image quality.
Methodology: Temporal Gating
TGATE is based on the observation that the denoising process in diffusion models consists of two distinct temporal phases with different attention requirements:
- Semantics-Planning Phase (Initial steps): The model focuses on layout and high-level conceptual alignment. During this stage, cross-attention (aligning text to pixels) is vital for establishing the scene, while self-attention can be partially cached.
- Fidelity-Improving Phase (Later steps): The model refines details and textures. The researchers discovered that cross-attention maps converge to a stable state early in the process. TGATE leverages this by caching an "anchor" cross-attention map and reusing it for all subsequent steps, thereby eliminating redundant computations.
TGATE is entirely training-free and compatible with various architectures, including U-Net-based models like Stable Diffusion and Transformer-based models like PixArt-Alpha.
Key Insights
- Early Convergence: Cross-attention maps stabilize quickly, typically within the first 5 to 10 denoising steps. Once converged, recalculating them provides no additional guidance for the final image.
- Temporal Complementarity: Cross-attention and self-attention operate somewhat independently across time. Cross-attention performs the heavy lifting early to define semantics, while self-attention takes over later to polish the visual fidelity.
- Phase Impact: Experimental results show that bypassing cross-attention in the early phase significantly degrades image quality (high FID), whereas bypassing it in the later phase has almost no impact, confirming the validity of the gated approach.
Experimental Results
TGATE was evaluated across diverse benchmarks including MS-COCO, MJHQ-10K, and OpenSora-Sample. It demonstrated substantial speedups across multiple model types:
- PixArt-Alpha: Latency was reduced from 61.5s to 32.8s, representing a ~47% acceleration on consumer-grade hardware.
- Stable Diffusion XL (SDXL): Inference time was nearly halved, dropping from 53.2s to 27.4s.
- Video Generation: On the OpenSora framework, TGATE reduced inference time by over 50%.
Furthermore, TGATE is orthogonal to other acceleration techniques. When combined with methods like DeepCache, it further reduced SDXL latency to 14.6s while maintaining competitive image quality.
Limitations and Future Work
While highly effective for standard diffusion processes, TGATE offers diminishing returns (around 10%) for models already compressed into very few steps, such as Latent Consistency Models (LCM). Future research may explore using these semantic-planning insights to improve the training of student models in distillation processes, potentially enabling even faster one-step generators.
Summary updated