Serve Stable Diffusion Three Times Faster
Blog post from Lightning AI
Stable Diffusion serving can be made substantially faster and less costly for high-concurrency production workloads through PyTorch and DeepSpeed optimizations while preserving image quality. Tests on an NVIDIA A10 GPU reduced single-image batch-size-one serving time from 6.4 seconds to 2.09 seconds, an improvement of more than 300%, compared with much slower results on M1 Mac hardware. Mixed-precision FP16 inference produced a 40% speed gain, while inference_mode or no_grad offered less than 1%, and CUDA Graphs added about 5% by capturing and replaying GPU operations to reduce Python and kernel-launch overhead; CUDA Graphs were applied to the CLIP text encoder, U-Net, and VAE but do not support dynamic batch sizes. DeepSpeed Inference yielded a further 44% gain through fused GPU kernels and optimized transformer layers, requiring custom replacements for Stable Diffusion’s CrossAttention and BasicTransformerBlock components because the model was used directly from its repository rather than through pre-supported Hugging Face or Timm implementations. The optimizations also delivered stronger gains at larger batch sizes, and future work may investigate dynamic batching for the U-Net and operator trace optimization.
No tracked trend matches for this post yet.
Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.