PeRFlow: Piecewise Rectified Flow as Universal Plug-and-Play Accelerator

Hanshu Yan, Xingchao Liu, Jiachun Pan, Jun Hao Liew, Qiang Liu, Jiashi Feng

Abstract

We present Piecewise Rectified Flow (PeRFlow), a flow-based method for accelerating diffusion models. PeRFlow divides the sampling process of generative flows into several time windows and straightens the trajectories in each interval via the reflow operation, thereby approaching piecewise linear flows. PeRFlow achieves superior performance in a few-step generation. Moreover, through dedicated parameterizations, the PeRFlow models inherit knowledge from the pretrained diffusion models. Thus, the training converges fast and the obtained models show advantageous transfer ability, serving as universal plug-and-play accelerators that are compatible with various workflows based on the pre-trained diffusion models. Codes for training and inference are publicly released.

Introduction

Diffusion models have established themselves as the gold standard for high-fidelity image synthesis. However, their primary drawback remains the "speed tax": the requirement for dozens of iterative sampling steps to produce a single clean image. While existing acceleration techniques like Latent Consistency Models (LCM) or adversarial distillation (e.g., SDXL-Turbo) offer speedups, they often introduce trade-offs such as loss of fine detail, training instability, or mode collapse.

PeRFlow (Piecewise Rectified Flow) addresses these challenges by reimagining the sampling trajectory. Instead of attempting to straighten the entire curved path of a diffusion model into a single line—a process prone to numerical error—PeRFlow adopts a "divide-and-conquer" approach, linearizing the trajectory within specific time windows. This results in a lightning-fast generator capable of producing high-quality images in just 4 steps while remaining fully compatible with the existing Stable Diffusion ecosystem.

Methodology

Piecewise Rectification

The core innovation of PeRFlow is the division of the sampling timeline into several discrete intervals. Within each window, the model learns to "straighten" the sampling path through a reflow operation. By focusing on shorter segments, the model can utilize real training data and perform online simulations more effectively than previous global flow-matching methods like InstaFlow. This piecewise linearity allows the ODE solver to take much larger steps during inference without drifting from the intended data distribution.

Velocity-Field Parameterization

To ensure the model retains the creative capabilities of its predecessors, the researchers derived a mathematical bridge between the standard noise prediction ($\epsilon$-prediction) of diffusion models and the velocity fields used in flow-based models. This dedicated parameterization allows PeRFlow to inherit the weights and "knowledge" of the original pre-trained model, leading to significantly faster training convergence.

The Reflow-Delta ($\Delta W$) Module

One of the most practical outcomes of this research is the discovery that the acceleration logic can be isolated. By calculating the difference between the base model weights and the PeRFlow-trained weights ($\Delta W = \theta - \phi$), the authors created a "speed-up module." This delta acts as a universal plug-and-play accelerator. It can be applied to various fine-tuned models—such as specific artistic styles or ControlNet architectures—to accelerate them instantly without requiring model-specific retraining.

Key Insights and Innovations

  • Efficiency through Straightening: In generative flows, a straight trajectory represents the most efficient path from Gaussian noise to a clean image. PeRFlow’s piecewise approach ensures this efficiency is achieved without the complexity of global linearization.
  • CFG Baking: To maintain prompt adherence at low step counts, the authors introduced "CFG-fixed" training. This process effectively "bakes" the effects of Classifier-Free Guidance into the straightened trajectories, allowing for high-quality results even with minimal guidance scales during inference.
  • Ecosystem Compatibility: Because the acceleration is captured as a weight delta, PeRFlow is uniquely compatible with tools like IP-Adapter (for image-prompting) and Wonder3D (for multi-view generation).

Experimental Results

PeRFlow was evaluated using industry-standard datasets including LAION-Aesthetics-5+, MS COCO 2014, and JourneyDB. The results demonstrate a clear advantage in both quantitative metrics and qualitative fidelity:

  • Superior Quality: In 4-step generation, PeRFlow achieved an FID score of 9.28 on SDXL, significantly outperforming competitors like SDXL-Lightning (11.41) and LCM-LoRA.
  • Visual Fidelity: Qualitative assessments show that PeRFlow preserves intricate textures and prompt alignment better than previous distillation methods, which often produce overly smoothed images.
  • Versatility: The framework successfully enabled one-step generation for multi-view 3D tasks in Wonder3D and maintained high performance when integrated with various ControlNet modules.

Conclusion and Future Work

PeRFlow provides a robust framework for transforming slow diffusion models into efficient, high-fidelity generators. By leveraging piecewise rectified flows and a universal delta-weight approach, it offers the community a powerful tool for real-time generation. While the current model is optimized for 4-step generation, future research aims to push these boundaries toward reliable 1-step and 2-step high-fidelity synthesis for even more complex structural tasks.

Reference: Yan, H., et al. (2024). PeRFlow: Piecewise Rectified Flow as Universal Plug-and-Play Accelerator. arXiv:2405.07510v5.

Summary updated

BibTeX
@inproceedings{yan2024perflow,
  author = {Hanshu Yan and Xingchao Liu and Jiachun Pan and Jun Hao Liew and Qiang Liu and Jiashi Feng},
  title = {{PeRFlow: Piecewise Rectified Flow as Universal Plug-and-Play Accelerator}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=qrlguvKu7a},
}
Figure