Nodes/cg-noise/UnHijack
ComfyUI Node

UnHijack

The cleanup half of Comfy's noise-hijack trick

By chrisgoringe·Created 3 years ago·Updated 2 years ago· 26
UnHijack
  • latent
  • latent

UnHijack is one half of a pair. On its own it does almost nothing; paired with its partner Hijack, it's how you add variation to any sampler - including third-party ones you can't swap for a drop-in replacement.

Here's the sneaky thing about how the cg-noise pack works. Instead of just handing you a modified KSampler, the Hijack node reaches into Comfy and replaces the internal function that generates the initial noise (comfy.sample.prepare_noise) with a version that mixes two seeds. That replacement is literally called a "hijack" - and somebody has to undo it. UnHijack is that somebody.

The pairing is dead simple:

  • Hijack goes right before your KSampler and swaps in the mixed-noise function
  • your KSampler runs as normal
  • UnHijack goes right after and restores the original noise function before the graph moves on

Both nodes are latent pass-throughs: UnHijack takes one LATENT in and hands the same LATENT out. Wire it between your sampler and whatever comes next, usually VAE Decode. It's registered as an output node, so it can legitimately end a branch of the graph.

Why bother with this instead of the dedicated "KSampler with Variations" nodes? Because those only exist for Comfy's stock samplers. The hijack pair wraps whatever sampler you already have - your custom sampler packs, workflow you don't want to rewire. That generality is the whole point.

The failure mode is forgetting to unhijack. The pack is defensive about it: if UnHijack runs and the noise function was never hijacked, it prints a warning to the console and carries on. The worse direction is the opposite - forget the UnHijack and the noise function stays replaced for everything downstream, which can produce baffling results in unrelated parts of the graph. Console messages are where you'll spot both.

Install is the pack install. ComfyUI Manager → search "cg-noise" or "chrisgoringe" → install → restart → hard refresh, or:

cd ComfyUI/custom_nodes
git clone https://github.com/chrisgoringe/cg-noise.git

Then restart. No models, no dependencies beyond Comfy itself.

One honest caveat: the pack is retired. The author rebuilt the whole concept in cg-noisetools once Comfy made noise a proper datatype, and that's the maintained path. UnHijack is bookkeeping for the old approach - it still works in existing workflows, it's just not where development went.

Categorynoise/hijack

Inputs (1)

NameTypeDefaultDescription
latentLATENT

Outputs (1)

NameTypeDescription
latentLATENT