[Paper Review] Efficient Spatially Sparse Inference for Conditional GANs and Diffusion Models
This paper proposes Spatially Sparse Inference (SSI) and the Sparse Incremental Generative Engine (SIGE), a general-purpose method that accelerates conditional GANs and diffusion models by reusing cached feature maps in unedited image regions and sparsely updating only the changed areas. SIGE achieves up to 7.2× inference speedup on NVIDIA RTX 3090 and 5.2× on Apple M1 Pro GPU for Stable Diffusion, with minimal quality loss and significant computation reduction.
During image editing, existing deep generative models tend to re-synthesize the entire output from scratch, including the unedited regions. This leads to a significant waste of computation, especially for minor editing operations. In this work, we present Spatially Sparse Inference (SSI), a general-purpose technique that selectively performs computation for edited regions and accelerates various generative models, including both conditional GANs and diffusion models. Our key observation is that users prone to gradually edit the input image. This motivates us to cache and reuse the feature maps of the original image. Given an edited image, we sparsely apply the convolutional filters to the edited regions while reusing the cached features for the unedited areas. Based on our algorithm, we further propose Sparse Incremental Generative Engine (SIGE) to convert the computation reduction to latency reduction on off-the-shelf hardware. With about $1\%$-area edits, SIGE accelerates DDPM by $3.0 imes$ on NVIDIA RTX 3090 and $4.6 imes$ on Apple M1 Pro GPU, Stable Diffusion by $7.2 imes$ on 3090, and GauGAN by $5.6 imes$ on 3090 and $5.2 imes$ on M1 Pro GPU. Compared to our conference version, we extend SIGE to accommodate attention layers and apply it to Stable Diffusion. Additionally, we offer support for Apple M1 Pro GPU and include more results with large and sequential edits.
Motivation & Objective
- To address the inefficiency of existing generative models that re-synthesize entire images even for minor edits, wasting significant computation.
- To enable real-time interactive image editing by reducing inference latency without sacrificing image quality.
- To develop a general-purpose, hardware-efficient inference engine compatible with off-the-shelf models and existing compression techniques.
- To support both convolutional layers and attention mechanisms in diffusion models and GANs, extending applicability to modern architectures like Stable Diffusion.
- To provide practical acceleration on diverse hardware, including consumer GPUs and Apple M1 Pro, while maintaining global coherence in generated images.
Proposed method
- Cache and reuse feature maps from previous inference steps in unedited regions to avoid redundant computation.
- Compute a difference mask to identify newly edited regions and apply convolutional filters only to those sparse spatial locations.
- Apply sparse update operations using gather-scatter patterns to efficiently update only edited regions while reusing cached activations.
- Extend the method to attention layers by pruning unedited query tokens, drastically reducing attention map computation proportional to edit size.
- Implement SIGE as a hardware-optimized inference engine that translates theoretical computation savings into measurable latency reductions on common GPUs and CPUs.
- Support incremental inference by maintaining state across edits, enabling fast preview and interaction in editing workflows.
Experimental results
Research questions
- RQ1Can we reduce computation in conditional GANs and diffusion models by selectively updating only edited image regions rather than the entire image?
- RQ2How can we maintain global image coherence while accelerating inference through spatial sparsity?
- RQ3Can the proposed method be efficiently implemented on standard hardware, including consumer GPUs and Apple M1 Pro, to achieve low-latency interactive editing?
- RQ4How does the method scale across different edit sizes and model architectures, including those with self- and cross-attention layers?
- RQ5To what extent can the method be combined with existing model compression techniques to further reduce computational cost?
Key findings
- SIGE achieves up to 7.2× speedup on NVIDIA RTX 3090 for Stable Diffusion and 5.6× on GauGAN, with 1.2% edit area.
- On Apple M1 Pro GPU, SIGE delivers 5.2× speedup for GauGAN and 4.6× for DDPM, demonstrating cross-platform effectiveness.
- For DDPM, SIGE reduces MACs by up to 7.5× and latency by 3.0× on RTX 3090, with 1.2% edit area.
- The method reduces computation by up to 18× for GauGAN and 8.2× for Stable Diffusion, measured in Multiply-Accumulate operations.
- When combined with GAN Compression, the computation of GauGAN is reduced by up to 47×, showing strong synergy with model compression.
- The method supports attention layers via query token pruning, reducing attention computation proportionally to edit size, and enables efficient inference in models like Stable Diffusion.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.