CFG Scale in Stable Diffusion
How CFG scale controls prompt adherence in Stable Diffusion, optimal ranges per model family, and why distilled models use CFG 1.
On this page
CFG Scale Explained: The Math Behind Stable Diffusion's Guidance Knob
TL;DR
- What CFG does: CFG scale multiplies the difference between a prompt-aware prediction and a prompt-agnostic prediction, pushing the generated image toward or away from your prompt.
- Optimal ranges vary: SD 1.5 typically works best at CFG 7, SDXL at 5–7, while Flux dev, SDXL Turbo, and SD-Turbo should use CFG 1 because they are distilled/guidance-embedded models.
- High CFG artifacts: Pushing CFG above 12 can cause oversaturation, over-sharpening, and unnatural hyper-realism; distilled models produce washed-out or distorted results with CFG > 1.
What CFG Actually Does to Predictions
Classifier-Free Guidance (CFG) blends two versions of the model: one that's paying attention to your prompt (prompt-aware) and one that's more or less ignoring it (prompt-agnostic). By mixing these together, you control how closely Stable Diffusion follows your prompt versus improvising on its own.
During training, the model learns two predictions simultaneously: the conditional prediction εθ(zλ, c)—what noise to remove given your prompt c—and the unconditional prediction εθ(zλ)—what noise to remove given a null token. The CFG scale, denoted w, combines these mathematically:
εθ(zλ, c) = (1 + w) · εθ(zλ, c) − w · εθ(zλ)
When w = 0, the model ignores the prompt entirely. As w increases, the guided score moves further toward the conditional prediction. Higher CFG makes images more prompt-faithful. The technique was introduced in Ho & Salimans (2022), which showed that randomly dropping conditioning tokens enables one network to produce both predictions without architectural changes. The guided score formula (Eq. 6 in the paper) has no classifier gradient present, making it distinct from classifier guidance [arXiv:2207.12598].
Model Family: When to Use What CFG
SD 1.5 and Legacy Checkpoints
SD 1.5 was trained with 10% text-conditioning dropout [SD 1.5 model card]. Community practitioners report a working range of CFG 7–8, with 7 being a common sweet spot for balanced results. See SA samplers and schedulers for how CFG interacts with sampling steps.
| CFG | Typical Result |
|---|---|
| 4–5 | More creative, less prompt-faithful; useful for style exploration |
| 7 | Balanced adherence and quality for most prompts |
| 10+ | Hyper-literal, may introduce oversaturation or artifacts |
SDXL Base and Refiner Pipelines
SDXL uses two text encoders (OpenCLIP-ViT/G and CLIP-ViT/L) and expects 1024×1024 resolution [SDXL base card]. Community touchstones suggest CFG 5–7 as a standard range for coherent images, with higher values for deliberate effects. Unlike SD 1.5, SDXL is more sensitive to CFG extremes; the refiner's separate processing can amplify artifacts when guidance is too aggressive.
Flux Dev: Distilled Guidance, CFG Must Be 1
Flux dev is a guidance-distilled model [guidance-distillation paper, Flux pipeline docs]. Distillation bakes the guidance combination directly into the model weights, making w an input rather than a sampler scaling factor.
This means:
- Set the sampler's CFG to exactly 1.0
- Adjust the FluxGuidance node (or equivalent) for desired prompt adherence
Using CFG 7 on Flux dev would double-apply guidance, washing out the image. The standard workflow uses Euler sampler, cfg 1.0, and guidance 3.5 [Flux workflow guide, Forge discussion #1119].
Turbo Models: Guidance Disabled by Design
SDXL Turbo and SD-Turbo are distilled for 1–4 step synthesis [SDXL-Turbo card, SD-Turbo card]. Their model cards explicitly state they do not use guidance_scale or negative_prompt, and guidance_scale=0.0 disables the mechanism. Using CFG > 1 on them introduces artifacts and slows generation without benefit.
Other Distilled Variants
Similar principles apply to Anima-Turbo (CFG 1, 8–12 steps) [Anima model card], Z-Image-Turbo (guidance_scale=0.0) [Z-Image-Turbo card], and Flux Schnell (guidance_scale=0 or 1, 1–4 steps).
Why High CFG Causes Artifacts
Pushing CFG beyond the training distribution amplifies the difference between conditional and unconditional predictions. Practitioner observation (DucHaiten, Civitai post 443573) notes that CFG above 12 tends to produce increased sharpness, hypersaturation, and a more literal fixation on prompt tokens [Civitai post 443573]. The unconditional branch, trained on empty prompts, cannot meaningfully counteract the aggressive steering. The paper itself notes that strongly guided samples display saturated colors [arXiv:2207.12598, Figure 3 caption].
Distilled Models vs. CFG 1: The Technical Reason
Guidance distillation trains a student model to reproduce a combined teacher's output [guidance-distillation paper]. The distilled model takes w as an input rather than running two separate predictions. Running CFG on top would double-apply guidance, causing overshoot—either washing out details (Flux) or introducing artifacts (Turbo). This rule also applies to LCM-SDXL (guidance_scale 1.0–2.0 or disabled) and SD-Turbo (guidance_scale=0), where guidance is handled by the architecture at training time [LCM-SDXL HF card, SD-Turbo HF card].
Negative Prompts and Distilled Models
Negative prompts work by replacing the empty-unconditional text embedding with your negative text [AUTOMATIC1111 Negative Prompt wiki]. On distilled models like Flux dev, the negative prompt is ignored unless true_cfg_scale > 1 [diffusers pipeline docs]. To use negatives on Flux, set true_cfg_scale > 1 and accept the added cost. Turbo models ignore negatives entirely because guidance_scale=0 disables the mechanism [SDXL-Turbo card, SD-Turbo card]. See Negative prompts guide for techniques beyond negation.
Common Errors and Fixes
| Symptom | Cause | Fix |
|---|---|---|
| Image washed out on Flux | CFG > 1 with guidance-distilled model | Set sampler CFG to 1.0; use FluxGuidance node |
| Negative prompt has no effect on Flux | Default true_cfg_scale is 1.0 | Set true_cfg_scale > 1 with negative prompt |
| Output looks burned or oversaturated | CFG too high for model family | Reduce CFG; use known touchstones (7 for SD 1.5, 5–7 for SDXL) |
FAQ
What does CFG actually change between predictions? The guided score is (1+w)·εθ(zλ, c) − w·εθ(zλ) [arXiv:2207.12598, Eq. 6]. Higher w moves the result further toward the conditional prediction.
Why does negative prompt do nothing on Flux? Flux dev is guidance-distilled [diffusers pipeline docs]. Without true_cfg_scale > 1, there is no separate unconditional branch to steer away from negative terms.
Should distilled models use CFG greater than 1? No [guidance-distillation paper, diffusers pipeline docs]. Distilled models bake guidance into their weights. Using CFG > 1 double-applies guidance, causing washed-out or distorted results.
Which CFG range is normal for SDXL vs SD 1.5? SD 1.5 practitioners commonly use CFG 7–8; SDXL practitioners suggest 5–7 [SDXL base card, AUTOMATIC1111 wiki]. Both families show degraded results at extremes; the exact boundary varies by checkpoint.
Why does high CFG look over-saturated or "burned"? Large guidance values amplify features tied to prompt tokens beyond the range seen during training, emphasizing sharpness and saturation at the cost of natural appearance [arXiv:2207.12598, Figure 3; Civitai post 443573].
What is the formula behind CFG and where did it come from? εθ(zλ, c) = (1 + w)·εθ(zλ, c) − w·εθ(zλ). Introduced in Ho & Salimans (2022) [arXiv:2207.12598].
Is SeedVR2 suitable for single-image tiling? SeedVR2 is a video upscaler that can be repurposed for single frames. Community workflow reported ~950% upscale on a 3090 with 16 tiles. Verify the model documentation explicitly supports single images before recommending for production.
Why do some Forge UIs show multiple CFG inputs? Forge exposes separate distilled CFG sliders for models like Flux [Flux workflow guide]. The primary CFG should be 1.0; adjust the distilled guidance parameter instead. See Inpainting and outpainting guide for related techniques.
Sources
| Source | Contribution |
|---|---|
| arXiv:2207.12598 | CFG formula (Eq. 6) and training mechanism |
| SD 1.5 model card | 10% text-conditioning dropout |
| SDXL base card | Two text encoders, 1024px target |
| SDXL-Turbo card | Guidance disabled, guidance_scale=0.0 |
| Flux pipeline docs | Embedded guidance, true_cfg_scale behavior |
| Guidance distillation paper | Distilled model takes w as input |
| Anima model card | CFG 1 for Anima-Turbo |
| Z-Image-Turbo card | guidance_scale=0 requirement |
| AUTOMATIC1111 Negative Prompt wiki | Negative prompt replaces empty unconditional embedding |
| Flux workflow guide | Flux CFG 1.0 workflow |
| Forge discussion #1119 | NF4 Flux settings |
| kohya Flux training docs | guidance_scale=1.0 requirement |
| LCM-SDXL HF card | Guidance 1.0–2.0 or disabled |
| SD-Turbo HF card | Guidance disabled |