Robots Atlas>ROBOTS ATLAS
Inference

CFG

2022ActivePublished: 8 June 2026Updated: 8 June 2026Published
Key innovation
Strengthens conditioning in generative models without a separate classifier — by extrapolating between the conditional and unconditional prediction of the same model trained with random condition dropout.
Category
Inference
Abstraction level
Building block
Operation level
InferenceTraining
Use cases
Text-to-image in diffusion models (Stable Diffusion, SDXL, SD3, Imagen, DALL·E 2)Text-conditioned video generation (SVD, Sora-like)Conditioned audio and speech generation (TTS, MusicGen)Conditioning in diffusion policy (robotics)Negative prompts (negative prompting as ∅ ≠ empty)Autoregressive generation with context guidance

How it works

Training: the condition c (e.g. a text embedding) is randomly replaced with an empty token ∅ with probability p_uncond (typically 0.1-0.2). This way one set of weights learns both the conditional prediction ε_θ(x,c) and the unconditional ε_θ(x,∅). Inference: at each denoising (or generation) step TWO passes are computed — conditional and unconditional — and the result is linearly extrapolated: ε̃ = ε_θ(x,∅) + w·(ε_θ(x,c) − ε_θ(x,∅)). Equivalently ε̃ = (1−w)·ε_θ(x,∅) + w·ε_θ(x,c) in some conventions. The vector (ε_θ(x,c) − ε_θ(x,∅)) points in the "condition direction"; the scale w amplifies it. w = 1 means no guidance (purely conditional), w > 1 amplifies. Cost: ~2× inference compute (two forward passes), although batching the conditional and unconditional passes mitigates the overhead.

Problem solved

Conditional generative models often follow the condition (prompt) weakly, producing content only loosely related to it. Earlier classifier guidance required a separate classifier trained on noisy data — costly and difficult. CFG strongly amplifies conditioning using only the generative model itself, with no extra networks.

Components

Condition dropout (training)Trains a joint conditional and unconditional model

Randomly replacing the condition c with an empty token ∅ at probability p_uncond (usually 0.1-0.2) during training.

Dual forward pass (inference)Computes conditional and unconditional predictions

Two model passes per step: ε_θ(x,c) and ε_θ(x,∅). Often batched together.

Guidance extrapolationLinear combination steered by scale w

ε̃ = ε_θ(x,∅) + w·(ε_θ(x,c) − ε_θ(x,∅)). The scale w controls conditioning strength.

CFG rescaleVariance renormalization of ε̃ against oversaturation (Common Diffusion Noise Schedules paper).
Dynamic/adaptive CFGGuidance scale w that varies over denoising.
Negative prompt guidance∅ replaced by a negative-prompt embedding.

Official

Implementation

Implementation pitfalls
Oversaturation and artifacts at high wHigh

Large guidance scale causes oversaturated colors, posterization, and unnatural textures.

Fix:CFG rescale, dynamic thresholding (Imagen), lower w, zero-SNR schedule.
Doubled inference costMedium

Two forward passes per step (conditional + unconditional) double the compute cost.

Fix:Batching both passes, guidance distillation, disabling CFG in late steps.
Diversity drop (conditional mode collapse)Medium

High w increases condition fidelity at the cost of sample diversity.

Fix:Choose w as a quality-diversity trade-off; adaptive guidance schedule.

Evolution

Original paper · 2022 · NeurIPS 2021 Workshop / arXiv 2022 · Jonathan Ho
Classifier-Free Diffusion Guidance
Jonathan Ho, Tim Salimans
2021
Classifier Guidance (predecessor)

Dhariwal & Nichol introduce guidance using a separate classifier trained on noisy data.

2021
Classifier-Free Guidance — introduction
Inflection point

Ho & Salimans show the separate classifier is unnecessary — a joint conditional/unconditional model suffices.

2022
Adoption in GLIDE, DALL·E 2, Imagen, Stable Diffusion
Inflection point

CFG becomes the standard conditioning mechanism across all leading text-to-image models.

2023
CFG rescale and zero-SNR

Lin et al. diagnose oversaturation at high w and propose rescale + zero-SNR schedule.

2024
Guidance distillation (fewer steps)

Distilling CFG into a single forward pass removes the 2× compute overhead (e.g. in few-step models).

Hyperparameters (configurable axes)

Guidance scale wCritical

Conditioning strength. w=1 no guidance, typically 5-12 for image, 1-3 for video. Too high → artifacts.

Unconditional training probabilityHigh

Condition-dropout probability during training (typically 0.1-0.2).

CFG rescale φMedium

Variance renormalization coefficient against oversaturation at high w.

Guidance scheduleMedium

Constant vs time-varying guidance scale (e.g. disabling CFG in late steps).

Execution paradigm

Primary mode
Dense

The full model is active twice per inference step (conditional and unconditional).

Activation pattern
All paths active

Parallelism

Parallelism level
Partially parallel

The conditional and unconditional passes can be computed in parallel within one batch, but CFG operates inside the base model's sequential denoising/generation loop.

Scope
InferenceTraining

Hardware requirements

Primary

CFG is a wrapper over a diffusion/AR model — it inherits the base model's hardware profile (GPU tensor cores).

Good fit

The guidance logic itself is a cheap linear tensor combination — it imposes no specific hardware requirement.