Nodes/KJNodes for ComfyUI/CFG Zero Star/Init
ComfyUI Node Runs on cloud

CFG Zero Star/Init

The CFG-Zero* trick, wrapped as a model patch

By kijai·Created 3 years ago·Updated about 21 hours ago· 2,930
CFG Zero Star/Init
  • model
  • MODEL
use_zero_inittrue
zero_init_steps0

This is kijai's implementation of CFG-Zero*, a small tweak to how classifier-free guidance is applied that quietly made the rounds on Wan and Flux as a "free quality" trick. The node's own description just points at the source repo (WeichenFan/CFG-Zero-star), which is very on-brand for KJNodes - the docs live in the tooltips. Here's what it's doing and whether it's worth wiring in.

The idea, in plain terms

Classifier-free guidance works by running the model twice per step - once with your prompt, once with the unconditional (empty) prompt - and pushing the result away from the unconditional. Standard stuff. CFG-Zero* makes two observations. First, in the very first sampling steps the model's estimate of that direction is basically garbage - the latent is still mostly noise, so applying strong guidance there does more harm than good. Second, the scale at which you combine the two passes can be optimized rather than left at a flat 1.0.

So the node does two things. use_zero_init zeroes out those useless earliest steps entirely - it lets the walk settle before guidance kicks in. And the "star" part rescales the guided output using an optimized projection instead of the naive CFG formula. The net effect people report on Wan and Flux is cleaner structure and fewer early-step artifacts, at no real cost. It first showed up in the community around Wan/Flux in early 2025 and stuck around as one of those low-risk toggles.

It's a model patch: MODEL in, patched MODEL out. Drop it in front of your sampler and it applies during sampling.

The inputs that matter

There are only two, which is refreshing:

  • use_zero_init (default true) - turn the zero-initialization on. This is the part that skips guidance on the earliest, noisiest steps. Leaving it on is the intended behavior.
  • zero_init_steps (default 0) - how many steps to zero out. Zero means it applies the projection fix but doesn't blank any steps; bump it to 1 or 2 to actually skip the first step or two. On flow-matching video models a small value is where people land - one or two, not ten.

That's the whole surface. It's the kind of node you set once and forget.

How to install it

It's in kijai's KJNodes pack, filed under KJNodes/experimental (fair - it is).

  • ComfyUI Manager - search KJNodes for ComfyUI, install, restart.
  • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-KJNodes, then pip install -r ComfyUI-KJNodes/requirements.txt, restart.

No downloads, no dependencies - it's pure sampling math.

Common issues & troubleshooting

You see no difference. Two likely reasons. One, you're running at CFG 1 - a guidance-distilled model (Z-Image Turbo, Klein, most distilled Wan setups) has guidance baked in and runs at CFG 1, which means there's no real CFG for this node to reshape. CFG-Zero* is for the case where you're actually running CFG above 1. Two, zero_init_steps is 0, so nothing is being skipped - try 1 or 2 to see the zero-init effect.

Cranking zero_init_steps degrades the image. Skip too many steps and you're throwing away guidance you needed; structure gets vague. This is a one-or-two-step tool, not a "more is better" one. Back it off.

It's in the experimental folder for a reason. Treat it as a nice-to-have tuning pass, not load-bearing. If a workflow misbehaves after you add it, bypass it and confirm it's actually the culprit before going deep - it's exactly the kind of subtle patch that's easy to blame and easy to rule out.

CategoryKJNodes/experimental

Inputs (3)

NameTypeDefaultDescription
modelMODEL
use_zero_initBOOLEANtrue
zero_init_stepsINT0for zero init, starts from 0 so first step is always zeroed out if use_zero_init enabled

Outputs (1)

NameTypeDescription
MODELMODEL