Diffusion models like Stable Diffusion have revolutionized generative AI, but their iterative sampling process imposes a notorious "speed limit." Generating a high-quality image typically requires dozens or even hundreds of sequential steps, making real-time applications a significant challenge. While researchers have attempted to accelerate this process by training smaller "distilled" models or employing advanced numerical solvers, these methods often require expensive retraining or eventually hit a ceiling in generation quality.
A new paper from researchers at UC Santa Barbara introduces ReDi (Retrieval-based Diffusion), a simple yet highly effective "learning-free" approach that speeds up inference by 2$\times$. The core premise is intuitive: if the model has generated a similar image structure before, it can simply retrieve that past experience and skip ahead, bypassing the most tedious parts of the generation process.
The Bottleneck: Function Evaluations in Diffusion
The primary bottleneck in diffusion models is the Number of Function Evaluations (NFEs). To transform random noise into a coherent image, the model must repeatedly predict and subtract noise. Existing solutions to reduce NFEs generally fall into two categories:
- Learning-based methods: Techniques like distillation require retraining the model to take larger steps. This is computationally expensive and often degrades the nuanced generation capabilities of the original pre-trained model.
- Learning-free methods: These utilize advanced numerical solvers (such as PNDM or DPM-Solver) to navigate the generation path more efficiently. However, these solvers still treat every generation as a completely novel problem. They ignore the fact that many images share similar structural "layouts" during the early, noisy stages of generation.
ReDi addresses this inefficiency by observing that the diffusion process is essentially a trajectory through a high-dimensional space. If two generation paths start near each other, they tend to remain close for a significant portion of the process.
The ReDi Framework
ReDi introduces a retrieval-based framework that operates in four main phases, requiring no modifications to the underlying model weights:
- Knowledge Base (KB) Construction: Before deployment, a set of generation trajectories is precomputed using a standard dataset (e.g., MS-COCO). For each trajectory, ReDi saves an early, noisy intermediate image (the Key at step $k$) and a later, more refined image (the Value at step $v$).
- Partial Generation & Query: When a user submits a prompt, ReDi begins the generation process normally. Once it reaches step $k$, it pauses and uses the current noisy image as a query.
- The "Jump" (Retrieval): ReDi searches the precomputed Knowledge Base for the nearest neighbors to the query. It then performs a weighted linear combination of the corresponding "Values" from the KB. This combined result serves as a shortcut, allowing the model to instantly skip all intermediate steps between $k$ and $v$.
- Refinement: Finally, the model resumes standard sampling from step $v$ down to 0, refining the retrieved layout into a crisp, final image.
Key Insights and Capabilities
- Trajectories Make the Best Keys: Previous retrieval-augmented generation methods often used text prompts or CLIP embeddings to find similar images. ReDi demonstrates that using the actual intermediate noisy image is far superior. The early steps of diffusion dictate the layout and structure of the image; matching this visual "skeleton" yields much more accurate retrievals than matching text descriptions.
- Theoretical Guarantees: The authors ground their method in the sensitivity of Ordinary Differential Equations (ODEs). They provide a theoretical proof showing that the distance between a retrieved trajectory and the "true" trajectory remains bounded, mathematically guaranteeing that the retrieval "jump" will not derail the final image quality.
- Zero-Shot Stylization: Because ReDi separates layout generation from final refinement, it excels at cross-domain generation. A user can retrieve a structural layout from a "style-free" database (like COCO) and then apply a stylistic prompt (e.g., "in the style of Van Gogh") for the final refinement steps. This preserves the composition of a standard photo while seamlessly applying complex artistic styles.
Performance and Results
Evaluated on the MS-COCO validation set, ReDi demonstrates significant efficiency gains:
- 2$\times$ Speedup: ReDi achieves comparable or superior image quality (measured via Fréchet Inception Distance, or FID) in just 20 steps compared to standard solvers running for 40 steps.
- High Efficiency: Constructing the Knowledge Base takes approximately 1 GPU day—a negligible cost compared to the thousands of GPU hours required to train or distill models like Stable Diffusion.
- Minimal Overhead: The retrieval process is highly optimized, accounting for only about 0.4% of the total inference time.
- Superior Layout Consistency: In human evaluations for stylization tasks, ReDi was found to preserve the original image layout significantly better than standard Stable Diffusion when switching styles.
Limitations and Future Directions
While highly effective, ReDi's performance is inherently tied to the diversity of its Knowledge Base. If a user prompts for an extremely niche concept not represented in the precomputed database, the retrieval step may find a poor match, potentially lowering final image quality. Additionally, finding matching trajectories for highly complex prompts with many distinct objects remains challenging. The authors suggest that integrating Large Language Models (LLMs) to simplify prompts during the retrieval stage could mitigate this issue.
Looking forward, the researchers believe the trajectory-retrieval logic could be extended beyond images to other modalities, such as audio or video diffusion, where computational demands are even more severe.
Summary updated