可在所有设备上部署的 Stable-Diffusion.cpp 开源加速
Open-Source Acceleration of Stable-Diffusion.cpp Deployable on All Devices
AI总结:
针对 Sdcpp 中 ggml_conv_2d 算子的高延迟与高内存问题,本文采用 Winograd 算法并结合计算图局部性与并行性优化二维卷积,在多款 Stable Diffusion 模型上实现最高 4.79 倍端到端加速。
摘要:
Stable diffusion 在生成高质量图像方面发挥着关键作用。然而,图像生成既耗时又耗费内存。为解决这一问题,stable-diffusion.cpp(Sdcpp)作为一种高效推理框架出现,用于加速扩散模型。尽管它十分轻量,但 Sdcpp 中 ggml_conv_2d 算子的当前实现并不理想,表现出较高的推理延迟和巨大的内存占用。为此,本文提出一个优化版本的 Sdcpp,利用 Winograd 算法加速作为整个流水线主要瓶颈的二维卷积运算。通过分析存在依赖和相互独立的计算图,我们利用设备的局部性与并行性,实现了显著的性能提升。我们的框架在多种 stable diffusion 模型上均能给出正确的端到端结果,包括 SDv1.4、v1.5、v2.1、SDXL 和 SDXL-Turbo。评估结果表明,在 M1 pro 上与原始 Sdcpp 相比,单个卷积层的加速最高可达 2.76 倍,整个图像生成过程的推理加速最高可达 4.79 倍。主页:https://github.com/SealAILab/stable-diffusion-cpp
英文摘要:
Stable diffusion plays a crucial role in generating high-quality images. However, image generation is time-consuming and memory-intensive. To address this, stable-diffusion.cpp (Sdcpp) emerges as an efficient inference framework to accelerate the diffusion models. Although it is lightweight, the current implementation of ggml_conv_2d operator in Sdcpp is suboptimal, exhibiting both high inference latency and massive memory usage. To address this, in this work, we present an optimized version of Sdcpp leveraging the Winograd algorithm to accelerate 2D convolution operations, which is the primary bottleneck in the pipeline. By analyzing both dependent and independent computation graphs, we exploit the device's locality and parallelism to achieve substantial performance improvements. Our framework delivers correct end-to-end results across various stable diffusion models, including SDv1.4, v1.5, v2.1, SDXL, and SDXL-Turbo. Our evaluation results demonstrate a speedup up to 2.76x for individual convolutional layers and an inference speedup up to 4.79x for the overall image generation process, compared with the original Sdcpp on M1 pro. Homepage: https://github.com/SealAILab/stable-diffusion-cpp
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。