Abstract
Text-conditional diffusion models have revolutionized image and video generation but suffer from high computational costs during inference. This paper investigates the role of attention mechanisms—specifically cross-attention and self-attention—across the denoising process. We observe that cross-attention outputs converge early in the inference process, dividing generation into a "semantic-planning" phase and a "fidelity-improving" phase. Based on these findings, we propose Temporally Gating the Attention (TGATE), a training-free method that caches and reuses attention maps to accelerate inference. Experimental results demonstrate that TGATE achieves 10%-50% speedups across various models, including Stable Diffusion XL and PixArt-Alpha, with negligible impact on image quality.
Introduction
Generating high-resolution visual content using diffusion models is a computationally intensive task. The primary bottleneck is the attention mechanism, which exhibits quadratic complexity relative to the number of visual tokens. While existing acceleration techniques often rely on model distillation or architectural pruning—both of which require significant retraining and compute—this research explores whether all attention computations are necessary at every denoising step. By analyzing the temporal dynamics of attention, we identify significant redundancies that can be exploited to improve efficiency without retraining.
Temporal Attention Decomposition
Our analysis reveals that the diffusion process is not uniform. Instead, it consists of two distinct functional phases determined by the behavior of the attention layers:
- Semantics-Planning Phase (Early Steps): During the initial steps, the model focuses on establishing the global structure and semantic content based on the text prompt. Cross-attention is critical here for aligning text embeddings with visual features. Conversely, self-attention is less impactful as the latent space is still dominated by noise.
- Fidelity-Improving Phase (Late Steps): As the process continues, the model shifts toward refining textures and details. We observed that cross-attention maps converge to a fixed point during this phase, rendering repeated recomputation redundant. However, self-attention becomes vital for maintaining spatial consistency and high-frequency details.
As shown in the figure above, the cross-attention difference drops sharply and stabilizes after roughly 10 steps, providing a natural "gate" for optimization.
The TGATE Method
TGATE (Temporally Gating the Attention) is a simple, plug-and-play inference strategy that leverages this temporal decomposition:
- In the Semantics-Planning Phase: The model computes cross-attention normally to ensure prompt alignment but caches self-attention maps, reusing them for a set number of steps to reduce overhead.
- In the Fidelity-Improving Phase: The model stops recomputing cross-attention. Instead, it reuses a "gate" map (an average of previous maps). It then resumes full self-attention computation to ensure the final image is sharp and realistic.
Because TGATE only modifies the inference loop, it is entirely training-free and compatible with both U-Net and Transformer-based diffusion architectures.
Experimental Results
We evaluated TGATE across several benchmarks, including MS-COCO for zero-shot quality and MJHQ-10K for aesthetic performance. The results consistently show significant reductions in latency with minimal impact on Fréchet Inception Distance (FID) scores.
As illustrated in the latency analysis, attention mechanisms account for over 75% of total inference time in baseline models. By applying TGATE, we achieved a 47% speedup on PixArt-Alpha (1024x1024) using a 1080 Ti GPU, reducing latency from 61.5s to 32.8s. Similar gains were observed in Stable Diffusion XL and video generation models like OpenSora. Qualitatively, the generated samples remain nearly indistinguishable from the baseline, preserving both composition and color accuracy.
Conclusion
TGATE offers a highly efficient, training-free solution for accelerating text-conditional diffusion models. By recognizing the complementary temporal roles of cross-attention and self-attention, we can skip redundant computations without sacrificing generative quality. Future work may involve integrating TGATE into the training process of new architectures to further push the boundaries of real-time high-resolution synthesis.
Code Availability: The implementation of TGATE is available at https://github.com/HaozheLiu-ST/T-GATE.
Summary updated