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

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

Introduction

Standard diffusion models are computationally expensive, often requiring dozens or hundreds of iterative steps to denoise a random starting point into a coherent image. This inefficiency stems from the mathematical path—the Probability Flow ODE—from noise to image being highly curved and complex.

Existing acceleration methods come with significant trade-offs. Distillation techniques like LCM often lose fine details compared to the original model. Adversarial training methods, such as SDXL-Turbo, can be unstable to train and prone to mode collapse. Meanwhile, Rectified Flow approaches like InstaFlow attempt to straighten the entire path into a single line, but this requires massive synthetic datasets and suffers from high numerical errors during training.

Piecewise Rectified Flow (PeRFlow) offers a novel acceleration technique that transforms these slow, "curvy" diffusion sampling paths into efficient, piecewise linear trajectories. By dividing the sampling process into discrete time windows and straightening each segment, PeRFlow enables high-quality image generation in as few as 4 steps. Furthermore, it serves as a "universal plug-and-play" module capable of accelerating existing tools like ControlNet and AnimateDiff without requiring retraining.

Methodology: Piecewise Reflow

The core innovation of PeRFlow is Piecewise Reflow. Instead of forcing the entire sampling trajectory into one straight line, PeRFlow divides the time range into $K$ discrete windows (typically 4).

Comparison of original curved probability flow trajectories versus PeRFlow's piecewise linear trajectories.
  1. Divide and Conquer: Within each window, the model is trained to "straighten" the path. This makes the overall trajectory a sequence of short, straight segments, significantly reducing the numerical errors associated with solving the ODE over long intervals.
  2. Real-Data Training: Unlike previous flow-based methods that rely on error-prone synthetic data, PeRFlow uses real training images. It adds noise to a real image to find a starting point in a time window, then uses the "teacher" model to find the target endpoint for that specific window.
  3. Dedicated Parameterization: The model is designed to inherit the exact structure ($\epsilon$-prediction or $v$-prediction) of the pretrained teacher. This allows the student model to start with the teacher's "knowledge," leading to much faster convergence.
  4. The $\Delta W$ Accelerator: After training, the difference in weights between the new model ($\theta$) and the base model ($\phi$)—denoted as $\Delta W$—acts as a standalone acceleration module.

Datasets and Evaluation

The authors validated PeRFlow across several major models, utilizing LAION-Aesthetics-5+ for training Stable Diffusion (SD) v1.5, v2.1, and SDXL. For video, they used $384 \times 384$ resolution clips to train an accelerated AnimateDiff. Performance was evaluated using MS COCO 2014 and JourneyDB prompts, primarily relying on Fréchet Inception Distance (FID) to measure image quality and diversity, and CLIP scores for text-prompt alignment.

Results and Performance

PeRFlow demonstrates a strong balance of high fidelity and rapid generation, outperforming several state-of-the-art acceleration methods.

Visual comparison of PeRFlow against Base-DDIM, LCM-LoRA, and Lightning.
  • Superior Quantitative Metrics: On SDXL, the 4-step PeRFlow achieved an FID of 13.30 on LAION-5B, outperforming SDXL-Lightning (15.47) and LCM-LoRA (13.66). It also achieved a CLIP score of 0.337, matching the performance of the original 25-step SDXL model in a fraction of the steps.
  • Visual Quality: Qualitatively, PeRFlow images retain more texture and finer details (such as hair and skin pores) compared to LCM-based methods, which can sometimes appear "smoothed over."
  • The "Universal" Property: The $\Delta W$ weights are highly transferable. A PeRFlow module trained on a base model like SD v1.5 can be "plugged" into a completely different fine-tuned model (like DreamShaper) or a specialized module (like ControlNet-Tile) to accelerate them instantly without additional training. The authors demonstrated this versatility through 1-step multiview generation (via Wonder3D) and 4-step high-resolution image enhancement.
  • Diversity vs. Quality: The paper introduces two modes for Classifier-Free Guidance (CFG). CFG-sync maintains the original model's creative diversity, while CFG-fixed prioritizes structural correctness and visual quality at the cost of some variety.

Limitations and Future Work

While PeRFlow excels at 4-8 steps, it currently struggles to produce high-quality results in just 1 or 2 steps, as the piecewise linear approximation begins to break down when the number of windows is too small. Additionally, for extremely intricate structures (like complex mechanical parts), the model may still require more than 4 steps to avoid artifacts. Future work will explore "multi-stage training" to push the boundaries of 1-2 step generation and refine "on-the-fly" target synthesis for even more efficient training.

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