Nodes/ComfyUI_agilly1989_motorway/LatentSubtract_motorway_edition
ComfyUI Node

LatentSubtract_motorway_edition

The node for 'what's actually different here?'

By agilly1989·Created 2 years ago·Updated about a year ago· 7
LatentSubtract_motorway_edition
  • MOTORWAY 🚌💨
  • MOTORWAY 🚌💨
INPUT_samples1_keysamples1
INPUT_samples2_keysamples2
OUTPUT_LATENT_keyLATENT

LatentSubtract_motorway_edition takes two latents out of your Motorway pipe and subtracts the second from the first. One node, no settings beyond the keys. It's the sibling of LatentAdd and the whole "latent arithmetic" family, and it exists because vectors in latent space are meaningful - differences between them carry semantic information.

The honest answer to "what would I use this for?" is: fewer people than you'd think, and mostly as a building block. Latent differences show up in style-transfer experiments (add the difference between two styles to a third latent), in some anime-to-photoreal blending recipes, and in a few editing pipelines that need to isolate "what changed between pass A and pass B." It's also the natural inverse for anyone debugging: subtract a reference latent from your output and the residual tells you what the sampler actually added.

The core node reshapes the second latent to match the first before subtracting, so you won't get a shape mismatch crash if the two batches aren't identical sizes - a nicety that turns a would-be footgun into a no-op.

The wrapper

Standard Motorway-ed clone: core LatentSubtract logic, pipe I/O instead of direct wiring.

  • MOTORWAY 🚌💨 - the pipe. Required.
  • INPUT_samples1_key (default samples1) - the minuend.
  • INPUT_samples2_key (default samples2) - the subtrahend.
  • OUTPUT_LATENT_key (default LATENT) - where samples1 − samples2 lands.

Both latents come out of the same pipe, so the graph upstream needs to have written samples1 and samples2 before this node runs - which in ComfyUI terms means both branches connect back into the pipe spatially before this node. As with every node in this pack, the only output port is the pipe; pull the result out with a Motorway AxB ramp pointed at the LATENT key if you want to feed it into a regular node.

Installing

It lives in the Motorway pack:

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

Or via ComfyUI Manager: search ComfyUI_agilly1989_motorway → Install. No model downloads, no extra pip packages.

Gotchas

  • You need a MotorwayStart (or primitive) node upstream to create the pipe.
  • Keys are exact strings. Key: 'samples1' doesn't exist in motorway means nothing upstream stored that key - check what your encoding branch actually wrote.
  • The pack is a one-dev beta. Author's README, verbatim-ish: "CURRENTLY IN ACTIVE DEVELOPMENT (BETA)! IF THINGS BREAK ITS BECAUSE I BROKE IT." The generated clone nodes have been dropped from releases mid-refactor before, so a missing node is probably a version issue, not you doing it wrong.

Subtraction is a niche tool, but when a workflow needs it, nothing else will do. Keep it in the back pocket for when a latent-space difference is the answer.

Categoryagilly1989 Nodes/Motorway-ed/latent/advanced

Inputs (4)

NameTypeDefaultDescription
MOTORWAY 🚌💨MOTORWAY 🚌💨
INPUT_samples1_keySTRINGsamples1
INPUT_samples2_keySTRINGsamples2
OUTPUT_LATENT_keySTRINGLATENT

Outputs (1)

NameTypeDescription
MOTORWAY 🚌💨MOTORWAY 🚌💨