Nodes/CFG Megapack/CFG-OEC: orthogonal error correction (Yang et al. 2025)
ComfyUI Node

CFG-OEC: orthogonal error correction (Yang et al. 2025)

Correcting the negative branch with its own mistakes

By AbstractEyes·Created 5 days ago·Updated 5 days ago· 3
CFG-OEC: orthogonal error correction (Yang et al. 2025)
  • model
  • MODEL
◄scale-1.0►
◄tau0.50►
◄spaceauto (the method's own)►

Every other node in this pack treats the two model predictions as opaque vectors. CFG-OEC (orthogonal error correction, Yang, Lee & Han, arXiv 2025) is the one that looks at how they change from step to step, and uses the difference as a signal.

The idea, stated plainly: at each step you can compute the error of the unconditional prediction - how much it moved between the previous step and this one. You can compute the same thing for the conditional prediction. If those two errors point in similar directions, the model is consistently wrong in the same way in both branches, and there's nothing interesting to separate. If they point in very different directions, the negative branch is drifting somewhere the positive branch isn't going - and taking only the part of the negative's error that is orthogonal to the positive's, and using it to correct u, is a targeted way to clean that up before guidance amplifies it.

That's the "when the two errors disagree" condition in the node's own description, and it's what tau sets: correct only when the cosine between the two errors is below the threshold.

Inputs

  • model - the model wire, before the sampler.
  • scale (default -1) - -1 takes the KSampler's scale, as with every combine node in the pack.
  • tau (default 0.5) - the cosine gate. Above tau, the two errors are considered to agree and the correction is skipped for that step. Below it, the orthogonal correction is applied. -1 means "never correct", which is a straight swap back to plain CFG and a good way to sanity-check that the node is doing anything at all. Note the tooltip's honesty: the paper does not give a value for tau. 0.5 is the pack's default, not the authors'. This is the input you're most likely to have to tune, and the one most likely to need tuning per model.
  • space - auto picks the method's own space (noise prediction for most methods in this line, velocity on flow models). Nonlinear, so don't move it without a reason.

Output: a single MODEL.

Practical notes

It needs history. The correction depends on the previous step's error, so the first step has nothing to compare against and effectively passes through untouched. It also means the node is stateful across the run, and the pack keeps that state in the model's guidance plan - which has consequences if you're doing anything clever like changing the model mid-schedule with a MultiSampler or a two-stage workflow: the plan travels with the model object, not with the sampler.

This is the least settled node in the batch. Two of the pack's own descriptions say the paper gives no value for a knob (here) or that the paper's published value wrecks images on noise-prediction models (SMC-CFG). That's not a criticism of the pack - it's publishing what the literature actually says instead of inventing a consensus - but it does mean you're exploring, not applying a known recipe. If you only want one guidance experiment today, pick one of the rescalers instead.

Install

# ComfyUI Manager: search "CFG Megapack" -> Install -> restart
# or:
comfy node install comfy-cfg-megapack
# or by hand:
cd ComfyUI/custom_nodes && git clone https://github.com/AbstractEyes/comfy-cfg-megapack

No dependencies, no model downloads, ComfyUI 0.38+ (it uses comfy_api.latest).

The pack rules that apply to every node here

The Megapack decomposes guided sampling into seven stages - when to guide, weak branch, how the two predictions combine, where guidance acts, magnitude correction, an angle governor, and measurement - with the stages always running in a fixed order regardless of how you chain the nodes. Consequences worth internalizing: a later node of the same stage replaces an earlier one (except corrections, which stack in order), and a paper node writes the stage its method belongs to, which for CFGOEC is the combine stage.

ComfyUI also has a single CFG-function slot per model. Another pack's RescaleCFG, Mahiro or RenormCFG chained after this one wins and CFG-OEC becomes dead weight; the pack's own pre/post-CFG nodes compose with the shared slot instead. And the hook sets disable_cfg1_optimization, so the unconditional pass always runs while any of these nodes is installed - good for correctness, bad for the CFG-1 speedup, and irrelevant to CFG-OEC specifically at w = 1, where there's nothing to correct.

CategoryCFG Megapack/papers/combining the two predictions

Inputs (4)

NameTypeDefaultDescription
modelMODEL—
scaleFLOAT-1.0-1–100The guidance scale w for this rule. -1 uses the sampler's cfg value.
tauFLOAT0.50-1–1Correct when the errors' cosine is below this (-1 = plain CFG; the paper gives no value).
spaceCOMBOauto (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)

NameTypeDescription
MODELMODEL—