Nodes/ComfyUI-ScaleLockedResidualDiffusion/Scale-Locked Runtime Context
ComfyUI Node

Scale-Locked Runtime Context

The unglamorous node that makes the scale-lock graph work

By xmarre·Created 6 months ago·Updated 6 months ago· 2
Scale-Locked Runtime Context
  • noise
  • guider
  • sampler
  • sigmas
  • latent_image
  • runtime
  • prepared_noise
  • lowres_planner
target_megapixels1.00
nested_noise_strength0.35
pin_anchorstrue

If you've opened the ComfyUI-ScaleLockedResidualDiffusion pack and seen the "suggested modular workflow", this is the node everything else hangs off. It's the front half of the pipeline: it runs the low-res planner pass, records the trajectory, and builds the aligned high-res noise that the rest of the graph consumes. It doesn't produce a final image on its own - it produces the context that makes the scale-lock correction possible.

The trade worth knowing up front: this node plus "Scale-Locked CFG Guider" plus a plain SamplerCustomAdvanced is the fully modular way to do what ScaleLockedResidualSamplerCustomAdvanced does in one node. You only build this graph if you want the pieces separately - to swap the guider, inspect the planner, or wire something custom in between. For everyone else, the one-node version is less to go wrong.

What it does

Feed it the same five objects a SamplerCustomAdvanced takes - noise, guider, sampler, sigmas, latent_image - plus target_megapixels (the planner resolution; 1.0 default) and it:

  1. downscales the latent to your target megapixel level and runs the planner pass, caching the per-step denoised x0 trajectory,
  2. builds the nested high-res noise field that shares the planner's coarse layout while carrying nested_noise_strength worth of independent high-frequency detail,
  3. bundles it all into a SLRD_RUNTIME object.

The output you actually care about first is prepared_noise (a NOISE object) - that's the aligned noise field, and it's what replaces your original noise when you sample. The runtime output is the context the guider patcher needs, and lowres_planner is the planner's own final latent, which is handy for confirming the low-res pass did what you expected.

The inputs that matter

Only three knobs here, which is refreshing:

  • target_megapixels - planner resolution in pixel-space MP. The README's Flux.2 Klein 9B-style first settings use 1.0 for a ~4MP target.
  • nested_noise_strength - how much independent high-frequency detail the high-res noise carries. More freedom, more drift risk; 0.35 default.
  • pin_anchors - pinned-memory staging for the planner's trajectory anchors. Leave it on; it's a memory-layout optimization, not a behavior switch.

How to wire it

The README's modular recipe, in order:

  1. Build your base GUIDER, sigmas, and sampler normally.
  2. Run this node with the base noise, guider, sampler, sigmas, and target latent.
  3. Feed the runtime into Scale-Locked CFG Guider - that patches your guider with the scale-lock correction and returns a fresh guider without mutating the original.
  4. Feed prepared_noise and the patched guider into a plain SamplerCustomAdvanced.

That last step is the thing people forget: the runtime context only does its job if the high-res noise field it built actually reaches the sampler. Wire prepared_noise, not the noise you started with.

Install

No extra Python dependencies, no model downloads - it's pure sampling logic.

cd ComfyUI/custom_nodes
git clone https://github.com/xmarre/ComfyUI-ScaleLockedResidualDiffusion

Restart ComfyUI. Or search ComfyUI-ScaleLockedResidualDiffusion in ComfyUI Manager.

Troubleshooting

The main failure mode is a "planner pass did not record any x0 anchors" error, which happens on degenerate runs - check sigmas is non-empty and your sampler is one the pack's guard approves of (euler, heun, ddim, dpmpp_2m, lcm and cfg_pp variants). If you're not using this node in a modular workflow and just want the finished image, seriously, use the one-node sampler instead - you're adding wiring for no benefit.

Categorysampling/scale_locked

Inputs (8)

NameTypeDefaultDescription
noiseNOISE
guiderGUIDER
samplerSAMPLER
sigmasSIGMAS
latent_imageLATENT
target_megapixelsFLOAT1.000.1–16
nested_noise_strengthFLOAT0.350–4
pin_anchorsBOOLEANtrue

Outputs (3)

NameTypeDescription
runtimeSLRD_RUNTIME
prepared_noiseNOISE
lowres_plannerLATENT