TL;DR
This paper provides a rigorous theoretical foundation for guidance in diffusion models, proving that positive guidance strength guarantees stronger alignment with the target condition while strictly preserving the true data support. By framing guidance scheduling as a Stochastic Optimal Control problem, the authors introduce a scalable framework to learn dynamic, time-dependent guidance schedules that outperform traditional constant-weight heuristics.
What Problem Does This Paper Address?
Classifier-Free Guidance (CFG) is a crucial component in modern generative AI, allowing diffusion models to generate samples that closely align with text prompts or class labels. Despite its widespread success, the way we choose guidance strength ($w$) is almost entirely heuristic. Practitioners typically pick a constant value (usually between 3 and 16) by trial and error.
This reliance on heuristics leaves significant gaps:
- Theoretical Ambiguity: There has been a lack of formal guarantees regarding what distribution guided sampling actually targets.
- Support Recovery Concerns: A common misconception in the community was that strong guidance might distort the generation process so much that samples drift away from the true data manifold.
- Suboptimality: A fixed, constant guidance weight throughout the entire generation process is unlikely to be optimal.
This paper tackles these issues by providing formal mathematical guarantees for guidance and presenting a principled method to dynamically optimize the guidance schedule.
Methods
The authors approach the problem in two phases: theoretical formalization and optimal control.
1. Theoretical Analysis
The authors analyze the "guiding field" along backward trajectories using Ito's lemma and the Fokker-Planck equation. They prove that applying any positive guidance strength ($w > 0$) increases the average likelihood of the target class. Crucially, they establish Theorem 3 (Support Recovery), which mathematically guarantees that the generated samples will always remain within the support of the true conditional data distribution, dispelling fears of data manifold corruption.
2. Stochastic Optimal Control (SOC) Framework
To find the best guidance schedule, the authors recast the problem as an SOC problem. They define an objective function that balances two competing goals:
- Maximizing the classifier confidence of the final generated sample.
- Minimizing the Kullback-Leibler (KL) divergence between the guided and unguided trajectories (to prevent the model from drifting into low-probability regions where score estimates are poor).
To solve this in high-dimensional spaces, they parameterize the guidance strength $w_\theta(t)$ as a neural network and optimize it using a scalable numerical approach based on the Adjoint State Method and Vector-Jacobian Products (VJPs), avoiding the need to compute expensive matrix derivatives explicitly.
Datasets
The framework was evaluated using the following datasets and models:
- Synthetic Gaussian Mixture: A simple mixture of four Isotropic Gaussians used to solve the exact Hamilton-Jacobi-Bellman (HJB) partial differential equations for visualization.
- ImageNet: Used to evaluate the EDM2 model (at $64 \times 64$ and $512 \times 512$ resolutions) and Stable Diffusion 1.5.
- COCO-captions: Used for text-to-image evaluation on Stable Diffusion 1.5.
Key Insights and Ideas
- Guidance is Inherently Dynamic: When solved exactly for simple distributions, the optimal guidance scale is not constant; it varies continuously across both time and space.
- Different Conditioning, Different Schedules: The optimal schedule depends heavily on how the model is conditioned. For discrete class labels (like EDM2 on ImageNet), the learned schedule follows a bell-shaped curve, peaking in the middle of the generation process. For continuous text embeddings (Stable Diffusion), the guidance starts very high at $t=0$ and monotonically drops to zero.
- Late-Stage Guidance is Unnecessary: For text-to-image models, the optimized guidance strength drops to zero well before the end of the generation process ($t > 1$). This implies that once the layout and core semantics are established early on, guidance can be safely turned off to let the model focus purely on sample quality.
Key Results
The authors compared their learned time-dependent guidance schedules against a standard constant baseline ($\alpha^{-1}$):
- EDM2 Performance: Across various model sizes and regularization strengths ($\alpha$), the optimized schedule consistently yielded higher classifier confidence (measured via an external InceptionV3 network) than the constant baseline, with only a marginal increase in the Fréchet Inception Distance (FID). For instance, on the size-S model with $\alpha=10$, classifier confidence improved from 0.817 to 0.821.
- Qualitative Alignment: Using Stable Diffusion on the COCO dataset, the optimized time-dependent schedule successfully generated highly detailed, well-aligned images based on complex prompts.
Limitations and Future Work
- Full State Dependency: While the theory allows the guidance strength $w$ to depend on time, the prompt, and the current sample state ($w_t(x, c)$), the authors' scalable adjoint method currently only optimizes a time-dependent schedule $w_\theta(t)$. Fully incorporating sample-state dependency ($x$) remains difficult due to gradient instabilities in the underlying score networks.
- Assumption of Perfect Scores: The theoretical guarantees assume that the diffusion model provides a perfect estimation of the score function. In practice, neural network approximations introduce errors, which might interact unpredictably with the optimized guidance schedules.
Summary updated