对比四种常微分方程求解器,发现高阶方法在低计算量下更高效且适合弱模型。
From Euler to Dormand-Prince: ODE Solvers for Flow Matching Generative Models

- 从泰勒展开推导经典求解器,用PyTorch实现并系统测试
- RK4在80次函数求值时质量媲美欧拉法200次,效率显著提升
- 求解器性能受模型训练程度影响,弱模型下高阶方法优势更明显
流匹配生成模型的采样需求解常微分方程,其计算开销主要来自神经网络前向传播。本文通过泰勒展开从头推导四种经典求解器——欧拉法、显式中点法、经典龙格-库塔(RK4)和多兰德-普赖斯5(4)——并在PyTorch中从零实现,系统评估其在条件流匹配任务中的效率,涵盖二维玩具分布到MNIST图像。定量方面,使用切片沃瑟斯坦距离构建NFE-质量帕累托前沿,发现RK4在80次函数求值时的样本质量可媲美欧拉法在200次下的表现。除验证已知收敛率外,还发现两个经验现象:(1) 学习到的速度场雅可比特征值谱在t=1附近急剧变陡,解释了自适应多兰德-普赖斯求解器为何自动将步长预算集中在轨迹末尾;(2) 对于训练不足或参数量较小的模型,低阶与高阶求解器之间的质量差距扩大,表明求解器选择在模型不完善时尤为关键。代码与所有实验脚本均已公开。
原文摘要 · Abstract (English)
Sampling from Flow Matching generative models requires solving an ordinary differential equation (ODE) whose computational cost is dominated by neural network forward passes. We derive four classical ODE solvers -- Euler, Explicit Midpoint, Classical Runge-Kutta (RK4), and Dormand-Prince 5(4) -- from first principles via Taylor expansion, implement them from scratch in PyTorch, and systematically benchmark their efficiency on Conditional Flow Matching tasks ranging from 2D toy distributions to MNIST digits. On the quantitative side, we use sliced Wasserstein distance to construct NFE-quality Pareto frontiers,finding that RK4 at 80 function evaluations achieves sample quality comparable to Euler at 200. Beyond reproducing known convergence rates, we report two empirical observations: (1) the Jacobian eigenvalue spectrum of the learned velocity field stiffens sharply near t=1, explaining why the adaptive Dormand-Prince solver automatically concentrates its step budget at the end of the trajectory; (2) the quality gap between low-order and high-order solvers widens for undertrained and smaller models, indicating that solver choice matters most when the model is imperfect. Code and all experiment scripts are publicly available.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。