home/ atoms/ streamdiffusion-stream-batch

StreamDiffusion's stream batch runs multiple denoising steps in parallel to sustain real-time frame rates

Standard diffusion inference is sequential: each denoising step waits for the previous one to finish, creating a latency floor that prevents sustained video rates. StreamDiffusion’s stream batch dissolves this bottleneck by treating several consecutive denoising steps as one GPU batch. A ring buffer (x_t_latent_buffer) holds intermediate latents from previous timesteps, and each call to predict_x0_batch processes the new input latent together with those buffered states in a single UNet forward pass. The net effect is ~1.5x throughput gain over sequential denoising. In practice, t_index_list=[32,45] means two timestep slots—two latents are batched together per UNet call. The tradeoff is that the batch size (and therefore VRAM) scales with the number of denoising steps and the frame_buffer_size.

Examples

stream = StreamDiffusion(
    pipe,
    t_index_list=[32, 45],   # 2 denoising steps → batch_size = 2
    frame_buffer_size=1,
)

For SD-Turbo with a single step (t_index_list=[0]), batch_size collapses to 1 and the buffer is unused.

Assessment

Given t_index_list=[0, 16, 32, 45] and frame_buffer_size=2, calculate the batch size that will be submitted to the UNet per call. Then explain why reducing len(t_index_list) to 1 removes the latency benefit.

“self.x_t_latent_buffer = torch.zeros( ( (self.denoising_steps_num - 1) * self.frame_bff_size,”
corpus · streamdiffusion-pipeline-for-real-time-interactive-image-gen · chunk 56