LTLatentOp
Do Math on Your Latents Without Leaving the Graph
- latent
- LATENT
LTLatentOp applies a unary math operation to a latent's samples: add, mul, pow, exp, abs, clamp_bottom, clamp_top, norm, mean, std, sigmoid, or nop. It's the pack's "tune-up" node - you generate noise, then reshape its statistics before you ever hit the sampler. Think of it as the adjustment layer for the latent space.
This is where the pack stops being a novelty and starts being a toolkit. Generate a Gaussian noise with LTGaussianLatent, blend it, load a saved pattern, and then use LTLatentOp to fix whatever drifted. The author's examples show an abs pass turning a clean gaussian into a half-wave rectified mess that the model then interprets in weird, occasionally gorgeous ways.
How it works
Every op is a direct torch call on latent["samples"] - no model involved, no weights, effectively free. The ones worth knowing by heart:
norm- z-score the whole latent: zero mean, unit variance. This is the "fix it" button for a latent whose stats drifted away from what the model expects.mean- shifts so the actual mean equalsarg.std- rescales so the actual standard deviation equalsarg.clamp_bottom/clamp_top- clip values toarg.add,mul,pow,exp,sigmoid- the exotic shaping tools.nop- literally nothing. Handy for keeping a branch alive without changing values.
The inputs that matter
latent- input LATENT.op- the 12-way dropdown.arg- the float argument, with a tooltip that saves you confusion: ignored forexp,abs,norm, andsigmoid. Don't go looking for a value that isn't used.
Where people get burned
The mean and std ops are not the same thing as the mean/std inputs on LTGaussianLatent. Those generate noise with a target distribution; these recompute and fix the distribution of whatever latent is already sitting there. Easy to mix up, so keep it straight: generator vs. editor.
Also remember every op changes the noise that the sampler sees. If you normalize a noise you carefully shaped with a specific std, you've just thrown away the shaping - chain ops deliberately (generate → clamp → norm) rather than on a whim.
Installing it
Part of xl0's Latent Tools pack. ComfyUI Manager → search Latent Tools → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/xl0/latent-tools
Restart, and it's under LatentTools. The pack's only dependency is lovely-tensors (Manager installs it; manual cloners may need pip install lovely-tensors). No model files - this node is pure tensor arithmetic and runs in milliseconds.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| latent | LATENT | — | |
| op | COMBO | 12 options: add, mul, pow, exp, abs, clamp_bottom, +6 | |
| arg | FLOAT | 0.000-99999–99999 | Ignored for exp, abs, normalize and sigmoid |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |