Contextual Flow Matching: Adaptive Step Selection in Flow Models for Efficient Visual Generation
Organizations: Department of IEOR IIT Bombay, Mumbai, India · SMART Centre Singapore
Abstract
Flow Matching enables high-quality visual generation via continuous-time dynamics, but inference remains costly due to multiple sequential function evaluations. Existing acceleration methods reduce the number of function evaluations but often introduce additional training overhead, degrade quality, or fail to account for input-dependent variability. We propose COFLOW, an inference-time method that adaptively selects the step counts each generation based on the prompt features. Our context-aware COFLOW is trained online with an unsupervised reward that balances inference efficiency and generation fidelity. Our method is plug-and-play, requiring no retraining of the underlying generative model. It generalizes to image and video generation, achieving over 2.5x speedup while preserving perceptual and semantic quality. We further provide a theoretical analysis establishing an O(1/K) forward-Euler discretization error bound under standard regularity conditions.
Figures & tables
| Method | BAGEL | FLUX | ||||||
| Overall | IQA | NFE | Time | Overall | IQA | NFE | Time | |
| Full Model | ||||||||
| Full-50 | 0.78 | 0.65 | 50 | 76.4 | 0.66 | 0.75 | 50 | 34.1 |
| Full-25 | 0.75 | 0.62 | 25 | 40.9 | 0.64 | 0.71 | 25 | 17.3 |
| Full-10 | 0.71 | 0.54 | 10 | 18.9 | 0.57 | 0.63 | 10 | 7.26 |
| Static Baselines | ||||||||
Appendix figures & tables17 assets
Supplementary material from the paper’s appendix.
Appendix
| Method | Time (s) |
| Full Model | |
| Full-50 | 75.6 |
| Full-25 | 40.1 |
| Ours | |
| NCB-50 | 76.4 |
| NCB-25 | 40.9 |
| Method | Compositional Dimensions | Overall Metrics | |||||||
| SO | TO | CO | CL | CA | PO | Overall | CLIPIQA | NFE | |
| Full Model | |||||||||
| Full-50 | 0.99 | 0.90 | 0.81 | 0.85 | 0.59 | 0.54 | 0.78 | 0.65 | 50 |
| Full-25 | 0.99 | 0.90 | 0.76 | 0.81 | 0.60 | 0.49 | 0.75 | 0.62 | 25 |
| Full-10 | 0.99 | 0.85 | 0.67 | 0.78 | 0.56 | 0.46 | 0.71 | 0.54 | 10 |
| Static Baselines | |||||||||
| Method | Compositional Dimensions | Overall Metrics | |||||||
| SO | TO | CO | CL | CA | PO | Overall | CLIPIQA | NFE | |
| Full Model | |||||||||
| Full-50 | 0.97 | 0.79 | 0.75 | 0.78 | 0.48 | 0.20 | 0.66 | 0.75 | 34.1 |
| Full-25 | 0.97 | 0.78 | 0.71 | 0.75 | 0.45 | 0.18 | 0.64 | 0.71 | 17.3 |
| Full-10 | 0.97 | 0.65 | 0.58 | 0.67 | 0.41 | 0.15 | 0.57 | 0.63 | 7.26 |
| TeaCache | 0.97 | 0.76 | 0.73 | 0.74 | 0.44 | 0.18 | 0.63 | 0.72 | 20.8 |
| Analysis | Spearman |
| Pooled prompt–budget pairs | 0.822 |
| Mean within-prompt | 0.924 |
| Median within-prompt | 0.970 |
| Mean cross-prompt at fixed budget | 0.255 |
| Method | Overall | IQA | NFE | Time |
| Ours + UCB (No Context) | 0.74 | 0.60 | 20.2 | 31.9 |
| Ours + UCB | 0.77 | 0.65 | 17.7 | 27.5 |
| Ours + TS | 0.76 | 0.65 | 17.5 | 26.9 |
| Context | Mean NFE | Max-step rate |
| No context | 39.75 | 65.4% |
| Handcrafted only | 37.79 | 52.9% |
| MiniLM only | 39.58 | 60.0% |
| Full | 37.67 | 47.9% |
| Rounds | Reward | NFE | Max-step rate |
| 1–10 | 0.520 | 43.2 | 72.0% |
| 11–20 | 0.548 | 40.5 | 63.3% |
| 21–40 | 0.566 | 38.7 | 55.8% |
| 41–60 | 0.575 | 37.9 | 51.6% |
| 61–80 | 0.578 | 37.6 | 50.4% |
| 81–100 | 0.580 | 37.4 | 49.8% |
| Policy | Reward | NFE | Max-step rate | Action entropy |
| Greedy | ||||
| NeuralUCB |
| Method | Compositional Dimensions | Overall Metrics | |||||||
| SO | TO | CO | CL | CA | PO | Overall | CLIPIQA | NFE | |
| Full Model | |||||||||
| Full-10 | 0.99 | 0.79 | 0.37 | 0.88 | 0.21 | 0.15 | 0.57 | 0.72 | 10 |
| Full-6 | 0.99 | 0.78 | 0.36 | 0.86 | 0.20 | 0.15 | 0.55 | 0.68 | 6 |
| Full-3 | 0.98 | 0.75 | 0.29 | 0.85 | 0.18 | 0.12 | 0.52 | 0.62 | 3 |
| Ours | |||||||||
| Method | GenEval | CLIP-IQA | NFE | Time |
| Baseline Methods | ||||
| TeaCache | 0.74 | 0.59 | 29.4 | 45.8 |
| FastFlow | 0.75 | 0.59 | 20.9 | 32.9 |
| FlowCast | 0.76 | 0.60 | 21.5 | 34.2 |
| With Ours (Adaptive Step Selection) | ||||
| TeaCache + Ours | 0.71 | 0.55 | 16.8 | 25.7 |
| Hyperparameter | FLUX | BAGEL | ||
| Generation | Editing | Generation | Editing | |
| Image resolution | – | – | ||
| Guidance scale | ||||
| Guidance rescale | ||||
| CFG interval | – | – | ||
| Method | Characteristics | GenEval | IQA | NFE |
| Base Solvers (50 Steps) | ||||
| Euler | Deterministic, 1st-order | 0.60 | 0.71 | 50 |
| Euler-anc | Stochastic, 1st-order | 0.57 | 0.72 | 50 |
| DPM++2M | Deterministic, multistep | 0.59 | 0.70 | 50 |
| DPM++2S-anc | Stochastic, multistep | 0.57 | 0.71 | 50 |
| Heun | Deterministic, 2nd-order | 0.59 | 0.70 | 50 |
| Feature | Definition | Description |
| Word count | Captures prompt length and compositional richness. Longer prompts typically involve more entities, relations, or attributes, increasing reasoning complexity. | |
| Subword diversity (TTR) | Measures lexical diversity. Higher diversity indicates richer semantics and reduced redundancy, often correlating with more complex generation requirements. | |
| Mean word length | Acts as a proxy for linguistic specificity. Longer words often correspond to more descriptive or specialized concepts. | |
| Numeric fraction | Captures numerical constraints (e.g., counts or quantities), which increase compositional difficulty and require precise control in generation. | |
| Object density (POS-based) | Measures the number of entities in the prompt. Higher density implies more objects and interactions, increasing spatial and compositional complexity. | |
| Attribute density (POS-based) | Captures descriptive richness. More attributes introduce finer-grained constraints (e.g., color, size), making generation more demanding. |