LatentSubtract
Difference arithmetic on images that aren't images yet
- samples1
- samples2
- LATENT
Latent Subtract does elementwise samples1 - samples2 on two latents. That's the whole mechanism, and the source even labels it with the search aliases "difference latent" and "remove features", which tells you how it's meant to be used. It's the subtraction half of latent arithmetic - the tool that lets you ask "what is the difference between these two images" in the model's own coordinate system rather than in pixels.
Inputs: samples1 and samples2. It reshapes the second to match the first (so mismatched resolutions get squished rather than rejected), subtracts, and outputs a LATENT.
Why subtracting latents is useful
The classic latent arithmetic play is direction vectors. Generate "man" and "woman" with identical settings, subtract one latent from the other, and you get a direction in latent space. Add that direction to a "king" latent and you're doing the old king - man + woman trick with real embeddings - except here the embeddings are full images. A more practical everyday use is feature removal: if image B is image A plus a style change, their difference is the "style delta" you can scale (with Latent Multiply) and apply elsewhere.
The other big use is error-signal workflows: subtract a reference latent from a candidate to visualize exactly where they diverge, then feed that difference downstream to target regeneration. And for debugging, subtracting two latents from the same prompt with different seeds shows you what the seed actually changed, which is occasionally illuminating and occasionally just noise.
The honest caveats
A difference latent is not an image. If you decode A - B directly you'll get something that looks like a hallucination - structured noise that happens to live at the boundary of the two pictures. The output is meant to be combined with something, not viewed. That trips people up constantly: they subtract, decode, see garbage, and assume it's broken. It isn't; it's a vector.
Second, shapes get silently reshaped - samples2 is stretched to fit samples1. If you're subtracting latents of different resolutions, the result is computed on a squished version of the second input. For meaningful arithmetic you want both latents generated at the same resolution from the same model - ideally the same seed so the only difference is the thing you changed (prompt, LoRA, whatever). Subtract latents from different models and you're subtracting across incompatible coordinate systems, which produces exactly nothing useful.
It ships with ComfyUI core - no install, no model files. The realistic take: it's a niche node that becomes indispensable exactly once you've internalized that latents are vectors and that arithmetic on them is a real operation. Keep it paired with Latent Multiply and Latent Add and you've got the full latent-arithmetic kit.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| samples1 | LATENT | — | |
| samples2 | LATENT | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |