TL;DR
This paper identifies a critical failure of optimal transport (OT) in conditional generative models: it skews the prior distribution during training, leading to a performance gap at test time. They introduce Conditional Optimal Transport (C2OT), a simple yet effective method that corrects this skew by incorporating a condition-aware cost into OT, significantly improving conditional generation quality across various datasets and conditions.
What Problem Does This Paper Address?
Generative models that can produce samples conditioned on specific inputs (like class labels or text prompts) are crucial for many applications. Flow-based generative models, particularly those using flow matching (FM), offer a promising approach. FM learns a continuous transformation (a "flow") from a simple prior distribution (e.g., Gaussian noise) to a complex data distribution. However, solving this flow at test time can be computationally expensive due to curved flow paths, requiring many steps of an ODE solver.
To address this, researchers proposed using minibatch optimal transport (OT) to "straighten" these flow paths, making inference faster and more efficient. While OT works well for unconditional generation, this paper highlights a significant problem when applying it to conditional generation. The core issue is that standard OT, when used to couple data and a prior, disregards the conditioning information. This leads to a "skewed prior" during training: the model learns to associate specific parts of the prior distribution with specific conditions. At test time, however, the model samples from the unskewed, full prior distribution, creating a mismatch that degrades performance. This paper aims to bridge this gap and enable the benefits of OT for conditional generation.
Methods
The paper's main contribution is Conditional Optimal Transport (C2OT). The core idea is to modify the OT cost function to explicitly account for the condition.
- The Problem with Standard OT: In unconditional generation, OT couples samples from the prior ($X_0$) and the data ($X_1$) by finding a permutation matrix $P$ that minimizes the distance between them. This results in a joint distribution $\pi_{ot}(x_0, x_1)$ where the marginals $q(x_0)$ and $q(x_1)$ remain unchanged. However, when conditions ($C$) are introduced, naively extending this to $\pi_{ot}(x_0, x_1, c)$ by coupling $(X_0, PX_1, PC)$ breaks this property. The prior $q(x_0)$ becomes dependent on the condition $c$ (i.e., $q(x_0|c) \neq q(x_0)$), which is inaccessible at test time.
- C2OT Formulation: C2OT aims to enforce $q(x_0|c) = q(x_0)$ even with OT coupling. This is achieved by modifying the OT cost function to penalize couplings between samples with different conditions.
- Discrete Conditions: For discrete conditions (e.g., class labels), a hard constraint is used: the cost is infinite if conditions don't match, effectively performing OT independently within each class.
- Continuous Conditions: For continuous conditions (e.g., embeddings), a relaxed cost function based on cosine distance is used. This prevents the degeneration seen with discrete conditions.
- Adaptive Hyperparameter Tuning: A key challenge for continuous conditions is tuning a weighting hyperparameter ($w$) in the cost function. The paper introduces an adaptive mechanism using a "target ratio" ($r_{tar}$) to automatically find a suitable $w$ for each minibatch, reducing manual tuning.
- Oversampling: To compensate for the reduced effective OT batch size caused by the condition-aware coupling, the paper suggests oversampling OT batches (using a larger batch size for OT computation than for the neural network).
Datasets
The paper evaluates C2OT on a variety of datasets:
- 8gaussians→moons: A 2D synthetic dataset used for initial visualization and analysis.
- CIFAR-10: A standard 32x32 image dataset for class-conditioned generation.
- ImageNet-32x32: A larger image dataset used for caption-conditioned generation.
- ImageNet-256x256: The largest dataset used, for caption-conditioned generation in latent space.
Key Insights and Ideas
- The "Curse of Conditions" for OT: The most significant insight is that standard optimal transport, while beneficial for unconditional generation, actively harms conditional generation by creating a train-test mismatch due to prior skewing. This is a counter-intuitive finding that challenges existing assumptions.
- Prior Skewing is the Root Cause: The paper rigorously demonstrates why OT fails in the conditional setting, pinpointing the skewed prior distribution as the fundamental problem.
- Simple Fix, Big Impact: C2OT is presented as a simple modification to the OT cost function, yet it yields substantial improvements, highlighting the power of addressing the core theoretical issue.
- Condition-Awareness is Key: The success of C2OT underscores the importance of explicitly incorporating conditioning information into the coupling mechanism, rather than treating it as an afterthought.
- Adaptive Tuning for Practicality: The adaptive mechanism for finding the hyperparameter $w$ in continuous conditions is crucial for making C2OT practical and robust across different datasets.
Key Results
- Improved Conditional Generation: C2OT consistently outperforms standard Flow Matching (FM) and minibatch Optimal Transport (OT) in conditional generation tasks across all tested datasets and condition types (discrete and continuous).
- Reduced 2-Wasserstein Distance: On the 2D 8gaussians→moons dataset, C2OT achieves significantly lower 2-Wasserstein distances (e.g., 0.048±0.010 for binary conditions with Euler-1) compared to FM (2.573±0.112) and OT (0.483±0.059).
- Better FID and Condition Adherence: On high-dimensional image datasets like CIFAR-10 and ImageNet, C2OT achieves competitive or superior Fréchet Inception Distances (FID) and better condition adherence metrics (e.g., cross-entropy for CIFAR-10, CLIP similarity for ImageNet), especially in few-step inference settings.
- Stable Performance: C2OT demonstrates more stable performance across different runs and settings compared to baselines.
- Efficiency: C2OT enables faster inference with fewer ODE solver steps while maintaining high quality, and the proposed oversampling strategy mitigates computational overhead.
Limitations and Future Work
- Diminishing Returns in High Dimensions: The paper notes that the benefits of C2OT are less pronounced in higher-dimensional image data compared to lower-dimensional data. They hypothesize this is because image data is more entangled, making the prior skew induced by OT less detrimental.
- Computational Cost of OT: While addressed with oversampling and offloading, the inherent $O(b^3)$ complexity of OT (with Hungarian matching) can still be a bottleneck for very large batch sizes.
- Future Work: The authors suggest that their findings and method can be integrated with other advancements in flow matching and consistency models. They also implicitly suggest further exploration into why the benefits are less pronounced in high dimensions.
Summary updated