ComfyUI Node

Cadence

Diffuse every Nth frame, dissolve the rest

By Statistical-Impossibility·Created 4 months ago·Updated 3 months ago· 0
Cadence
  • warped_old
  • corrected
  • fresh
  • flow
  • frame
  • next_anchor
  • is_gen
◄loop_index0►
◄cadence1►
◄num_frames1►
◄is_startfalse►
◄flow_factor1.00►

If you've watched a Deforum-style loop grind through 300 frames at 20 sampler steps each, you've met the problem this node solves. Cadence is the classic Deforum speed trick: instead of diffusing every frame, you diffuse every Nth frame and fill the in-betweens by warping your two image lineages along the motion schedule and cross-dissolving them. At cadence 4 your sampler runs a quarter as often - the difference between a 20-minute loop and a 5-minute one, for roughly the same perceived smoothness.

It's one of the five building blocks in the Stat-Imp pack, which is otherwise the depth warp, the two color-coherence nodes, and the optical-flow estimator. Cadence is the scheduler/dissolve brick: the part that decides which frames actually cost a diffusion pass.

How it works

Every Nth iteration is a gen frame (loop_index % N == 0); the ones between are tweens. Each tween cross-dissolves the two most recent image lineages with a weight that ramps across the span, and a tail divisor makes sure the final fade completes on the last frame. Two details are worth internalizing:

  • Lazy inputs. The node only pulls fresh on gen frames and warped_old on tweens, so the sampler and the second warp genuinely don't run in between. That's not just optimization - it's the whole point.
  • The vanilla semantic (counter-intuitive, but correct): new diffused content arrives up to N frames after its schedule index. It fades in across the following span instead of snapping in. That's exactly how original Deforum behaves, and it's why cadence = 1 is a mathematical no-op you can safely leave wired.

The node has zero widgets by design - every scalar input is forceInput, fed from the Deforum harness rather than hand-typed. That's deliberate: no saved widget values to drift out of sync with the loop.

Inputs and outputs that matter

  • loop_index (from ForLoopOpen), cadence (diffuse every Nth; 1 = off), num_frames, is_start (true on the loop's first iteration).
  • warped_old, corrected, fresh - the image lineages. fresh is only requested on gen frames, which is what skips the sampler.
  • flow and flow_factor (optional) - plug in the Compute Optical Flow node to flow-morph the lineages into alignment before the dissolve instead of a plain cross-fade.

Outputs: frame (the emit - a dissolve on tweens, the fresh diffusion on gens), next_anchor (the lineage to carry to the next iteration via ForLoopClose), and is_gen - a boolean you wire into a graph-level LazySwitch on the latent path to actually gate the sampler.

Install

This is a loop-internal node, so it needs the Deforum harness around it - specifically this author's fork of deforum-comfy-nodes, which widens the loop's carry state to 10 value sockets (Cadence threads several images through the loop) and fixes the value-schedule parser so sin/cos and multi-arg functions work:

cd ComfyUI/custom_nodes
git clone https://github.com/Statistical-Impossibility/comfyui-Stat-Imp-nodes
git clone https://github.com/Statistical-Impossibility/deforum-comfy-nodes

Restart ComfyUI and hard-refresh the browser; the nodes appear under Stat-Imp / Deforum. (ComfyUI Manager can install the pack too, if that's your habit.) The core is pure torch with no extra Python dependencies.

Common issues

The #1 gotcha is the fork. If your loop errors on a missing ForLoopOpen value slot, or value schedules throw NameError on cos(t), you've installed upstream deforum-comfy-nodes instead of the fork - swap it and the example workflow runs. The other classic: you wire is_gen somewhere and "nothing happens," because the gate is graph-level - you have to actually feed a LazySwitch on the latent path. And if your tweens look smeary, don't blame Cadence; that's the dissolve working as designed, and the flow input is the upgrade path.

CategoryStat-Imp/Deforum

Inputs (9)

NameTypeDefaultDescription
loop_indexINT0—
cadenceINT1—
num_framesINT1—
is_startBOOLEANfalse—
warped_oldIMAGE—
correctedIMAGE—
freshIMAGE—
flowoptFLOW—
flow_factoroptFLOAT1.000–1—

Outputs (3)

NameTypeDescription
frameIMAGE—
next_anchorIMAGE—
is_genBOOLEAN—