TL;DR
This paper introduces StreamFlow, a novel acceleration framework designed specifically for Rectified Flow and Flow Matching generative models. By decoupling velocity field computation from step size constraints and employing dynamic TensorRT compilation, StreamFlow achieves a remarkable up to 611% speedup in image generation without sacrificing quality, overcoming limitations of existing diffusion-model-centric acceleration techniques.
What Problem Does This Paper Address?
Generative models like Rectified Flow and Flow Matching have shown great promise, offering improved control, quality, and efficiency compared to traditional diffusion models. These newer methods learn a velocity field to directly guide the generation process, enabling faster sampling (e.g., 4-step generation). However, existing acceleration techniques, largely developed for diffusion models, struggle to be directly applied to Rectified Flow due to fundamental differences in their underlying theory, design, and execution structure. Specifically, Rectified Flow models deal with time-dependent velocity fields rather than noise prediction, use variable time steps, and have dynamic structures that often lead to compilation failures with standard optimization tools like TensorRT. This gap limits the practical deployment of these advanced generative models, especially in applications requiring real-time performance.
Methods
StreamFlow tackles these challenges with a multi-pronged approach:
- Batched Velocity Field Computation: Instead of processing each sample's velocity field sequentially, StreamFlow treats them as a batch. It decouples the velocity field computation from the step size, allowing for vectorized processing of heterogeneous time steps. This is achieved by introducing a "Decoupled Time-Step Binding" mechanism and a "Unified Adaptive Scheduler."
- Vectorized Heterogeneous Time-Step Batching: The framework handles variable time steps across different samples within a batch. It synchronizes velocity outputs from parallel queues, each potentially processing different time intervals, ensuring algorithmic correctness.
- Dynamic TensorRT Compilation: To overcome the static graph limitations of traditional compilers like TensorRT, StreamFlow implements a dynamic compilation strategy. It detects whether a batch is homogeneous (all samples have the same time steps) or heterogeneous. For homogeneous batches, it uses a pre-compiled TensorRT engine. For heterogeneous batches, it decomposes the batch and applies TensorRT to individual samples, still yielding significant speedups due to operator fusion and memory optimization. This approach is designed to be "plug-and-play," requiring no modifications to existing TensorRT-compiled models.
Datasets
Not explicitly detailed in the paper, but the experiments are conducted on image generation tasks, implying the use of standard image datasets for training and evaluation of generative models. The paper mentions generating 512x512 images.
Key Insights and Ideas
- Rectified Flow's unique challenges: The paper highlights that Rectified Flow's reliance on velocity fields and variable time steps fundamentally differs from diffusion models, necessitating a specialized acceleration approach.
- Decoupling is key: The core insight is decoupling the velocity field computation from step size constraints. This allows for efficient batching and vectorization, even with heterogeneous time steps.
- Dynamic compilation for flexibility: Recognizing that static compilation fails for dynamic structures, the paper proposes a runtime adaptive strategy that handles both homogeneous and heterogeneous batches, maximizing the benefits of TensorRT.
- Batching is not just for diffusion: The success of batching in diffusion models is adapted and extended to Rectified Flow, proving its broader applicability in accelerating generative models.
Key Results
StreamFlow achieves significant speedups:
- Up to 611% speedup: The paper reports accelerating 512x512 image generation by up to 611% compared to baseline methods.
- Significant FPS increase: The optimized pipeline achieves 10.05 FPS with TensorRT and 8.0 FPS with Xformer, compared to baseline speeds of 1.87-2.22 FPS.
- Minimal quality degradation: The acceleration methods have a negligible impact on generation quality, with CLIP Score and FID scores showing less than 1% variation compared to baselines.
- Robustness to resolution: The framework demonstrates strong scalability, maintaining substantial speedup ratios even at resolutions up to 1024px, outperforming baselines that suffer significant performance degradation.
- Power and memory efficiency: StreamFlow reduces power consumption by up to 47% and memory usage by 20-30%, leading to approximately 11x better performance per watt.
Limitations and Future Work
- Limitations:
- The dynamic compilation strategy for heterogeneous batches involves decomposing the batch, which introduces a slight overhead compared to a fully compiled homogeneous batch. However, this overhead is minimal, and substantial speedups are still achieved.
- The paper notes that while the compatibility layer for TensorRT enhances stability, it introduces a minor trade-off in speed.
- Future Work:
- The paper suggests that their framework is compatible with existing Rectified Flow models and can be used in combination with other acceleration methods, implying potential for further integration and improvement.
- The authors aim to make large-scale flow models more readily deployable, suggesting future work could focus on broader adoption and application in real-world scenarios.
Summary updated