Pre CFG automatic scale
The automatic CFG scale node that tunes itself
- model
- channels_selection
- MODEL
- parameters
You know the drill: every checkpoint has its own CFG sweet spot, and finding it means a dozen renders on the same seed. Pre CFG automatic scale is Extraltodeus's answer - a node that measures what the CFG difference actually looks like at each step and rescales the predictions so you don't have to hunt for the magic number. It's the same "automatic CFG" logic the author ships elsewhere, packaged as a model patch.
The mechanism is where it gets clever. CFG amplifies the gap between the cond and uncond predictions, and a reference CFG value tells you what the "difference range" would normally be. This node looks at the actual predictions, computes how far off they are from that reference, and derives a per-channel scale to normalize them - effectively asking "how big is the signal here, and how hard should I push it?" That's the reference_CFG input (default 8): it's the CFG value the node assumes as normal, not the value you're sampling at. scale_multiplier (default 0.8) is an overall strength on top, and top_k (default 0.25) controls how much of the prediction's value range counts as "the signal" - a robust measurement that ignores the extreme outliers that would otherwise skew everything.
Two enums do the bookkeeping:
scaling_method- how the derived scale is applied: per-channel individually (individual, default), one scale for everything (all_as_one), or an aggregate likeaverage_of_all_channels/smallest/biggest.min_max_method- how to measure the difference range:difference,average, orbiggest.
The optional channels_selection input accepts the CHANS output from this pack's channel selector nodes, so you can tell the auto-scale to only normalize the channels you care about. That's a genuinely useful trick if you've found that one specific latent channel is the one causing your color cast.
The node has two outputs. MODEL is the patched model you feed to the sampler. The parameters STRING output is a report - it echoes back your scaling method, min/max method, and which channels are active - handy for keeping notes inside a workflow.
Where this shines: chained pre-CFG setups where you've modified the predictions and don't want to re-derive the CFG scale by hand, and workflows you share with people running different checkpoints. It's a stabilizer. Just be ready for one honest quirk - the "strict" variants of this scaling family can throw artifacts and weird blurs if pushed through to the end of sampling, so if you see that, pair it with the Support empty uncond node (same pack) and stop early.
Install is the standard pack routine:
cd ComfyUI/custom_nodes
git clone https://github.com/Extraltodeus/pre_cfg_comfy_nodes_for_ComfyUI
or via ComfyUI Manager by searching pre_cfg_comfy_nodes_for_ComfyUI, then restart. No extra dependencies and no model downloads.
This is the pack's workhorse. If you only install one node from it, this is the one that'll actually end up in your default SDXL template.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| scaling_method | COMBO | individual | 5 options: individual, all_as_one, average_of_all_channels, smallest_of_all_channels, biggest_of_all_channels |
| min_max_method | COMBO | average | 3 options: difference, average, biggest |
| reference_CFG | FLOAT | 8.00–100 | — |
| scale_multiplier | FLOAT | 0.800–100 | — |
| top_k | FLOAT | 0.250–0.5 | — |
| channels_selectionopt | CHANS | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |
| parameters | STRING | — |