Nodes/ComfyUI Model Bending/Timestep Gated Bending
ComfyUI Node

Timestep Gated Bending

Bend while composition forms, then let go

By abuzreq·Created 2 years ago·Updated 11 days ago· 26
Timestep Gated Bending
  • bending_module
  • BENDING_MODULE
◄t_start1.00►
◄t_end0.70►
◄ramphard►
◄ramp_width0.10►

Ask anyone who's used ControlNet what the most important knob is and they'll say the start/end step pair - release the condition once composition has formed and let the model add its own detail. Every serious control technique converges on the same insight: when you intervene matters as much as how hard.

Timestep Gated Bending is that knob for this pack. It wraps any bending module and limits it to a window of diffusion time.

How it works

You plug a BENDING_MODULE in and you get a BENDING_MODULE out - a wrapped one. The appliers downstream (Model Bending, DiT Block Bending, Attention Map Bending, and friends) notice the wrapper and, instead of applying the bend flat, ask it for a weight at the current diffusion time. The result is a blend:

out = x + w(t) * (bend(x) − x)

So w = 1 is the full bend, w = 0 is no bend at all, and a ramp gives you everything in between. Outside the window the weight is zero and the layer passes through untouched.

The clever part is what t is. It's not the step number - it's normalised diffusion time, derived from the model's own timestep mapping for the current sigma, so 1 is pure noise and 0 is the clean image. That means your window survives changing the step count, the scheduler, the shift on a flow-matching model, or the denoise strength on an img2img pass. A "steps 0–4" window breaks when you go from 20 steps to 30. A "t 1.0–0.7" window doesn't.

Ramps only fade at interior edges, by the way. A window that starts at 1.0 or ends at 0.0 has nothing outside it to fade to, so the ramp is skipped there - a deliberate detail, and one that saves you wondering why the fade-in did nothing.

Inputs

  • bending_module - the module to gate.
  • t_start - default 1.0, the noisy end.
  • t_end - default 0.7. Together with the default start that's a "composition only" preset, which is a nice statement of intent from the author.
  • ramp - hard (weight jumps to 1), linear, or cosine.
  • ramp_width - default 0.1, the width of the fade at each edge.

Output is the wrapped BENDING_MODULE. In the pack's DiT block workflow it's a cosine-gated Rotate at 15° on double:13-18 - bend the middle blocks over the first 40% of the noise schedule and leave the detail steps alone.

Choosing a window

The node's own tooltip is the best guide available, and it lines up with what you'd guess from any diffusion model:

  • 1.0 → 0.7 - composition and layout. Big, structural moves. This is where you get "the whole frame tilts" or "the two figures swap places".
  • 0.7 → 0.2 - shapes and style. Where most aesthetic bending wants to live.
  • 0.2 → 0 - detail. A bend here shows up as texture and finish, and it's the window least likely to break your image.

Start hard, watch the result, then add a ramp if the transition looks like a step change in the middle of the render. ramp_width 0.1 with cosine is a gentle place to begin.

Install

ComfyUI Manager → "ComfyUI Model Bending", or:

cd ComfyUI/custom_nodes
git clone https://github.com/abuzreq/ComfyUI-Model-Bending
pip install -r ComfyUI-Model-Bending/requirements.txt

kornia and scikit-learn, then a restart. Everything the pack prints is tagged [model-bending], which is how you'll spot the gating warnings below.

Where people get burned

  • The gate can't resolve diffusion time. On a model whose sampling object the wrapper can't read, the time-windowed bend is skipped for that pass and you get one warning. It fails closed on purpose - better an unbent image with a log line than a bend applied at every step. If you see the warning and want the effect anyway, use a step-number window instead (Model Bending's steps field, or Attention Map Bending's steps).
  • Expecting a gate to make a violent bend safe. It changes when, not how much. A rotate at 90° is still a rotate at 90°; you've just confined the damage.
  • Gating the same module twice. Wrap once. Stacking two gates on one module doesn't multiply the effect, it just makes the window intersect in ways that are hard to reason about.
  • Forgetting that weight blends per layer call. On a model that evaluates a layer several times per step, the blend uses the same t for all of them - no per-call surprises, but also no per-call control.
  • Confusing this with a bending applier. Timestep Gated Bending doesn't touch a model and outputs no MODEL. It's a modifier sitting in the wire between a module node and its applier.
Categorymodel_bending

Inputs (5)

NameTypeDefaultDescription
bending_moduleBENDING_MODULE—
t_startFLOAT1.000–1Window start in diffusion time (1 = pure noise)
t_endFLOAT0.700–1Window end in diffusion time (0 = clean image)
rampCOMBOhard3 options: hard, linear, cosine
ramp_widthFLOAT0.100–1Width of the fade-in/fade-out at each window edge

Outputs (1)

NameTypeDescription
BENDING_MODULEBENDING_MODULE—