ComfyUI Node

Pre CFG flip flop

Swap your positive and negative predictions, just to see what happens

By Extraltodeus·Created 2 years ago·Updated about a year ago· 66
Pre CFG flip flop
  • model
  • MODEL
enabledtrue

Sometimes the most honest thing a tool can do is let you invert an assumption and see what falls out. Pre CFG flip flop does exactly that: it swaps the positive and negative predictions before the CFG function runs. For the duration of its active steps, your prompt's prediction becomes the negative and the uncond becomes the positive - CFG then pushes toward what the model thinks of as "no prompt" and away from your words.

The README is refreshingly upfront about what this is for: "For experimental purposes." It's not a productivity node. It's a probe - a way to see how much of an image's character comes from the prompt signal versus the unconditional baseline. The mechanism is one line of tensor bookkeeping: conds_out[0], conds_out[1] = conds_out[1], conds_out[0], gated by the enabled toggle. That's the entire node, and its value is entirely in how you chain it.

The interesting use, per the README: because order matters in this pack's pre-CFG chain, you can swap, run some other node, then swap back. Flip flop at the front of the chain, a few pre-CFG tweaks aimed at the "positive" slot, flip flop again to restore the original order - and now those tweaks have been applied to the negative prediction instead. It's a way to route any pre-CFG node's work at the other side of the CFG equation without building a second chain. That's the trick the node exists for.

When is this worth touching? Three honest cases. One: diagnostics - a fixed seed with the swap on for a portion of sampling tells you in a couple renders what the uncond baseline contributes (usually: structure, sometimes a lot). Two: experimental styling where you genuinely want the sampler repelled from your prompt's most dominant tokens - it produces bizarre, defocused results that occasionally read as an intentional "dreamy" look. Three: the chain-route trick above, if you're deep enough into pre-CFG play to need it.

The inputs are model and enabled (default on). The output is the patched MODEL. There's no sigma window on this node, so it swaps at every step it's active - if you want it for only part of sampling, gate it with start_at_sigma-style nodes or just toggle the enabled box between renders.

A warning that costs nothing to heed: do not leave this on accidentally. A flipped workflow produces output that looks like a broken model - which is the point of a probe, but it's also a great way to spend an hour convinced your checkpoint corrupted. Test it on a fixed seed with enabled as your switch.

Install with the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/Extraltodeus/pre_cfg_comfy_nodes_for_ComfyUI

or search pre_cfg_comfy_nodes_for_ComfyUI in ComfyUI Manager and restart. No models, no extra dependencies.

It's a toy with a serious twin purpose. If you never use it, you're not missing out on quality. But the next time you wonder "what is the negative actually doing here?", this is the fastest answer.

Categorymodel_patches/Pre CFG

Inputs (2)

NameTypeDefaultDescription
modelMODEL
enabledBOOLEANtrue

Outputs (1)

NameTypeDescription
MODELMODEL