Swap CFG Guidance
Front-load structure, relax the details
- model
- positive
- negative
- GUIDER
Swap CFG Guidance is the pack's answer to a specific, real annoyance: one CFG value for the whole run is a compromise. Early steps want structure - you want the model to commit to a composition hard. Late steps want restraint - cranking guidance through the detail pass is exactly how you get burned colors and deep-fried textures. This node runs CFG1 for the first portion of denoising, then flips to CFG2 at a progress point you choose.
The author ships it as the "Dual-CFG" centerpiece of the PG master workflows (SD-Master, SD3-Master, FLUX-Master), and the typical setup is front-loaded: CFG 6–7 early to lock the composition, then drop to CFG 1–2 for the finish. Or the reverse, if your model likes being told what to do late. Both directions are just a swap.
How it works
This is a custom guider, which is ComfyUI's mechanism for intercepting how conditioning steers the sampler. You give it model, positive, and negative conditioning, plus three numbers:
cfg1- guidance used from 0% up to the swap point. Default 6.0.cfg2- guidance used after the swap point. Default 1.0.swap_percent- the trigger as a 0–1 float. Default 0.5, meaning halfway.
Under the hood it subclasses CFGGuider, and at each step it computes the current position in the denoising schedule, picks the active CFG, and runs the normal sampling function with it. The negative prompt stays active in both phases - nothing exotic there. Output is a single GUIDER that you plug into an advanced sampler node's guider input (the KSampler Advanced / custom-guider style samplers, not the plain KSampler).
Where people actually use this: fixing "image ruined at the end of generation." The classic troubleshooting doc - too-high CFG with too-few steps over-pushes in the final steps, burning the image. Swap CFG is a surgical fix for exactly that failure mode: keep your composition CFG where it needs to be early, then drop it before the finish line.
The inputs that matter
model,positive,negative- the usual suspects, straight from your loader and encoder.cfg1/cfg2- your two guidance values. Range 0–100.swap_percent- the split point. 0.5 is a sane start; front-loaders go lower (swap earlier), late-detail people go higher.
The GUIDER output is the only wire out - into a sampler's guider input.
Install
Ships with PG Nodes:
ComfyUI Manager → search "PG Nodes" → Install → restart
Manual: git clone https://github.com/GizmoR13/PG-Nodes into custom_nodes (folder named PG-nodes), restart. Under PG. No dependencies beyond ComfyUI's own guider API.
Common issues
- "My sampler doesn't take a guider." Right - plain KSampler has no guider input. Use the advanced sampler nodes (KSampler Advanced) or the ones that expose guider/
GUIDERinputs. - Swap point has no visible effect. If cfg1 and cfg2 are close, of course nothing changes. Also, on guidance-distilled models (Flux, Z-Image Turbo, Klein), CFG semantics are inverted and this whole dance behaves differently - read what your model family actually wants first.
- Burned image at the end. Lower cfg2, or move the swap earlier. That's the primary dial for this node.
- swap_percent is 0–1, not a percentage. The node takes a fraction, so 50% is 0.5. The pack's
Percentnode exists precisely to convert a 0–100 integer into that 0–1 float if your panel thinks in percents.
It's a small idea executed cleanly, and it's the one PG node that genuinely does something a stock ComfyUI install can't do without custom code. If you've ever rescued a run by re-generating with lower CFG at higher steps, this is that rescue, automated.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| positive | CONDITIONING | — | |
| negative | CONDITIONING | — | |
| cfg1 | FLOAT | 6.000–100 | — |
| cfg2 | FLOAT | 1.000–100 | — |
| swap_percent | FLOAT | 0.500–1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| GUIDER | GUIDER | — |