Few-Step Flow Sampling: Why 2nd-Order Heun Loses Badly to 1st-Order Euler at 2 NFE
Across 375 quality settings and 600 CUDA timing runs on an isomorphic 745k-parameter MicroDiT: why full-step Heun overshoots off-manifold at 2 NFE, when Shortcut wins, and how Inductor BF16 fusion shifts rounding.
Same 2 Function Evaluations, 4.7× Worse Feature Distance
Benchmarking OT-CFM, 2-Rectified-Flow, and Shortcut on procedural optical diffraction/interference patterns ( RGB) using an identical 745,136-parameter MicroDiT backbone and matched update budget exposed a striking reversal at 2 NFE:
Evaluating the exact same OT-CFM weights from identical initial noise, two-step explicit Euler achieved a feature Sliced Wasserstein Distance (SWD, lower is better) of 0.1692, whereas one-step Heun (2nd-order predictor–corrector) degraded to 0.7929—with 31.14% of raw output channels saturating outside before clipping, compared to 0.012% for Euler.
Mechanism: Full-Step Extrapolation Queries an Out-of-Distribution Endpoint
Writing out both 2 NFE rules side by side pinpoints the failure:
- Two-step Euler advances halfway first, re-querying the network at where noisy interpolation paths overlap densely during training.
- One-step Heun extrapolates the coarse tangent all the way to (). At , training supervision is concentrated strictly on clean data samples; the crude predictor lands off-manifold where the learned velocity field is poorly constrained, mixing a large endpoint error back in with weight .
Across low-NFE budgets, staying inside well-supported intermediate marginals matters far more than asymptotic solver order:
| Objective & Sampler | NFE | Feature SWD ↓ | Operating Sweet Spot |
|---|---|---|---|
OT-CFM + 1-step Euler |
1 | 0.3287 | Naive tangent baseline |
2-Rectified-Flow + 1-step Euler |
1 | 0.1985 | Sharpest 1-step edge fidelity (0.836) |
Shortcut + direct step () |
1 | 0.1819 | Best 1-NFE distribution (-44.7% SWD) |
Shortcut + 2 equal steps () |
2 | 0.1587 | Best 2-NFE point (keep dyadic grid!) |
OT-CFM + 4-step uniform Euler |
4 | 0.1436 | Best overall 4-NFE distribution |
One practical pitfall: because Shortcut trains on dyadic step sizes , feeding a non-uniform 2-step schedule at test time worsens SWD from 0.1587 to 0.6466.
torch.compile 3.24× Speedup & BF16 Cast Alignment
On an RTX 4060 Ti (batch = 1, BF16 autocast), compiling the 4-step OT-CFM network via TorchInductor cut steady-state median latency from 29.57 ms to 9.14 ms (3.24× speedup). However, fused kernels bypass eager intermediate BF16 downcasts, pushing worst-case paired trajectory drift to 0.386 RMSE. Enabling explicit cast emulation restores numerical parity (0.386 → 0.119 worst-case, 0.0088 median RMSE) at only a 2.5% latency cost:
compiled_net = torch.compile(
model,
backend="inductor",
fullgraph=True,
dynamic=False,
options={"emulate_precision_casts": True},
)
Measured datasets & code: 375-row quality matrix · 600-row CUDA latency log · Precision cast probes · MIT core source ZIP