Constrained Diffusion Models via Dual Training

Shervin Khalafi, Dongsheng Ding, Alejandro Ribeiro

Diffusion models (DMs) have established themselves as the state-of-the-art for high-fidelity generative modeling across images, video, and molecular structures. However, these models are prone to inheriting and amplifying biases present in their training data. Furthermore, when fine-tuned on new datasets, they often suffer from catastrophic forgetting, losing the diversity of their original pre-training.

Presented at NeurIPS 2024, "Constrained Diffusion Models via Dual Training" introduces a mathematically rigorous framework to embed requirements—such as fairness or data retention—directly into the training objective. By treating diffusion training as a constrained optimization problem, the authors provide a principled alternative to heuristic re-weighting methods.

The Problem: Bias and Forgetting

Standard diffusion models minimize a denoising matching loss, effectively learning to replicate the distribution of the training data. If the training set is imbalanced (e.g., skewed demographic representation), the model naturally replicates this imbalance. Similarly, when a pre-trained model is adapted to a specific new task or small dataset, it often collapses toward the new data, losing its ability to generate the broader distribution it once knew. Existing solutions often rely on manual sample re-weighting or ad-hoc adjustments that lack theoretical guarantees or transparency.

Methodology: Lagrangian Dual Training

The authors propose casting diffusion training as a constrained distribution optimization problem. The goal is to minimize the KL divergence between the model's distribution and the target data distribution, subject to constraints that ensure the model remains close to other "desirable" distributions (e.g., a minority class or the original pre-training distribution).

The Dual Training Loop

To solve this, the researchers utilize Lagrangian Duality. They introduce dual variables (Lagrange multipliers) for each constraint, transforming the problem into a minimax game. The training follows a dual loop (Algorithm 1):

  1. Primal Step: The model parameters are updated to minimize a weighted loss function.
  2. Dual Step: The Lagrange multipliers are updated based on constraint satisfaction. If a constraint is violated, its multiplier increases, forcing the model to prioritize that specific requirement in the next iteration.

Crucially, the authors demonstrate that this constrained objective, termed U-LOSS, is a weighted sum of standard denoising losses. This ensures the method is compatible with existing deep learning architectures like U-Nets and Latent Diffusion Models.

Theoretical Insights

The paper offers two key theoretical contributions that clarify how constraints affect generative modeling:

  • The Optimal Mixture (Theorem 1): The authors prove that the optimal constrained model generates data from a mixture distribution. It is a mathematically optimal blend of the primary data and the constraint distributions, rather than a simple interpolation.
  • The Role of Entropy (Theorem 2): The research reveals that the weight assigned to a constraint is not solely dependent on the user-defined threshold; it is also influenced by the differential entropy of the target distribution. More diverse (higher entropy) distributions require more significant weighting to satisfy the same constraint thresholds.

Experimental Results

The framework was evaluated on MNIST, Celeb-A, and ImageNet, yielding several significant findings:

1. Fairness and Representation

In experiments using a biased version of MNIST (where digits 4, 5, and 7 were underrepresented), unconstrained models failed to generate the minority classes. The constrained model, however, achieved a nearly uniform distribution across all digits. On Celeb-A, the model successfully balanced gender representation even when the training data was skewed.

2. Quality Improvements

Enforcing constraints did not come at the cost of image quality. In fact, the constrained models often achieved lower (better) FID scores. For instance, on MNIST, the FID improved from 15.9 to 13.4, suggesting that enforcing fairness can act as a regularizer that helps the model learn more robust representations.

3. Adaptation without Forgetting

When fine-tuning a model on a new class (e.g., MNIST digit 9), the constrained approach allowed the model to learn the new data while retaining its knowledge of digits 0-8. In contrast, standard fine-tuning baselines quickly overfit, losing the ability to generate anything but the new class.

Limitations and Future Directions

While the empirical results are strong, the authors note that their current mathematical proofs assume "disjoint supports" (non-overlapping distributions) between the objective and constraints. While the method works in practice even when distributions overlap, the theoretical framework for the overlapping case remains an open area for research. Additionally, while the computational overhead is negligible for a few constraints, scaling to hundreds of complex constraints may require further optimization.

Future work may involve extending this framework to text-to-image models, allowing for prompt-based constraints, and exploring "mirror diffusion" to handle complex domain-specific requirements.

Summary updated

BibTeX
@inproceedings{khalafi2024constrained,
  author = {Shervin Khalafi and Dongsheng Ding and Alejandro Ribeiro},
  title = {{Constrained Diffusion Models via Dual Training}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=Es2Ey2tGmM},
}
Figure