ComfyUI Node

CFG Selector

Turn the CFG box into a wire before you sweep it

By DemonAlone·Created 9 months ago·Updated about 20 hours ago· 6
CFG Selector
    • CFG
    ◄CFG7.0►

    Here's the situation this node exists for. You've got CFG set to 6.5 on your KSampler, you want to know whether 5.5 or 7.5 is better on this prompt, and the only way ComfyUI lets you ask that question is to type 6.5 into a box, run it, type 5.5 into the same box, run it, and delete the bad ones later. Do that across three axes and you've built yourself a job.

    CFG Selector fixes exactly one thing: it moves CFG out of the widget and onto a wire. Once CFG is a socket, something upstream can change it - a loop iteration, a sweep, a second KSampler sharing the same number. That's the whole pitch, and it's less trivial than it sounds.

    What it actually does

    Nothing, in the nicest possible sense. Here is the entire implementation:

    def run(self, CFG):
        return (CFG,)
    

    One FLOAT in, the same FLOAT out. No sampling, no clamping beyond the widget's own range, no state. If that feels like a wasted node, remember what ComfyUI's plumbing layer is for: repetition and legibility. A value that lives in a socket can fan out to five places; a value that lives in a widget has to be retyped five times, and the fifth time you'll forget.

    The mechanism you need to know is Convert widget to input. Right-click the cfg field on your KSampler (or any node with a float CFG field), pick convert-to-input, and the widget becomes an empty socket. Now wire CFG Selector's output into it. The number on the node is the single source of truth; the sampler no longer has an opinion.

    The one input and the one output

    CFG is the only input: FLOAT, default 7.0, range 0 to 100, step 0.5. The output is also named CFG and is a plain FLOAT.

    Honest comparison, because you'll wonder: core ComfyUI's PrimitiveFloat does the same job. What you get here is a range that matches the actual CFG domain (0-100 in half-points, rather than the huge default range a generic primitive gives you), an output socket labelled the way the rest of the pack is labelled, and consistency if you're already using its siblings - Denoise Selector, Steps Selector, Sampler Selector. If you've standardised on core primitives, there's no reason to switch packs for this.

    Where CFG is actually worth sweeping

    The starting numbers, per model family:

    • SD 1.5 / SDXL, including Illustrious and Pony finetunes: 5-9, with 4-6 being the anime-SDXL convention.
    • Distilled checkpoints and step-distilled LoRAs: 1. At exactly 1 ComfyUI doesn't weight the negative pass to zero, it skips computing it, which is a real speed win.
    • CFG++ samplers (euler_cfg_pp, dpmpp_2m_cfg_pp) are built for guidance below 1.

    That last point is where this node's 0.5 step gets awkward. Half-point increments are perfect for the 4-9 range and too coarse for hunting around 1.0-1.5 on a guidance-distilled model, where 0.1 moves the image. If you live in that range, either put the sweep in a different tool or accept a coarse grid first and refine by hand.

    Install

    The pack ships no models - the only Python dependency is piexif, and none of the selector nodes touch it.

    Easiest route is ComfyUI Manager: search DemonAlone-nodes-ComfyUI, install, restart the server. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/DemonAlone/DemonAlone-nodes-ComfyUI
    cd DemonAlone-nodes-ComfyUI
    pip install -r requirements.txt
    

    Then restart ComfyUI. The node lands under utils in the right-click menu as CFG Selector.

    Things that go wrong

    Nothing from the pack appears, and the traceback mentions piexif. That's the one install trap worth memorising. image_utilites.py imports piexif at module level for the EXIF-reading image nodes, so if pip never ran - very common when you clone by hand instead of using Manager - the whole package fails to import and none of the DemonAlone nodes show up, including the ones that have nothing to do with EXIF. Install the requirement and restart.

    You changed CFG and the image didn't move. Check that the value didn't cross 1.0 while a negative prompt was doing the work - at CFG 1 the negative conditioning isn't computed at all, so it can't have an effect. Also make sure the converted socket is actually the one you're feeding; it's easy to end up with two KSamplers in a graph and only one of them rewired.

    A sweep looks chaotic. If your sampler is ancestral (euler_ancestral, dpmpp_sde), each step adds fresh noise, so cells never fully settle and a fixed seed doesn't make them comparable. For a CFG sweep, hold the sampler converging - Euler or DPM++ 2M - and sweep one axis at a time. The pack itself was built for exactly this kind of grid work, all the way back to its XYZ-plot roots.

    Categoryutils

    Inputs (1)

    NameTypeDefaultDescription
    CFGFLOAT7.00–100—

    Outputs (1)

    NameTypeDescription
    CFGFLOAT—