Stable-Fast compiles the full diffusion pipeline with Triton + CUDA graphs for an intermediate speed tier
Stable-Fast (sfast) is a third-party JIT compiler for diffusion pipelines. In StreamDiffusion it is invoked via accelerate_with_stable_fast(stream), which calls sfast.compilers.stable_diffusion_pipeline_compiler.compile(). The compiler applies xformers attention, Triton kernel fusion, and CUDA graphs (small batch sizes benefit most from CUDA graphs by reducing CPU launch overhead). Unlike TensorRT, stable-fast compilation is faster and does not require ONNX export or engine files, making it easier to use in development. The wrapper’s _load_model method catches compilation failures and falls back to unaccelerated mode, making it resilient for deployment.
Examples
# Via wrapper parameter:
StreamDiffusionWrapper(..., acceleration='sfast')
# Directly:
from streamdiffusion.acceleration.sfast import accelerate_with_stable_fast
stream = accelerate_with_stable_fast(stream)
Assessment
What does config.enable_cuda_graph = True do in the stable-fast config, and why is it specifically beneficial for small batch sizes in a streaming context?