Papers
Topics
Authors
Recent
Search
2000 character limit reached

CFG Resolution Weighting (CFG-RW)

Updated 18 December 2025
  • 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(xtc)\nabla_{x_t}\log q_t(x_t\mid c) with a weighted mixture: xtlogqt,γ(xtc)=γxtlogqt(xtc)+(1γ)xtlogqt(xt)\nabla_{x_t}\log q_{t,\gamma}(x_t\mid c) = \gamma\,\nabla_{x_t}\log q_t(x_t\mid c) + (1-\gamma)\,\nabla_{x_t}\log q_t(x_t) for γ>1\gamma > 1. In the ϵ\epsilon-prediction formulation this corresponds to

ϵγ(xt,c,t)=γϵθ(xt,c,t)+(1γ)ϵθ(xt,t)\epsilon_{\gamma}(x_t,c,t) = \gamma\,\epsilon_\theta(x_t,c,t) + (1-\gamma)\,\epsilon_\theta(x_t,t)

While this sharpens the conditional distribution qt(xtc)γqt(xt)1γq_t(x_t\mid c)^\gamma q_t(x_t)^{1-\gamma}, it violates the zero-mean property that is critical for diffusion-theoretic reversibility. Specifically,

Extqt(c)[ϵθ(xt,t)]0\mathbb{E}_{x_t\sim q_t(\cdot\mid c)}[\epsilon_\theta(x_t,t)] \neq 0

and thus,

Ext[xtlogqt,γ(xtc)]=(1γ)Ext[xtlogqt(xt)]0\mathbb{E}_{x_t}[\nabla_{x_t}\log q_{t,\gamma}(x_t\mid c)] = (1-\gamma)\,\mathbb{E}_{x_t}[\nabla_{x_t}\log q_t(x_t)] \neq 0

This expectation shift prevents the reverse process from precisely inverting the forward diffusion, resulting in a systematic bias away from E[x0c]\mathbb{E}[x_0\mid c] (Xia et al., 2024).

2. Derivation of Rectified Guidance Weights

CFG Resolution Weighting introduces two free coefficients, αc\alpha_c and xtlogqt,γ(xtc)=γxtlogqt(xtc)+(1γ)xtlogqt(xt)\nabla_{x_t}\log q_{t,\gamma}(x_t\mid c) = \gamma\,\nabla_{x_t}\log q_t(x_t\mid c) + (1-\gamma)\,\nabla_{x_t}\log q_t(x_t)0, corresponding to conditional and unconditional branches: xtlogqt,γ(xtc)=γxtlogqt(xtc)+(1γ)xtlogqt(xt)\nabla_{x_t}\log q_{t,\gamma}(x_t\mid c) = \gamma\,\nabla_{x_t}\log q_t(x_t\mid c) + (1-\gamma)\,\nabla_{x_t}\log q_t(x_t)1 with the xtlogqt,γ(xtc)=γxtlogqt(xtc)+(1γ)xtlogqt(xt)\nabla_{x_t}\log q_{t,\gamma}(x_t\mid c) = \gamma\,\nabla_{x_t}\log q_t(x_t\mid c) + (1-\gamma)\,\nabla_{x_t}\log q_t(x_t)2-space form: xtlogqt,γ(xtc)=γxtlogqt(xtc)+(1γ)xtlogqt(xt)\nabla_{x_t}\log q_{t,\gamma}(x_t\mid c) = \gamma\,\nabla_{x_t}\log q_t(x_t\mid c) + (1-\gamma)\,\nabla_{x_t}\log q_t(x_t)3 A zero-expectation (annihilation) constraint is enforced: xtlogqt,γ(xtc)=γxtlogqt(xtc)+(1γ)xtlogqt(xt)\nabla_{x_t}\log q_{t,\gamma}(x_t\mid c) = \gamma\,\nabla_{x_t}\log q_t(x_t\mid c) + (1-\gamma)\,\nabla_{x_t}\log q_t(x_t)4 Estimating xtlogqt,γ(xtc)=γxtlogqt(xtc)+(1γ)xtlogqt(xt)\nabla_{x_t}\log q_{t,\gamma}(x_t\mid c) = \gamma\,\nabla_{x_t}\log q_t(x_t\mid c) + (1-\gamma)\,\nabla_{x_t}\log q_t(x_t)5 and xtlogqt,γ(xtc)=γxtlogqt(xtc)+(1γ)xtlogqt(xt)\nabla_{x_t}\log q_{t,\gamma}(x_t\mid c) = \gamma\,\nabla_{x_t}\log q_t(x_t\mid c) + (1-\gamma)\,\nabla_{x_t}\log q_t(x_t)6 via Monte Carlo, the optimal coefficient is found in closed form: xtlogqt,γ(xtc)=γxtlogqt(xtc)+(1γ)xtlogqt(xt)\nabla_{x_t}\log q_{t,\gamma}(x_t\mid c) = \gamma\,\nabla_{x_t}\log q_t(x_t\mid c) + (1-\gamma)\,\nabla_{x_t}\log q_t(x_t)7 Practically, xtlogqt,γ(xtc)=γxtlogqt(xtc)+(1γ)xtlogqt(xt)\nabla_{x_t}\log q_{t,\gamma}(x_t\mid c) = \gamma\,\nabla_{x_t}\log q_t(x_t\mid c) + (1-\gamma)\,\nabla_{x_t}\log q_t(x_t)8 is set to the guidance strength xtlogqt,γ(xtc)=γxtlogqt(xtc)+(1γ)xtlogqt(xt)\nabla_{x_t}\log q_{t,\gamma}(x_t\mid c) = \gamma\,\nabla_{x_t}\log q_t(x_t\mid c) + (1-\gamma)\,\nabla_{x_t}\log q_t(x_t)9, so

γ>1\gamma > 10

with practical constraints γ>1\gamma > 11 and γ>1\gamma > 12 typically satisfied for γ>1\gamma > 13.

The relationship to original CFG is outlined as follows:

Approach Coefficient Form Constraint
CFG γ>1\gamma > 14 γ>1\gamma > 15
ReCFG γ>1\gamma > 16 No sum constraint

3. Computation of Resolution Weights

CFG-RW requires precomputing the ratio

γ>1\gamma > 17

for each condition γ>1\gamma > 18 and timestep γ>1\gamma > 19. This is achieved through a single-pass Monte Carlo estimate across the dataset:

  1. Initialize accumulators ϵ\epsilon0, ϵ\epsilon1, ϵ\epsilon2 for each ϵ\epsilon3.
  2. For each data sample ϵ\epsilon4 and each time ϵ\epsilon5:
    • Draw ϵ\epsilon6, set ϵ\epsilon7.
    • Compute ϵ\epsilon8 and ϵ\epsilon9.
    • Accumulate ϵγ(xt,c,t)=γϵθ(xt,c,t)+(1γ)ϵθ(xt,t)\epsilon_{\gamma}(x_t,c,t) = \gamma\,\epsilon_\theta(x_t,c,t) + (1-\gamma)\,\epsilon_\theta(x_t,t)0, ϵγ(xt,c,t)=γϵθ(xt,c,t)+(1γ)ϵθ(xt,t)\epsilon_{\gamma}(x_t,c,t) = \gamma\,\epsilon_\theta(x_t,c,t) + (1-\gamma)\,\epsilon_\theta(x_t,t)1, ϵγ(xt,c,t)=γϵθ(xt,c,t)+(1γ)ϵθ(xt,t)\epsilon_{\gamma}(x_t,c,t) = \gamma\,\epsilon_\theta(x_t,c,t) + (1-\gamma)\,\epsilon_\theta(x_t,t)2.
  3. After traversal, set ϵγ(xt,c,t)=γϵθ(xt,c,t)+(1γ)ϵθ(xt,t)\epsilon_{\gamma}(x_t,c,t) = \gamma\,\epsilon_\theta(x_t,c,t) + (1-\gamma)\,\epsilon_\theta(x_t,t)3, ϵγ(xt,c,t)=γϵθ(xt,c,t)+(1γ)ϵθ(xt,t)\epsilon_{\gamma}(x_t,c,t) = \gamma\,\epsilon_\theta(x_t,c,t) + (1-\gamma)\,\epsilon_\theta(x_t,t)4, and ϵγ(xt,c,t)=γϵθ(xt,c,t)+(1γ)ϵθ(xt,t)\epsilon_{\gamma}(x_t,c,t) = \gamma\,\epsilon_\theta(x_t,c,t) + (1-\gamma)\,\epsilon_\theta(x_t,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: Extqt(c)[ϵθ(xt,t)]0\mathbb{E}_{x_t\sim q_t(\cdot\mid c)}[\epsilon_\theta(x_t,t)] \neq 05 ReCFG replaces ϵγ(xt,c,t)=γϵθ(xt,c,t)+(1γ)ϵθ(xt,t)\epsilon_{\gamma}(x_t,c,t) = \gamma\,\epsilon_\theta(x_t,c,t) + (1-\gamma)\,\epsilon_\theta(x_t,t)6 with ϵγ(xt,c,t)=γϵθ(xt,c,t)+(1γ)ϵθ(xt,t)\epsilon_{\gamma}(x_t,c,t) = \gamma\,\epsilon_\theta(x_t,c,t) + (1-\gamma)\,\epsilon_\theta(x_t,t)7 and ϵγ(xt,c,t)=γϵθ(xt,c,t)+(1γ)ϵθ(xt,t)\epsilon_{\gamma}(x_t,c,t) = \gamma\,\epsilon_\theta(x_t,c,t) + (1-\gamma)\,\epsilon_\theta(x_t,t)8: Extqt(c)[ϵθ(xt,t)]0\mathbb{E}_{x_t\sim q_t(\cdot\mid c)}[\epsilon_\theta(x_t,t)] \neq 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:

Model/Dataset Standard CFG ReCFG (CFG-RW) Metric Change
LDM, ImageNet 256×256, 20 steps FID ≈ 18.9 FID ≈ 16.9 FID ↓ 2.0
EDM2-S, ImageNet 512×512, 63 steps FID ≈ 5.9 FID ≈ 4.8 FID ↓ 1.1
SD3, CC12M 512×512, 25 steps CLIP ≈ 0.268, FID ≈ 72.2 CLIP ≈ 0.270, FID ≈ 71.8 CLIP, FID ↑0.002, ↓0.4

Ablation reveals:

  • Lookup table estimates saturate in performance after ≈300 traversals per condition.
  • The mean ratio ϵγ(xt,c,t)=γϵθ(xt,c,t)+(1γ)ϵθ(xt,t)\epsilon_{\gamma}(x_t,c,t) = \gamma\,\epsilon_\theta(x_t,c,t) + (1-\gamma)\,\epsilon_\theta(x_t,t)9 varies minimally across qt(xtc)γqt(xt)1γq_t(x_t\mid c)^\gamma q_t(x_t)^{1-\gamma}0, justifying use of a global or average qt(xtc)γqt(xt)1γq_t(x_t\mid c)^\gamma q_t(x_t)^{1-\gamma}1 for open-vocabulary text models with negligible loss (CLIP-Score loss ≤ 0.001).
  • Storing pixel-wise qt(xtc)γqt(xt)1γq_t(x_t\mid c)^\gamma q_t(x_t)^{1-\gamma}2 yields marginal additional benefit over a scalar per qt(xtc)γqt(xt)1γq_t(x_t\mid c)^\gamma q_t(x_t)^{1-\gamma}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(xtc)γqt(xt)1γq_t(x_t\mid c)^\gamma q_t(x_t)^{1-\gamma}4 mediates the trade-off between fidelity and diversity, with optimal performance at qt(xtc)γqt(xt)1γq_t(x_t\mid c)^\gamma q_t(x_t)^{1-\gamma}5–qt(xtc)γqt(xt)1γq_t(x_t\mid c)^\gamma q_t(x_t)^{1-\gamma}6 for class-conditional models and higher qt(xtc)γqt(xt)1γq_t(x_t\mid c)^\gamma q_t(x_t)^{1-\gamma}7 for open-vocabulary prompting.
  • In practice, qt(xtc)γqt(xt)1γq_t(x_t\mid c)^\gamma q_t(x_t)^{1-\gamma}8, so qt(xtc)γqt(xt)1γq_t(x_t\mid c)^\gamma q_t(x_t)^{1-\gamma}9 with minor corrections; thus, ReCFG closely approximates boosting the conditional branch by Extqt(c)[ϵθ(xt,t)]0\mathbb{E}_{x_t\sim q_t(\cdot\mid c)}[\epsilon_\theta(x_t,t)] \neq 00 while ensuring zero expectation in the unconditional branch.
  • For high-resolution synthesis, as Extqt(c)[ϵθ(xt,t)]0\mathbb{E}_{x_t\sim q_t(\cdot\mid c)}[\epsilon_\theta(x_t,t)] \neq 01, Extqt(c)[ϵθ(xt,t)]0\mathbb{E}_{x_t\sim q_t(\cdot\mid c)}[\epsilon_\theta(x_t,t)] \neq 02, allowing Extqt(c)[ϵθ(xt,t)]0\mathbb{E}_{x_t\sim q_t(\cdot\mid c)}[\epsilon_\theta(x_t,t)] \neq 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 Extqt(c)[ϵθ(xt,t)]0\mathbb{E}_{x_t\sim q_t(\cdot\mid c)}[\epsilon_\theta(x_t,t)] \neq 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).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to CFG Resolution Weighting (CFG-RW).