Nodes/CFG Megapack/Power-Law CFG (Lehman Pavasovic et al. 2025)
ComfyUI Node

Power-Law CFG (Lehman Pavasovic et al. 2025)

The guidance scale that grows with the argument

By AbstractEyes·Created 5 days ago·Updated 5 days ago· 3
Power-Law CFG (Lehman Pavasovic et al. 2025)
  • model
  • MODEL
◄scale-1.0►
◄alpha0.90►
◄omega-1.00►
◄spaceauto (the method's own)►

Every other guidance rule in this pack picks a number - fixed, scheduled, capped, damped - and applies it to the disagreement between your prompt and the model's prior. Power-Law CFG (Lehman Pavasovic, Verbeek, Biroli & Mezard, arXiv 2025) argues that the number shouldn't be fixed at all: the right amount of guidance depends on how big the disagreement already is, and it should scale with it as a power law.

The rule

c + omega · ||c - u||^alpha · (c - u)

Read that as a per-sample effective scale of 1 + omega · ||c - u||^alpha. When the conditional and unconditional predictions are close, guidance is gentle. When the model's prior is fighting your prompt hard, guidance ramps up. With alpha at 0, the norm term disappears and you're back to plain CFG - which is exactly what the node does when you set it that way, and the cleanest way to check your wiring.

The inputs

  • alpha - the exponent on the difference's norm, default 0.9 (the paper's value). 0 is plain CFG.
  • omega - the coefficient, default -1, which means "use w - 1" so that the node inherits its strength from the scale you set. Set it explicitly and you're choosing the coefficient directly.
  • scale - the guidance scale for the rule; -1 (default) inherits the KSampler's cfg.
  • space - leave on auto (the method's own). The rule is nonlinear, so moving it changes the image.

One MODEL out, patched, in the usual loader → node → KSampler position.

Why this one needs a warning label

The norm in that formula is an absolute size, and the size of a latent tensor scales with the number of elements in it - which means omega is not a portable number. Change from 1024×1024 to 768×768 and the difference's norm changes; change from SDXL to a 16-channel transformer and it changes again. The paper's own constants were chosen in a particular normalisation, and they don't transfer to the node's default space by themselves.

The pack is refreshingly blunt about this in its own notes, and I'll pass the number along: their showcase used omega 2.42 on SDXL at 1024×1024, where the size of the guidance difference was around 2.7, plus a scale of 19.2 so the effective scale landed where the reference image's cfg sat. That's not a recipe to copy - it's a demonstration that "defaults plus a small tweak" is not how this node gets tuned.

If what you want is guidance that adapts to how hard the model is resisting, and you don't want a re-tuning ritual every time you change resolution, MAMBO-G is the same family with the same motivation and a dimensionless ratio instead of an absolute norm. That one travels between models with its defaults intact. Power-Law CFG is worth trying when you specifically want the paper's shape - an effective scale that rises with the disagreement - and you're willing to measure what you're working with.

Which brings us to the useful trick: you can measure it. Chain CFG Measure: Per-Step Probe after this node and read the size of the guidance difference off each step's line. That's the number the exponent is being applied to, and it's the number you need to set omega sensibly.

Install

ComfyUI Manager: search CFG Megapack, install, restart. comfy-cli: comfy node install comfy-cfg-megapack. By hand:

cd ComfyUI/custom_nodes
git clone https://github.com/AbstractEyes/comfy-cfg-megapack

Restart ComfyUI. No requirements.txt, no model downloads, no extra packages - the pack runs on torch and the Python standard library through ComfyUI's newer node API (comfy_api.latest). Tested on ComfyUI 0.38.0 with torch 2.11, GPU and CPU-only. On a shared card, CFG_MEGAPACK_VRAM_FRACTION=0.6 before launch caps how much of it the pack claims.

It costs nothing at sampling time - no extra model evaluations, no extra buffers.

Traps

  • It writes the combine stage, so it's exclusive. Chain it after APG, CFG-Zero*, MAMBO-G, PMC-CFG or one of the Mix nodes and you've replaced it. A later node of the same stage wins.
  • Don't carry omega between resolutions or model families. That's the whole caveat above, and it's the reason people conclude "the method doesn't work" after one try.
  • Pushing alpha up is not the same as pushing scale up. Higher alpha amplifies the disagreement nonlinearly, which is a different look from a stronger constant scale - sharper commitment to the dominant interpretation, less of the middle ground.
  • Other packs' CFG-function nodes share ComfyUI's single slot. A RescaleCFG, Mahiro or RenormCFG chained after this node takes it and wins.
CategoryCFG Megapack/papers/combining the two predictions

Inputs (5)

NameTypeDefaultDescription
modelMODEL—
scaleFLOAT-1.0-1–100The guidance scale w for this rule. -1 uses the sampler's cfg value.
alphaFLOAT0.900–3Exponent on the difference's norm (0 = plain CFG).
omegaFLOAT-1.00-1–100The coefficient (-1 = w - 1).
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—