Diffusion models have revolutionized image generation, yet their iterative nature remains a significant computational hurdle. Generating a single high-resolution image often requires dozens of denoising steps, each involving complex attention mechanisms. Researchers from KAUST, NUS, and Meta AI have introduced TGATE (Temporally Gating the Attention), a training-free method that slashes inference latency by up to 50% by exploiting the temporal redundancy of attention maps.
The Bottleneck: Attention in Diffusion
The primary computational cost in modern diffusion models, whether based on U-Net or Transformer (DiT) architectures, stems from the attention mechanism. Specifically, cross-attention (aligning text prompts with pixels) and self-attention (handling spatial relationships) exhibit quadratic complexity relative to the number of tokens.
While techniques like distillation or architectural pruning exist, they often necessitate expensive retraining or are model-specific. TGATE addresses this by asking a fundamental question: Is full attention necessary at every step of the denoising process?
Temporal Decomposition of the Denoising Trajectory
The authors' key insight is that the roles of cross-attention and self-attention shift dramatically during the generation process. They identify two distinct phases:
- Semantics-Planning Phase: In the initial steps, cross-attention is critical for establishing the layout and semantic content based on the text prompt.
- Fidelity-Improving Phase: Once the layout is fixed, the model focuses on refining textures and fine details. In this stage, self-attention becomes the primary driver of quality, while cross-attention maps converge to a fixed point.
As shown in the analysis above, the mean of predicted noise drops sharply after the initial steps, marking the transition between these phases. By visualizing the impact of null text embeddings, the researchers demonstrated that text guidance is mostly redundant after the "gate step" (typically around step 10 of 25).
The TGATE Algorithm
TGATE is a plug-and-play inference-time modification. It operates in two stages:
- Early Phase: Cross-attention remains active to lock in the prompt's meaning. To save time, self-attention maps are cached and reused every $k$ steps.
- Late Phase: Upon reaching a predefined gate step ($m$), the cross-attention maps are cached and reused for all remaining steps. Full self-attention is then restored to ensure high-fidelity detail.
Because TGATE is a structural change to the inference loop, it requires zero retraining and is compatible with both U-Net and DiT architectures, such as SDXL and PixArt-Alpha.
Performance and Quality
The empirical results demonstrate that TGATE achieves significant speedups without compromising image quality. On an NVIDIA 1080Ti, the latency for the PixArt-Alpha model was reduced from 61.5 seconds to 32.8 seconds—a nearly 50% improvement.
Interestingly, image quality (measured by FID) often remained stable or even improved. For instance, in SD-2.1, the baseline FID of 22.6 improved to 20.8 when using TGATE for cross-attention. This suggests that reusing stable attention maps can act as a form of regularization, preventing the model from introducing unwanted artifacts in the final stages of generation. Furthermore, TGATE is orthogonal to other acceleration techniques; when combined with DeepCache, it reduced SDXL latency from 53 seconds to just 14.6 seconds while maintaining competitive performance.
Conclusion
TGATE represents a significant step toward efficient diffusion. By recognizing the "complementary redundancy" of attention—where cross-attention is vital early and self-attention is vital late—the method provides a simple yet powerful way to accelerate generation. While TGATE shows diminishing returns on highly distilled models (like LCM) that already use very few steps, its universality and training-free nature make it a valuable tool for the current generation of high-resolution models.
Summary updated