TL;DR
Generative models like GANs and Diffusion models are powerful but computationally expensive. They often re-calculate an entire image even when a user only changes a tiny fraction of it. This paper introduces Spatially Sparse Inference (SSI) and a specialized engine called SIGE that allows these models to "reuse" previous calculations for unedited regions, resulting in up to 14× speedups on consumer hardware without losing image quality.
The Inefficiency of Image Editing
When using an AI tool to edit an image—such as changing a building's roof or adding a car to a street—the underlying model (like GauGAN or a Diffusion model) typically re-synthesizes the entire image from scratch.
The authors point out a massive inefficiency: if a user edits only 1% of an image, current models still spend 100% of the original computation time to generate the result. This "waste" happens because standard deep learning frameworks are designed for dense, uniform computation. There is no built-in way to tell a convolutional layer to "only look at this small box and ignore the rest." This leads to high latency, making interactive, real-time editing difficult on anything but the most powerful GPUs.
Methods: Caching and Sparse Computation
To solve this, the authors propose a two-part solution:
- Spatially Sparse Inference (SSI): Because convolution is a linear operator, the output of an edited image can be mathematically split into two parts: the output of the original image (which can be cached) and the output of the difference between the original and edited image. Since the difference is mostly zeros (sparse), the model only needs to perform new calculations on the edited pixels.
- Sparse Incremental Generative Engine (SIGE): Theoretical sparsity doesn't automatically mean faster code, as standard "gather-scatter" operations in frameworks like PyTorch have high overhead. SIGE is a custom inference engine that uses tiling-based sparse convolution. It breaks the image into small blocks (tiles) and only processes tiles that contain edited pixels.
To further squeeze out performance, the authors implemented Kernel Fusion (combining multiple operations into one to save memory bandwidth) and Normalization Pre-computation (reusing statistics from the original image to avoid re-calculating them for the whole frame).
Key Insights
- Feature Map Redundancy: Feature maps in the deeper layers of a neural network remain remarkably similar in unedited regions, allowing for aggressive caching.
- Linearity is Key: By exploiting the distributive property of convolution, they turned a generative task into a much smaller "delta" update task.
- Hardware-Aware Design: "Fine-grained" sparsity (pixel-by-pixel) is slow on GPUs. By moving to "tiling-based" sparsity (block-by-block), the algorithm aligns with how modern hardware actually processes data.
Datasets and Evaluation
The researchers evaluated their method on LSUN Church (testing Diffusion models like DDIM) and Cityscapes (testing GauGAN). Crucially, they introduced a new automated stroke editing benchmark. They used a segmentation model to "erase" objects and generated synthetic user strokes to simulate human editing, allowing for a rigorous, reproducible comparison of editing speed and quality.
Key Results
The performance gains are significant across different model architectures and hardware:
- Computation Reduction: For an edit covering 1.2% of the image, they reduced the computation (MACs) of DDIM by 7.5× and GauGAN by 18×.
- Latency Speedups:
- On NVIDIA RTX 3090: DDIM became 3× faster; GauGAN became 4.2× faster.
- On Apple M1 Pro (CPU): DDIM became 6.6× faster; GauGAN became a staggering 14× faster.
- Compatibility: SSI acts as a "plugin." When combined with existing model compression techniques (like GAN Compression), they achieved a cumulative 47× reduction in computation for GauGAN.
- Quality: Quantitative metrics (FID and mIoU) showed that the sparse inference results were nearly indistinguishable from the "full" dense inference results.
Limitations and Future Work
While highly effective, the method has a few limitations. First is memory overhead: the system must store the feature maps of the original image in memory, which can significantly increase GPU memory usage for deep diffusion models with many steps. Second, the tiling approach faces a low-resolution bottleneck; it is less effective at very low resolutions (e.g., 16x16 layers), where a single "edited" tile might cover the entire feature map. Finally, the method struggles with edits that cause global effects, such as changing the lighting or adding a reflective object, since SSI only updates local regions.
Summary updated