CFG-RW is a method that rectifies the expectation shift in conventional classifier-free guidance by modifying the coefficient constraints.
It relaxes the traditional linear sum-to-one restriction, enforcing a zero-mean property to maintain diffusion process consistency.
Empirical results show that CFG-RW enhances FID scores and conditional alignment across various diffusion samplers with minimal computational overhead.
CFG Resolution Weighting (CFG-RW), more rigorously characterized as Rectified Classifier-Free Guidance (ReCFG), refers to a post-hoc modification of the coefficient selection used for classifier-free guidance in diffusion model sampling. Conventional classifier-free guidance (CFG) employs a linear combination of conditional and unconditional score estimates, governed by coefficients that sum to unity. However, this approach introduces a systematic bias—an "expectation shift"—which theoretically disrupts the reciprocity of the reverse diffusion process. CFG Resolution Weighting corrects this bias by relaxing the “sum-to-one” constraint, instead solving for guidance coefficients that enforce a zero-mean property of the combined score, thereby restoring theoretical consistency with the forward–reverse SDE/ODE framework and improving sampling fidelity in conditional generative modeling (Xia et al., 2024).
1. Theoretical Basis and Expectation Shift
Standard CFG replaces the true conditional score ∇xtlogqt(xt∣c) with a weighted mixture: ∇xtlogqt,γ(xt∣c)=γ∇xtlogqt(xt∣c)+(1−γ)∇xtlogqt(xt)
for γ>1. In the ϵ-prediction formulation this corresponds to
ϵγ(xt,c,t)=γϵθ(xt,c,t)+(1−γ)ϵθ(xt,t)
While this sharpens the conditional distribution qt(xt∣c)γqt(xt)1−γ, it violates the zero-mean property that is critical for diffusion-theoretic reversibility. Specifically,
This expectation shift prevents the reverse process from precisely inverting the forward diffusion, resulting in a systematic bias away from E[x0∣c] (Xia et al., 2024).
2. Derivation of Rectified Guidance Weights
CFG Resolution Weighting introduces two free coefficients, αc and ∇xtlogqt,γ(xt∣c)=γ∇xtlogqt(xt∣c)+(1−γ)∇xtlogqt(xt)0, corresponding to conditional and unconditional branches: ∇xtlogqt,γ(xt∣c)=γ∇xtlogqt(xt∣c)+(1−γ)∇xtlogqt(xt)1
with the ∇xtlogqt,γ(xt∣c)=γ∇xtlogqt(xt∣c)+(1−γ)∇xtlogqt(xt)2-space form: ∇xtlogqt,γ(xt∣c)=γ∇xtlogqt(xt∣c)+(1−γ)∇xtlogqt(xt)3
A zero-expectation (annihilation) constraint is enforced: ∇xtlogqt,γ(xt∣c)=γ∇xtlogqt(xt∣c)+(1−γ)∇xtlogqt(xt)4
Estimating ∇xtlogqt,γ(xt∣c)=γ∇xtlogqt(xt∣c)+(1−γ)∇xtlogqt(xt)5 and ∇xtlogqt,γ(xt∣c)=γ∇xtlogqt(xt∣c)+(1−γ)∇xtlogqt(xt)6 via Monte Carlo, the optimal coefficient is found in closed form: ∇xtlogqt,γ(xt∣c)=γ∇xtlogqt(xt∣c)+(1−γ)∇xtlogqt(xt)7
Practically, ∇xtlogqt,γ(xt∣c)=γ∇xtlogqt(xt∣c)+(1−γ)∇xtlogqt(xt)8 is set to the guidance strength ∇xtlogqt,γ(xt∣c)=γ∇xtlogqt(xt∣c)+(1−γ)∇xtlogqt(xt)9, so
γ>10
with practical constraints γ>11 and γ>12 typically satisfied for γ>13.
The relationship to original CFG is outlined as follows:
Approach
Coefficient Form
Constraint
CFG
γ>14
γ>15
ReCFG
γ>16
No sum constraint
3. Computation of Resolution Weights
CFG-RW requires precomputing the ratio
γ>17
for each condition γ>18 and timestep γ>19. This is achieved through a single-pass Monte Carlo estimate across the dataset:
After traversal, set ϵγ(xt,c,t)=γϵθ(xt,c,t)+(1−γ)ϵθ(xt,t)3, ϵγ(xt,c,t)=γϵθ(xt,c,t)+(1−γ)ϵθ(xt,t)4, and ϵγ(xt,c,t)=γϵθ(xt,c,t)+(1−γ)ϵθ(xt,t)5.
This lookup table enables efficient runtime, as the coefficients can be retrieved with minimal computational overhead (Xia et al., 2024).
4. Integration with Diffusion Model Samplers
Most state-of-the-art diffusion samplers (e.g., DDIM, Euler–Maruyama, EDM2, SD3) use the following procedure in each denoising step:
Ext∼qt(⋅∣c)[ϵθ(xt,t)]=05
ReCFG replaces ϵγ(xt,c,t)=γϵθ(xt,c,t)+(1−γ)ϵθ(xt,t)6 with ϵγ(xt,c,t)=γϵθ(xt,c,t)+(1−γ)ϵθ(xt,t)7 and ϵγ(xt,c,t)=γϵθ(xt,c,t)+(1−γ)ϵθ(xt,t)8:
Ext∼qt(⋅∣c)[ϵθ(xt,t)]=06
No retraining or modification to the network is required. This modification is compatible with both class-conditioned (e.g., EDM2 on ImageNet) and text-conditioned (e.g., SD3 on CC12M) models (Xia et al., 2024).
5. Empirical Performance and Ablation Highlights
Empirical studies show quantifiable gains in both fidelity and conditional faithfulness:
Lookup table estimates saturate in performance after ≈300 traversals per condition.
The mean ratio ϵγ(xt,c,t)=γϵθ(xt,c,t)+(1−γ)ϵθ(xt,t)9 varies minimally across qt(xt∣c)γqt(xt)1−γ0, justifying use of a global or average qt(xt∣c)γqt(xt)1−γ1 for open-vocabulary text models with negligible loss (CLIP-Score loss ≤ 0.001).
Storing pixel-wise qt(xt∣c)γqt(xt)1−γ2 yields marginal additional benefit over a scalar per qt(xt∣c)γqt(xt)1−γ3.
A one-dimensional Gaussian toy example demonstrates that standard CFG systematically shifts the mean, while ReCFG retrieves the exact mean and reduces variance (Xia et al., 2024).
6. Practical Recommendations
Guidance strength qt(xt∣c)γqt(xt)1−γ4 mediates the trade-off between fidelity and diversity, with optimal performance at qt(xt∣c)γqt(xt)1−γ5–qt(xt∣c)γqt(xt)1−γ6 for class-conditional models and higher qt(xt∣c)γqt(xt)1−γ7 for open-vocabulary prompting.
In practice, qt(xt∣c)γqt(xt)1−γ8, so qt(xt∣c)γqt(xt)1−γ9 with minor corrections; thus, ReCFG closely approximates boosting the conditional branch by Ext∼qt(⋅∣c)[ϵθ(xt,t)]=00 while ensuring zero expectation in the unconditional branch.
For high-resolution synthesis, as Ext∼qt(⋅∣c)[ϵθ(xt,t)]=01, Ext∼qt(⋅∣c)[ϵθ(xt,t)]=02, allowing Ext∼qt(⋅∣c)[ϵθ(xt,t)]=03 for stability in late denoising steps.
ReCFG can be rapidly implemented post-hoc for any pretrained conditional diffusion model with negligible computational overhead and consistent performance gains.
7. Significance and Implications
CFG Resolution Weighting enforces the theoretical zero-mean property absent in standard CFG by removing the linear coefficient constraint, aligning the sampling process with the requirements of diffusion SDE/ODE theory. The post-hoc nature and closed-form solution for the rectified coefficients permit integration without retraining or architecture changes. Empirical results indicate systematic improvements in FID and conditional alignment for both class-labeled and open-vocabulary generative tasks. The minimal variation in Ext∼qt(⋅∣c)[ϵθ(xt,t)]=04 across conditions suggests potential for further optimization in lookup-table storage and runtime efficiency. A plausible implication is that this approach may generalize beyond diffusion samplers currently demonstrated, offering a template for theoretical corrections to guidance heuristics in other generative domains (Xia et al., 2024).