CFG: Classifier-Free Guidance (Ho & Salimans 2022)
Plain CFG as a node
- model
- MODEL
You already use classifier-free guidance. It is the cfg box on your KSampler, and it has been
sitting at 7 since you copied your first workflow. So why would anyone ship a node whose entire
job is to be that same formula?
Because in the CFG Megapack everything is a node, and you need the baseline as one too. This is
u + w (c - u) - the unconditional prediction pushed away from the conditional one by the scale -
expressed as a MODEL patch instead of a sampler widget. It is what the other 49 nodes in the pack
are measured against, and it is the honest way to A/B a guidance trick on one seed without
touching your sampler settings.
What it actually does
At every step the model gives you two predictions: c (your prompt) and u (the empty/negative
prompt). Plain CFG extrapolates past the conditional one. ComfyUI implements exactly that in a
single line of samplers.py, and this node writes the same arithmetic into the model's
sampler-CFG hook.
That has one consequence people miss: the pack installs its hook with ComfyUI's
disable_cfg1_optimization flag set, because every rule it implements needs the unconditional
prediction to exist. Normally ComfyUI skips the unconditional pass when cfg is exactly 1 - that
is the free 2x speedup everyone quotes for distilled models. This node turns that optimization off.
So the pack can make a CFG-1 workflow slower even when the picture comes out identical.
Inputs and output
Three things to set, and you'll only touch one of them:
- model - the wire from your checkpoint loader (or from a LoRA loader; the hook survives a clone).
- scale - the guidance scale
wfor this rule. Leave it at -1 and the node uses whatever you typed in the KSampler, which is almost always what you want. Set it explicitly if you want the model chain to disagree with the sampler. - space - where the rule is computed:
auto (the method's own), or noise/denoised/velocity. Plain CFG is linear, so for this node the space changes nothing; for the nonlinear nodes in the same menu it very much does.automaps to noise prediction for most methods, denoised for APG and the angle rule, velocity on flow models.
The output is a MODEL, which goes into KSampler, KSamplerAdvanced, or the model input of SamplerCustomAdvanced exactly like the loader's own output. Chain order in the graph doesn't matter much - the pack always runs its stages in a fixed order (when → weak branch → combine → where → correct → govern → measure) - but the node has to sit between the loader and the sampler, which is the single most common mistake with the whole pack.
Installing it
The pack is on the Comfy Registry, so Manager handles it:
# ComfyUI Manager: search "CFG Megapack" -> Install -> restart
# or, with comfy-cli:
comfy node install comfy-cfg-megapack
# or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/AbstractEyes/comfy-cfg-megapack
There is no requirements.txt and nothing to download - the pack needs only torch and the Python
standard library, which ComfyUI already has. It does require ComfyUI ≥ 0.38 for the node API it
uses, so an old install will simply fail to load it at startup.
Where people get burned
A CFG-function slot is a single slot. ComfyUI lets a model carry one CFG function. Other packs ship nodes that take it (RescaleCFG, Mahiro, RenormCFG). Whichever one you chain last wins, and the loser silently does nothing. If a comparison looks identical, check that first.
At CFG 1 this node is a no-op that still costs time. u + 1(c - u) is c. On a
guidance-distilled checkpoint running at its intended CFG 1, adding it changes nothing visible and
re-enables the second forward pass. The pack's own docs are upfront that neutral settings reproduce
plain sampling pixel for pixel; that's the design, not a bug.
The pack is niche. It shipped in 2026 by AbstractPhil (with Claude Code as co-author on every
commit) and at the time of writing there is essentially no Reddit chatter about it under its own
name - you'll be reading HOWTO.md and the node tooltips rather than forum threads. Start with one
node, one seed, and the pack's own "Workflow > Browse Templates > Custom Nodes > comfy-cfg-megapack"
examples, which render plain CFG and the variant side by side.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| scale | FLOAT | -1.0-1–100 | The guidance scale w for this rule. -1 uses the sampler's cfg value. |
| space | COMBO | auto (the method's own) | Where the rule is computed. Linear rules give the same image in any space; nonlinear ones do not. 'auto' uses the space the method was published in (noise for most, denoised for APG and the angle rule, velocity for flow models). |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |