Skip to main content
QUICK REVIEW

[论文解读] StreamDiffusion: A Pipeline-level Solution for Real-time Interactive Generation

Akio Kodaira, Chenfeng Xu|arXiv (Cornell University)|Dec 19, 2023
Generative Adversarial Networks and Image Synthesis被引用 6
一句话总结

StreamDiffusion 为使用扩散模型实现实时交互式图像生成引入了一种流水线级优化,在单张 RTX 4090 显卡上实现了高达 91.07 fps 的性能。通过流式批处理、残差无分类器引导(RCFG)以及随机相似性过滤,该方法实现了高吞吐量、低延迟推理,将 GPU 功耗降低最多达 2.39 倍,同时相比现有流水线将吞吐量提升了 59.6 倍。

ABSTRACT

We introduce StreamDiffusion, a real-time diffusion pipeline designed for interactive image generation. Existing diffusion models are adept at creating images from text or image prompts, yet they often fall short in real-time interaction. This limitation becomes particularly evident in scenarios involving continuous input, such as Metaverse, live video streaming, and broadcasting, where high throughput is imperative. To address this, we present a novel approach that transforms the original sequential denoising into the batching denoising process. Stream Batch eliminates the conventional wait-and-interact approach and enables fluid and high throughput streams. To handle the frequency disparity between data input and model throughput, we design a novel input-output queue for parallelizing the streaming process. Moreover, the existing diffusion pipeline uses classifier-free guidance(CFG), which requires additional U-Net computation. To mitigate the redundant computations, we propose a novel residual classifier-free guidance (RCFG) algorithm that reduces the number of negative conditional denoising steps to only one or even zero. Besides, we introduce a stochastic similarity filter(SSF) to optimize power consumption. Our Stream Batch achieves around 1.5x speedup compared to the sequential denoising method at different denoising levels. The proposed RCFG leads to speeds up to 2.05x higher than the conventional CFG. Combining the proposed strategies and existing mature acceleration tools makes the image-to-image generation achieve up-to 91.07fps on one RTX4090, improving the throughputs of AutoPipline developed by Diffusers over 59.56x. Furthermore, our proposed StreamDiffusion also significantly reduces the energy consumption by 2.39x on one RTX3060 and 1.99x on one RTX4090, respectively.

研究动机与目标

  • 为解决现有扩散模型在元宇宙、直播和游戏等实时交互应用中吞吐量低、延迟高的问题。
  • 通过在多个输入间实现重叠的、批处理的去噪,消除顺序去噪中的等待与交互瓶颈。
  • 通过用单个残差近似替代重复的负向条件,减少无分类器引导(CFG)中的计算冗余。
  • 通过应用随机相似性过滤跳过冗余的模型推理,最小化连续推理中的 GPU 功耗。
  • 在不牺牲图像质量或提示词对齐的前提下,实现高性能与高能效。

提出的方法

  • 流式批处理将顺序去噪替换为流水线化的批处理去噪过程,多个输入在相同的 U-Net 中以错开的步骤进行去噪。
  • 输入-输出队列管理输入源与 U-Net 之间的异步数据流,支持输入与输出的并行处理。
  • 残差无分类器引导(RCFG)仅在第一次去噪步骤中通过虚拟残差噪声一次性计算负向条件向量,从而消除各步骤间重复的负向去噪。
  • 随机相似性过滤将新输入与上一个处理的帧进行比较;若相似,则跳过模型推理,从而降低 GPU 激活频率与功耗。
  • 该流水线集成了现有的加速工具,如 Tiny AutoEncoder 和模型加速框架,进一步提升吞吐量。
  • 系统支持图像到图像和文本到图像生成,在消费级 GPU 上使用 sd-turbo 和 LCM-LoRA 等模型时表现出色。
Figure 2 : The concept of Stream Batch. In our approach, instead of waiting for a single image to be fully denoised before processing the next input image, we accept the next input image after each denoising step. This creates a denoising batch where the denoising steps are staggered for each image.
Figure 2 : The concept of Stream Batch. In our approach, instead of waiting for a single image to be fully denoised before processing the next input image, we accept the next input image after each denoising step. This creates a denoising batch where the denoising steps are staggered for each image.

实验结果

研究问题

  • RQ1能否通过流水线级优化实现实时、高吞吐量的扩散推理以支持交互式应用?
  • RQ2如何在不降低提示词对齐的前提下减少无分类器引导中的计算冗余?
  • RQ3在连续扩散推理中,GPU 功耗最多可降低多少,而不会牺牲帧率或图像质量?
  • RQ4流式批处理与输入队列能否在保持低延迟的同时实现持续的高吞吐量?
  • RQ5与标准 CFG 相比,残差无分类器引导在提示词遵循度与图像一致性方面表现如何?

主要发现

  • StreamDiffusion 在单张 RTX 4090 显卡上对图像到图像生成实现了高达 91.07 fps 的性能,相比 Diffusers Autopipeline 的吞吐量提升了 59.6 倍。
  • 仅流式批处理策略在不同去噪级别下相比顺序去噪即可实现约 1.5 倍的速度提升。
  • 残差无分类器引导(RCFG)相比传统 CFG 最多可实现 2.05 倍的速度提升,通过将负向去噪步骤减少至一次或零次。
  • 随机相似性过滤在 RTX 3060 上将 GPU 功耗降低 2.39 倍,在 RTX 4090 上降低 1.99 倍,显著提升了能效。
  • 在批大小为 12 时,该流水线使用 sd-turbo 模型可稳定维持约每秒 150 幅图像的处理速度,展现出良好的可扩展性与高吞吐量。
  • RCFG 在提示词对齐方面优于标准 CFG,尤其在修改头发颜色或添加物体等属性时表现更优,且可通过可调超参数缓解对比度不稳定性。
Figure 3 : Virtual residual noise vectors: The orange vectors depict the virtual residual noise that starts from the PF ODE trajectory and points to the original input latent $x_{0}$
Figure 3 : Virtual residual noise vectors: The orange vectors depict the virtual residual noise that starts from the PF ODE trajectory and points to the original input latent $x_{0}$

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。