NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Cache Me if You Can: Accelerating Diffusion Models through Block Caching

Felix Wimbauer, Bichen Wu, Edgar Schoenfeld, Xiaoliang Dai, Ji Hou, Zijian He, Artsiom Sanakoyeu, Peizhao Zhang, Sam Tsai, Jonas Kohler, Christian Rupprecht, Daniel Cremers, Peter Vajda, Jialiang Wang

TL;DR

"Block Caching" is a novel inference-acceleration technique that speeds up diffusion models by 1.5x to 1.8x while maintaining or even improving image quality. By exploiting the fact that internal layer outputs change smoothly and contain high redundancy across denoising timesteps, the method skips redundant computations in heavy attention blocks and uses a lightweight scale-shift mechanism to prevent feature misalignment.

What Problem Does This Paper Address?

While text-to-image diffusion models (like Stable Diffusion or Emu) generate stunning, photorealistic imagery, their iterative denoising process is notoriously slow. Generating a single image requires passing a large U-Net architecture through dozens of sequential steps.

Most existing acceleration methods treat the denoising network as a black box, focusing either on creating advanced numerical ODE solvers (like DPM-Solver) to reduce the total number of steps, or distilling the network into fewer-step student models. However, naively cutting down the number of steps often degrades image quality, leading to duller colors and lost details. This paper looks inside the black box to address the massive computational redundancy occurring from step to step within the network layers themselves.

Methods

The authors observed that the internal feature maps of a diffusion model's U-Net change remarkably smoothly over the denoising trajectory. To exploit this, they introduced three core components:

  1. Block Caching: Instead of recomputing every layer at every step, the model caches and reuses the outputs of the computationally expensive SpatialTransformer (attention) blocks from previous steps. Because of the network's residual connections, caching can be done at a per-block level without breaking the overall information flow.
  2. Automatic Cache Scheduling: Not all blocks change at the same rate. The authors designed a mechanism that tracks the accumulated relative absolute change ($L1_{rel}$) of each block. A block's output is cached until its accumulated change crosses a predefined threshold $\delta$, triggering a recomputation.
Example of an automatically derived caching schedule across solver steps.
  1. Scale-Shift Adjustment: Aggressive caching can cause slight feature misalignments, introducing unwanted visual artifacts. To counteract this, the authors added a tiny, timestep-dependent linear layer that applies a channel-wise scale and shift to the cached features. This adjustment is trained using a resource-friendly student-teacher distillation setup, where the weights of the original network remain frozen.

Datasets

The authors validated their approach across two prominent diffusion setups:

  • LDM-512: A 900-million parameter Latent Diffusion Model trained on internal Shutterstock images. Quantitative evaluation (FID) was performed on a standard COCO subset (with faces removed for privacy reasons).
  • EMU-768: A state-of-the-art 2.7-billion parameter foundation model.

For qualitative and human preference testing, the authors utilized prompts from Open User Input (OUI) and PartiPrompts to gather a total of 1,320 independent human evaluations.

Key Insights and Ideas

  • Distinct, Input-Agnostic Patterns: Different layers exhibit highly specialized behavior over time. High-resolution blocks (at the very beginning or end of the U-Net) experience the most change during the final 20% of the denoising process. Conversely, deeper, lower-resolution blocks change rapidly at the beginning and flatten out later. Crucially, these patterns remain consistent regardless of the text prompt or random seed used.
Visualization of smooth layer-wise changes across different resolutions.
  • Attention vs. Convolutions: Caching only works well for attention-based SpatialTransformer blocks. The authors found that convolutional ResBlocks do not change smoothly and are highly sensitive; attempting to cache them severely degrades local image details while yielding a negligible 5% speedup.
  • The "Momentum" Effect: Interestingly, block caching combined with scale-shift adjustment often yields better FID scores than the standard baseline at the same step count. The authors hypothesize that caching introduces a slight beneficial "momentum" in the denoising trajectory, resulting in more pronounced, vibrant features.

Key Results

  • Substantial Speedups: The method consistently delivers a 1.5x to 1.8x inference speedup across different models (LDM, EMU) and solvers (DDIM, DPM).
  • Improved Visual Quality at Equal Latency: When given the same computational budget, running more steps with Block Caching significantly outperforms naively running fewer steps. For instance, on LDM-512 (DPM), 20 steps with caching matches the latency of a 14-step standard baseline but improves the FID score from 18.67 down to 15.95.
  • Human Preference: In side-by-side blind tests at equal latency, human annotators consistently preferred the block-cached images over the reduced-step baselines due to their superior detail and color vibrancy.
Figure 1. Speeding up diffusion models through block caching. We observe that there are many redundant layer computations at different timesteps in diffusion models when generating an image. Our block caching technique allows us to avoid these unnecessary computations, therefore speeding up inference by a factor of 1.5x-1.8x while maintaining image quality. Compared to the standard practice of naively reducing the number of denoising steps to match our inference speed, our approach produces more detailed and vibrant results.

Limitations and Future Work

  • Identity Shifts: The authors note that while the scale-shift adjustment successfully removes artifacts, it can occasionally alter the fine identity or style of objects/faces in the image more than a standard step-reduction would. This might necessitate extra safety checks in production environments.
  • Hyperparameter Sensitivity: The model can be sensitive to the choice of the threshold $\delta$, meaning finding the optimal balance between speed and quality requires manual tuning.
  • Future Directions: Promising avenues include integrating block caching directly into the initial training phase of diffusion models to accelerate training, or using human-in-the-loop reinforcement learning to better optimize the scale-shift parameters.

Summary updated

BibTeX
@misc{wimbauer2023cache,
  author = {Felix Wimbauer and Bichen Wu and Edgar Schoenfeld and Xiaoliang Dai and Ji Hou and Zijian He and Artsiom Sanakoyeu and Peizhao Zhang and Sam Tsai and Jonas Kohler and Christian Rupprecht and Daniel Cremers and Peter Vajda and Jialiang Wang},
  title = {{Cache Me if You Can: Accelerating Diffusion Models through Block Caching}},
  year = {2023},
  eprint = {2312.03209},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2312.03209},
}
Figure