arXiv:2610.05845cs.LGOct 2026

Manuscript Offprint

arXiv:2610.05845

CACFG: Curvature-Aware Classifier-Free Guidance and Optimal Control

Max Collins, Dasith de Silva Edirimuni, Jordan Vice, Tim French, Ajmal Mian

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Max Collins

School of Physics, Maths and Computing

The University of Western Australia

Perth, WA 6009

max.collins@research.uwa.edu.au

Jordan Vice

School of Physics, Maths and Computing

The University of Western Australia

Perth, WA 6009

jordan.vice@uwa.edu.au

Dasith de Silva Edirimuni

School of Physics, Maths and Computing

The University of Western Australia

Perth, WA 6009

dasith.desilva@uwa.edu.au

Ajmal Mian

School of Physics, Maths and Computing

The University of Western Australia

Perth, WA 6009

ajmal.mian@uwa.edu.au

Tim French

School of Physics, Maths and Computing

The University of Western Australia

Perth, WA 6009

tim.french@uwa.edu.au

ABSTRACT

Diffusion models generate samples by learning to reverse a fixed corruption process, and classifier-free guidance (CFG) is the standard mechanism for conditioning this process on a desired class or prompt. CFG can be applied at varying guidance strengths, and while higher strengths improve image quality and conditional alignment, too high a guidance strength can degrade image quality and diversity. Furthermore, CFG violates principled diffusion sampling dynamics, and existing explanations for why it works despite the violation disagree on the underlying theory or do not extend to deterministic samplers used in practice. We address both these issues. We first frame CFG sampling as a continuous-time optimal control problem, treating the sampling trajectory as a sequence of controls chosen to maximise the probability of the desired condition. Solving the resulting Hamilton–Jacobi–Bellman equation shows that CFG is recovered under specific path costs when using an unconstrained control set. We argue this lack of constraint is responsible for CFG's failure at high guidance strengths, since it permits the sampling path to move arbitrarily far from the current image estimate. To fix this, we propose curvature-aware CFG (CACFG), which constrains the control set to a hypersphere informed by the Gaussian regularisation used when training variational autoencoders. We show that the control inputs produced by CFG sampling routinely violate this bound, and that across diffusion models, datasets, and guidance schedules, CACFG achieves superior generative quality at mid-to-high guidance strengths with a less severe quality-diversity tradeoff than regular CFG.

1 INTRODUCTION

Diffusion models generate samples by learning to iteratively reverse a fixed process that gradually corrupts data with noise (Ho et al., 2020; Song et al., 2021b). Classifier-free guidance (CFG) (Ho & Salimans, 2022) provides a mechanism to control the content of generated images by using a variable guidance strength parameter to target a tilted conditional distribution. However, this tilted distribution

Figure

(a) CFG

(b) CACFG

Figure 1: Tweedie’s magnitude ( ∥x^0(t,xt,ξ)∥2\|\hat{x}_0(t, \boldsymbol{x}_t, \xi)\|_2) of diffusion sampling trajectories across time with ω=7.5\omega = 7.5 and using (a) CFG (Ho & Salimans, 2022) and (b) CACFG (ours), alongside a representative sample generated by each method. Note that 40% of CFG sampling paths violate the theoretical 95% upper magnitude bound. CACFG restricts permissible controls to lie within a time-varying bounded control set.

is not the marginal of any true diffusion process, and excessive CFG guidance can reduce image diversity and degrade image quality by introducing visual artefacts (Sadat et al., 2025; Karras et al., 2024). Despite this, CFG is frequently used in practice, and practitioners select the largest guidance strengths that do not harm image quality (Dhariwal & Nichol, 2021; Ho & Salimans, 2022).

Previous work has proposed methods of fixing CFG artefacts: CFG++ (Chung et al., 2025) and Interval-CFG (IntCFG) (Kynkäänniemi et al., 2024) each attribute CFG's artefacts to the sampling trajectory departing the image manifold, correcting for this by varying guidance strength across the trajectory. A separate line of work asks why CFG works despite violating diffusion sampling dynamics. Hypotheses attribute its effectiveness to a shared bias in the conditional and unconditional denoisers (Karras et al., 2024), an implicit correction for the poorly-approximated tilted distribution (Moufad et al., 2025), or an equivalence with a predictor-corrector scheme in the continuous-time SDE limit (Bradley & Nakkiran, 2025). However, these explanations disagree on the mechanism responsible, and they do not rigorously extend to commonly used deterministic samplers.

We address this gap by reformulating CFG sampling as a continuous-time optimal control problem: rather than fixing the sampling trajectory as a function of stochastic transition kernels, we treat it as a sequence of controls chosen to maximise the terminal reward p(ξ∣x0)p(\xi \mid \boldsymbol{x}_0), i.e., how probable it is that the sample is of the desired condition/class ξ\xi. Solving the resulting Hamilton–Jacobi–Bellman (HJB) equation shows that the optimal control recovers CFG when the control set is unconstrained and the traversal penalty is expressed in the same scale as the diffusion training loss. To the best of our knowledge, we are the first to frame CFG as a deterministic optimal control problem in this way. Additionally, existing guidance scheduling methods such as CFG++ and IntCFG also emerge from this same optimal control formulation under alternative choices of the traversal penalty (Appendix B). By examining the path costs of this optimisation problem, we find that the CFG diffusion sampling trajectory is encouraged to: align the conditional and CFG scores at early-to-mid sampling times; converge towards a local maximum at late sampling times; and avoid traversing near a maximum too early. This provides significant insight into how CFG works, and why it exhibits certain pathologies.

Our optimal control formulation shows that traditional CFG imposes no constraint on the control set. This permits the sampling path to move arbitrarily far from the current image estimate given sufficiently low traversal penalty. We argue this is directly responsible for CFG's failure modes in high-guidance regimes. To address this, we propose a constrained control set and corresponding curvature-aware CFG scheme (CACFG) that relies on a property latent diffusion models have by construction: the training objective of their variational autoencoder (VAE) is explicitly regularised towards an isotropic Gaussian. We hypothesise that this forces most encodings to lie within a hypersphere of an estimable radius, and we show empirically that the Tweedie estimates produced by traditional CFG sampling frequently violate this theoretical upper bound, while those of CACFG do not (Figure 1). We find that across diffusion models, datasets, and guidance schedules, CACFG has superior generative quality at mid-to-high guidance strengths as measured by various quality metrics.

Our core contributions are as follows: (i) We show that diffusion guidance can be interpreted as a continuous-time control problem; (ii) We show that classifier-free guidance (CFG) is one solution to this control problem, and that existing guidance scheduling methods, such as CFG++ (Chung et al., 2025) and IntCFG (Kynkäänniemi et al., 2024), arise from the same framework under alternative choices of the traversal penalty; (iii) We propose a method of using the Gaussian regularisation term of the VAE training loss to infer the structure of the embedded image manifold; (iv) We propose a constrained control set for the continuous-time optimisation problem that results in a diffusion guidance (CACFG) that provides superior conditional generation with a less severe quality-diversity tradeoff than unconstrained guidance methods, at negligible additional computational cost.

References (33)