Nodes/ApplySpectralLock/Apply Spectral Lock (Flux/USDU)
ComfyUI Node

Apply Spectral Lock (Flux/USDU)

Apply Spectral Lock

By lookuters22·Created 3 months ago·Updated 3 months ago· 0
Apply Spectral Lock (Flux/USDU)
  • model
  • latent_orig
  • patched_model
kernel_size15
blur_sigma3.0
alpha_lock0.85
gamma_max0.70
clip_k2.0
decay_type
edge_taper8

Apply Spectral Lock is a model patch that keeps low-step Flux from turning a hi-res fix into digital grain. If you've ever run Flux through Ultimate SD Upscale and watched each tile drift off into its own crunchy, oversaturated mess - or pushed denoise to 0.8 and gotten back an image that isn't even the same composition anymore - this is aimed squarely at you. It's a niche tool from a single-author pack, barely six impressions of Google traffic, so treat it as a new kid, not a household name. But the problem it solves is real and current.

What it actually does

Flux is a rectified-flow model, and distilled/turbo-era Flux (CFG 1, low steps) has a nasty habit: the solver overshoots detail in the late steps and produces what the author calls the "Turbo paradox" - a crisp-looking image that's actually a carpet of grain and halos. Tiled upscaling makes it worse, because every tile re-denoises independently and blends into visible seams.

This node attacks both halves with two decoupled controls. A structure lock anchors the low frequencies (composition, color, lighting) to a reference latent from step 0, so you can run a hi-res fix at high denoise without the scene drifting. A detail gate doesn't blanket-blur the high frequencies - that's the trap most "grain fix" patches fall into. Instead it soft-clips the extreme spikes in the high band, taming the grain while ordinary detail sails through. That distinction is the whole point: grain is sparse, extreme outliers, so clipping outliers preserves what real detail was there.

How it works

The node clones your model and injects a post-CFG callback - the same patch pattern as other model-patch nodes, applied via set_model_options_post_cfg_function. Every step it splits the denoised 16-channel latent into low and high bands with a depthwise-separable Gaussian (two conv2d passes, one per axis, reflect padding), then:

  • blends the low band toward a blurred/cropped version of latent_orig at strength alpha_lock,
  • soft-clips the high band with a tanh knee at clip_k × sigma, blended in at gamma_max strength,
  • ramps that gate with sampling progress (cosine by default, so it mostly engages in the final steps).

It only touches latents with 16 channels - Flux territory. Your SD 4-channel latents pass through completely untouched, so you can leave it in a shared workflow without breaking non-Flux models.

The inputs that matter

  • latent_orig - the reference. VAE-encode your guide image (or the base latent) and feed it here. This is the only non-obvious one, and it's mandatory.
  • alpha_lock (default 0.85) - how hard low frequencies stick to the reference. If composition still drifts, nudge up.
  • gamma_max (default 0.70) - how much grain suppression engages in the final steps. Seeing mush? Lower it.
  • clip_k (default 2.0) - the knee. Lower = more aggressive grain removal, higher = gentler, more detail kept. This is your taste dial.
  • kernel_size (15) / blur_sigma (3.0) - the Gaussian that defines "low" vs "high" frequency. Leave them unless you know why you're changing them.

decay_type flips the gate between cosine and linear. edge_taper zeroes the adjustment at tile borders so USDU seam blending sees a clean edge - the README's table claims 48 as the default, but the shipped code and node UI actually use 8, and the code wins. Keep kernel_size coherent with your tile overlap or large blur radii can still stress seams.

Wiring it up

One output, patched_model. Drop the node between your loaded model and the sampler (or the USDU chain): model → ApplySpectralLock → sampler. The hook is registered with disable_cfg1_optimization=True, so it fires even when CFG is disabled - which is the normal state for distilled Flux.

Installing it

Same as any custom node:

cd ComfyUI/custom_nodes
git clone https://github.com/lookuters22/ComfyUI-ApplySpectralLock

Restart ComfyUI. That's it - no model downloads, no extra dependencies beyond the torch ComfyUI already ships (the pyproject lists only torch). It should also be findable through ComfyUI Manager once indexed. MIT licensed, so no license anxiety.

Honest verdict

Spectral lock is a clever answer to a real annoyance, but it's a one-node pack from an unknown author with essentially no track record yet. The defaults are starting points, not gospel - treat gamma_max and clip_k as sliders to test, and A/B against your plain USDU workflow before trusting it. That said, the design is unusually thoughtful for a niche patch: the tanh-knee approach kills grain without flattening detail, and the tile-matching means it works with USDU rather than fighting it.

Categorymodel_patches/spectral

Inputs (9)

NameTypeDefaultDescription
modelMODEL
latent_origLATENT
kernel_sizeINT153–63
blur_sigmaFLOAT3.00.1–10
alpha_lockFLOAT0.850–1
gamma_maxFLOAT0.700–1
clip_kFLOAT2.00.5–6
decay_typeCOMBO2 options: cosine, linear
edge_taperINT80–256

Outputs (1)

NameTypeDescription
patched_modelMODEL