Gradient-free Decoder Inversion in Latent Diffusion Models

Seongmin Hong, Suh Yoon Jeon, Kyeonghyun Lee, Ernest K. Ryu, Se Young Chun

Abstract

Latent Diffusion Models (LDMs) achieve high-quality image synthesis by operating in a compressed latent space. However, inverting the decoder to find the latent representation of a given image remains a significant bottleneck, typically requiring memory-intensive gradient-based optimization. This paper introduces a gradient-free inversion method that leverages the model's pre-trained encoder as a proxy for gradients. By treating inversion as a fixed-point iteration problem, the proposed approach achieves up to a 5x speedup and an 89% reduction in GPU memory usage, enabling high-resolution video inversion on consumer-grade hardware.

Introduction

Latent Diffusion Models, such as Stable Diffusion, have revolutionized generative AI by performing diffusion in a low-dimensional latent space. While this efficiency is a boon for generation, it complicates tasks like image editing or watermarking that require "inverting" the decoder—mapping a pixel-space image back to its exact latent representation.

Comparison of LDM architectures and the trade-offs in generative model invertibility.

As shown in Figure 4, traditional LDMs separate the diffusion process from the image space via a decoder $\mathcal{D}$. Unlike Pixel-space Diffusion Models (DMs), where the latent $z_0$ is the image itself, LDMs require an additional inversion step. Current state-of-the-art methods rely on gradient-based optimization, which is computationally expensive and suffers from a "memory wall," often limiting inversion to a handful of frames on standard hardware.

Methodology: Gradient-free Inversion

The core innovation of this work is a gradient-free algorithm that bypasses backpropagation through the massive decoder. Instead of calculating gradients, the method uses the pre-trained encoder ($\mathcal{E}$) to guide the search for the optimal latent.

The update rule is formulated as a fixed-point iteration: the latent estimate is adjusted based on the difference between the encoded target image and the encoded reconstruction. This approach is theoretically grounded in the concept of $\beta$-cocoercivity. The authors demonstrate that because the encoder and decoder are trained as approximate inverses, the mapping is sufficiently well-behaved for iterative convergence.

Experimental validation of the relationship between cocoercivity and inversion error (NMSE).

Figure 6 illustrates this relationship, showing that higher cocoercivity correlates with lower reconstruction error (NMSE), validating the theoretical assumptions across various latent samples. To further enhance performance, the authors incorporate momentum via Inertial Krasnoselskii-Mann (KM) iterations and integrate the Adam optimizer with learning rate scheduling.

Key Results and Efficiency

The gradient-free approach offers significant practical advantages over traditional optimization:

  • Memory Efficiency: By removing the need to store a computation graph for backpropagation, memory usage is drastically reduced. In tests with the LaVie video model, VRAM requirements dropped from 64.7 GB to just 7.13 GB—an 89% saving.
  • Speed: The method is up to 5x faster than gradient-based alternatives, reaching target error thresholds in a fraction of the time (e.g., 1.89s vs 9.51s).
  • Numerical Stability: Unlike gradient-based methods that often require 32-bit precision to avoid vanishing gradients, this method is robust in 16-bit (FP16), further optimizing hardware utilization.

The researchers validated these results across multiple models, including Stable Diffusion 2.1, LaVie, and InstaFlow, demonstrating comparable or superior accuracy to gradient-based methods while maintaining a much smaller computational footprint.

Conclusion

By reframing decoder inversion as a gradient-free iterative process, this research overcomes the primary scalability hurdles of Latent Diffusion Models. The ability to perform high-quality inversion with minimal memory overhead opens new doors for complex video editing and robust watermarking on accessible hardware. Future work may extend this framework to other generative architectures, potentially enabling real-time latent-space manipulation.

Summary updated

BibTeX
@inproceedings{hong2024gradient,
  author = {Seongmin Hong and Suh Yoon Jeon and Kyeonghyun Lee and Ernest K. Ryu and Se Young Chun},
  title = {{Gradient-free Decoder Inversion in Latent Diffusion Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=nbqvjkOs6S},
}
Figure