Nodes/ComfyUI_agilly1989_motorway/PerpNeg_motorway_edition
ComfyUI Node

PerpNeg_motorway_edition

PerpNeg as a model patch, bus-style β€” better negatives without a custom sampler

By agilly1989Β·Created 2 years agoΒ·Updated about a year agoΒ· 7
PerpNeg_motorway_edition
  • MOTORWAY πŸšŒπŸ’¨
  • MOTORWAY πŸšŒπŸ’¨
β—„INPUT_model_keymodelβ–Ί
β—„INPUT_empty_conditioning_keyempty_conditioningβ–Ί
β—„neg_scale1.00β–Ί
β—„OUTPUT_MODEL_keyMODELβ–Ί

There are two ways to get PerpNeg ("perpendicular negative") into a generation. One is the guider version, which slots into a custom sampling chain. This is the other one: a model patch that gives you the same trick while letting you keep using a plain sampler. And like everything in the Motorway pack, it exchanges direct wires for named keys on a shared bus.

The mechanism is identical to the guider's. In normal classifier-free guidance the update is uncond_pred + (cond_pred - uncond_pred) * cfg, and PerpNeg decomposes that update into a part parallel to the negative prompt's direction and a part perpendicular to it. By default it keeps only the perpendicular component, so your negative prompt steers the image away from what you named without dragging unrelated pixels with it. The neg_scale widget (default 1) controls how much of that perpendicular direction survives.

What makes this one different

The guider version has to be wired into SamplerCustomAdvanced's guider input, which means building a whole custom sampling stack. The patch version instead returns a modified MODEL - you keep your normal KSampler or SamplerCustom and just hand it the patched model. For most people that's the friendlier entry point to PerpNeg, and it's easier to toggle on and off.

On the bus, the inputs are:

  • INPUT_model_key (default model) - the checkpoint sitting on the bus.
  • INPUT_empty_conditioning_key (default empty_conditioning) - the blank conditioning that PerpNeg compares against.

And the one knob that matters: neg_scale, default 1. If your image is already good and you just want negatives to bite a little harder, nudge this up. If results get weird or burned, dial it down toward 0.

The patched model lands back on the bus under OUTPUT_MODEL_key (default MODEL). Whatever sampler node you use downstream needs to read that key - if it defaults to reading model, point it at MODEL or rename the key to match. Keys are shared by name across the whole workflow and are case-sensitive.

Install

No dependencies, no model downloads - it's a git clone plus restart:

cd ComfyUI/custom_nodes
git clone https://github.com/agilly1989/ComfyUI_agilly1989_motorway

ComfyUI Manager works too: search the pack title ComfyUI_agilly1989_motorway and install.

Watch out for

Two things, both from the pack's own history. First, this is a beta project whose author literally warns "IF THINGS BREAK ITS BECAUSE I BROKE IT." Second, the _motorway_edition clones were generated by an auto-cloner that build 1.1.7 removed, so if you install today and this node isn't in your menu, that's not user error - the clone simply isn't generated on the latest build. Pinning to an older 1.1.x commit of the pack is the workaround if you really want it.

The classic error is KeyError: 'hash_...' doesn't exist in motorway - that key was never stored, so trace your upstream ramps and confirm the name. And since the bus overwrites silently, don't reuse model for two different things in one flow.

If PerpNeg isn't doing anything for you, it's worth remembering that on guidance-distilled models (Flux, Turbo, anything running CFG β‰ˆ 1) negative prompts are structurally weak sauce - no patch fully fixes that.

Categoryagilly1989 Nodes/Motorway-ed/_for_testing

Inputs (5)

NameTypeDefaultDescription
MOTORWAY πŸšŒπŸ’¨MOTORWAY πŸšŒπŸ’¨β€”
INPUT_model_keySTRINGmodelβ€”
INPUT_empty_conditioning_keySTRINGempty_conditioningβ€”
neg_scaleFLOAT1.000–100β€”
OUTPUT_MODEL_keySTRINGMODELβ€”

Outputs (1)

NameTypeDescription
MOTORWAY πŸšŒπŸ’¨MOTORWAY πŸšŒπŸ’¨β€”