Optimizing Real-Time Diffusion with StreamDiffusion
Learning objectives
- learner can explain how StreamDiffusion hits real-time via stream batch, timestep selection, and frame skipping
- learner can apply the acceleration stack: TensorRT, Stable-Fast, TinyVAE, KV-cache, residual CFG, LoRA stacking
- learner can set up the install, warmup, IO queues, and multiprocess viewer for a stable pipeline
Capstone — one whole task that evidences the objectives
Stand up an optimized real-time img2img pipeline and benchmark it: install StreamDiffusion, choose a t_index_list, enable stream batch, TensorRT (or Stable-Fast) and TinyVAE, add KV-cache precomputation and residual CFG, stack LoRAs for style, run warmup and split generation/display across processes with IO queues, and report your fps against the published RTX-4090 benchmarks.
Prerequisite modules
The whole task here is the one every AV livecoder with an NVIDIA rig eventually faces: turning diffusion from a batch renderer into a live visual instrument. If you want camera- or pattern-reactive imagery projected behind a set, the pipeline must sustain video rate on stage hardware — which means every millisecond of the inference loop has to be accounted for. This module builds toward standing up that pipeline yourself and proving it with numbers against the published RTX-4090 benchmarks.
The arc starts supported: get the layered install right (the CUDA/Python/TensorRT stack in “StreamDiffusion requires CUDA GPU, Python 3.10, PyTorch 2.1”) and run a stock example through the high-level wrapper. From there you tighten one screw at a time, using the atoms as just-in-time how-tos: pick timesteps with “The t_index_list selects which diffusion timesteps to apply”, swap in the distilled autoencoder per “Replacing the standard VAE with TinyVAE”, then layer on residual CFG, KV-cache precomputation, and fused style LoRAs. The final unsupported step is architectural — splitting generation and display across OS processes with IO queues and a proper warmup — done without scaffolding, ending in your own fps report.
The required atoms gate the capstone directly: you cannot choose a sane t_index_list, enable an acceleration backend, or explain why your fps differs from 106/93 without them, and the frame-skipping story (Stochastic Similarity Filter) is what you reach for when the input goes static mid-set. Supporting atoms enrich rather than gate: latent diffusion and denoising inference explain why these optimizations work, while LCM-LoRA, xformers, and mode constraints deepen the trade-off space you will explore after the benchmark stands.
Atoms in this module
Required — these gate the capstone
Supporting — enrichment, not gating
Part of curricula
- Audio-Visual Performer — integrated, synced live AV — Compose the whole (generative & AI-layered AV) required
- Generative & AI AV Artist — real-time machine-driven performance — Engineer steerable real-time diffusion visuals required
Unlocks — modules that require this one