TL;DR
This paper introduces SwiftDiffusion, a system designed to significantly speed up text-to-image generation services by efficiently serving diffusion models with complex add-on modules like ControlNet and LoRA. By decoupling ControlNet, optimizing LoRA loading, and introducing latent parallelism, SwiftDiffusion achieves up to 7.8x lower latency and 1.6x higher throughput without sacrificing image quality.
What Problem Does This Paper Address?
The explosion of text-to-image (T2I) generation services, powered by diffusion models, has created a demand for efficient cloud-based serving. However, production T2I systems often augment base diffusion models with "add-on" modules like ControlNet (for spatial control) and LoRA (for style customization) to enhance user control. These add-ons, while powerful, introduce substantial loading and computational overhead, leading to increased latency and reduced throughput. Existing solutions primarily focus on optimizing the base diffusion model, neglecting the significant bottlenecks introduced by these add-on modules, especially when multiple are used concurrently.
Methods
SwiftDiffusion tackles the T2I serving challenge with a three-pronged, holistic approach:
- ControlNet-as-a-Service: ControlNets are decoupled from the base diffusion model and served as a separate, independently scalable service on dedicated GPUs. This allows for:
- Caching: Popular ControlNets are cached in GPU memory to eliminate loading overhead.
- Parallelization: ControlNets can run in parallel with the base diffusion model, significantly reducing computation time.
- Sharing: A single ControlNet instance can be shared across multiple base models.
- Bounded Asynchronous LoRA Loading (BAL): LoRAs are compute-light but have high loading overhead. BAL addresses this by:
- Overlapping Loading and Inference: LoRA loading is initiated asynchronously while the base model begins its initial denoising steps (up to k steps).
- Quality Guarantee: The loading is "bounded" to ensure that LoRA is applied before its absence significantly impacts image quality.
- Efficient Patching: LoRA weights are merged directly into the base model's parameters in-place, avoiding the overhead of creating new layers.
- Latent Parallelism for CFG Computation: The core diffusion model inference involves a Classifier-Free Guidance (CFG) step where the latent tensor is duplicated and processed twice (conditioned and unconditioned). SwiftDiffusion parallelizes these two computations across two GPUs, effectively doubling the base model inference speed. This technique is also applied to accelerate ControlNet computations.
Datasets
The paper uses the Google PartiPrompts (P2) dataset for generating text prompts for evaluation. The models evaluated include SDXL, and two diffusion transformer (DiT) models: SD3 and Hunyuan-DiT.
Key Insights and Ideas
- Add-ons are the real bottleneck: The study highlights that while base diffusion models are computationally intensive, the real performance killer in production T2I services comes from the overhead of loading and running add-on modules like ControlNet and LoRA.
- ControlNet popularity is skewed: A small percentage of ControlNets are used by a vast majority of requests, making caching a highly effective strategy.
- LoRA's impact is delayed: The stylistic effects of LoRAs become prominent only in the later stages of the diffusion process, enabling asynchronous loading and overlapping with early inference steps.
- Parallelism is key: Decoupling and parallelizing ControlNet execution, and parallelizing the CFG step within the base model, are crucial for achieving significant speedups.
Key Results
- Latency Reduction: SwiftDiffusion achieves up to 7.8x latency reduction compared to state-of-the-art T2I serving systems.
- Throughput Improvement: It offers up to 1.6x throughput improvement.
- ControlNet Speedup: ControlNet-as-a-Service provides up to 2.2x speedup by distributing ControlNet computations across multiple GPUs.
- LoRA Efficiency: BAL and efficient LoRA patching reduce LoRA loading and patching overhead to approximately 230ms.
- Base Model Speedup: Latent parallelism and kernel optimizations provide a 1.7x speedup for base diffusion model inference.
- Image Quality: Crucially, SwiftDiffusion does not sacrifice image quality, as validated by quantitative metrics (CLIP, FID, LPIPS, SSIM) and a user study.
Limitations and Future Work
- Inter-GPU Bandwidth Dependency: The performance of ControlNet parallelization is shown to be dependent on inter-GPU bandwidth. While pipelining techniques can mitigate this for low-bandwidth scenarios, high-bandwidth solutions are still preferred for optimal speedup.
- Generalization to DiT Models: While the paper demonstrates SwiftDiffusion's effectiveness on DiT-based models, further exploration into specific optimizations for these newer architectures might be beneficial.
- Future Work: The paper suggests that the proposed techniques can be adapted to support other emerging add-on modules, indicating a path for future research in expanding SwiftDiffusion's applicability.
Summary updated