[论文解读] Efficient Spatially Sparse Inference for Conditional GANs and Diffusion Models
本文提出空间稀疏推理(SSI)与稀疏增量生成引擎(SIGE),一种通用方法,通过重用未编辑图像区域中的缓存特征图,并仅稀疏更新已更改区域,从而加速条件式生成对抗网络(GANs)与扩散模型。SIGE 在 NVIDIA RTX 3090 上实现高达 7.2× 的推理速度提升,在 Apple M1 Pro GPU 上实现 5.2× 的速度提升,适用于 Stable Diffusion,且质量损失极小,计算量显著减少。
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.
研究动机与目标
- 为了解决现有生成模型在仅进行微小编辑时仍需重新合成整张图像所导致的计算浪费问题,提升效率。
- 通过降低推理延迟,在不损失图像质量的前提下,实现真正的实时交互式图像编辑。
- 开发一种通用、硬件高效的推理引擎,兼容现成模型与现有压缩技术。
- 支持扩散模型与 GAN 中的卷积层及注意力机制,扩展至现代架构(如 Stable Diffusion)的适用性。
- 在多种硬件上实现实用化的加速,包括消费级 GPU 与 Apple M1 Pro,同时保持生成图像的全局一致性。
提出的方法
- 在未编辑区域重用前序推理步骤中的特征图,避免冗余计算。
- 计算差异掩码以识别新编辑区域,并仅在这些稀疏空间位置应用卷积滤波器。
- 通过 gather-scatter 模式应用稀疏更新操作,高效地仅更新已编辑区域,同时重用缓存激活。
- 通过剪枝未编辑的查询令牌,将方法扩展至注意力层,使注意力图计算量与编辑区域大小成比例大幅减少。
- 将 SIGE 实现为硬件优化的推理引擎,将理论计算节省转化为常见 GPU 与 CPU 上可测量的延迟降低。
- 通过在编辑间保持状态,支持增量推理,实现在编辑工作流中快速预览与交互。
实验结果
研究问题
- RQ1我们能否通过仅选择性地更新编辑过的图像区域而非整张图像,来减少条件式 GAN 与扩散模型中的计算量?
- RQ2在通过空间稀疏性加速推理的同时,如何保持图像的全局一致性?
- RQ3所提出的方法能否在标准硬件(包括消费级 GPU 与 Apple M1 Pro)上高效实现,以实现低延迟的交互式编辑?
- RQ4该方法在不同编辑尺寸与模型架构(包括具有自注意力与交叉注意力层的模型)上的可扩展性如何?
- RQ5该方法在多大程度上可与现有模型压缩技术结合,以进一步降低计算成本?
主要发现
- SIGE 在 NVIDIA RTX 3090 上对 Stable Diffusion 实现高达 7.2× 的加速,在 GauGAN 上实现 5.6× 的加速,编辑区域占比为 1.2%。
- 在 Apple M1 Pro GPU 上,SIGE 对 GauGAN 实现 5.2× 的加速,对 DDPM 实现 4.6× 的加速,展现出跨平台的有效性。
- 对于 DDPM,SIGE 在 RTX 3090 上将 MACs 减少高达 7.5×,延迟降低 3.0×,编辑区域占比为 1.2%。
- 该方法将 GauGAN 的计算量减少高达 18×,Stable Diffusion 减少 8.2×,以乘加操作(Multiply-Accumulate operations)为度量。
- 当与 GAN 压缩结合时,GauGAN 的计算量可减少高达 47×,显示出与模型压缩技术的强协同效应。
- 该方法通过查询令牌剪枝支持注意力层,使注意力计算量与编辑区域大小成比例减少,从而在如 Stable Diffusion 等模型中实现高效推理。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。