LatentOperationLayerNorm
When your latents need a recalibration, not a rescale
- op
The fastest way to break a generation is to grab a latent, add a number to it, and feed it back into the sampler with no idea what that does. Latents aren't pixels. They're a compressed, roughly centered cloud of values per channel - think of them as a distribution more than a picture. LatentOperationLayerNorm is the node you reach for when you want to re-center and re-scale that distribution without dragging it toward zero the way a plain z-score would.
What it actually does
Under the hood it's one call to PyTorch's torch.nn.functional.layer_norm(latent, latent.shape[1:], eps=1e-8). For every sample in the batch, it computes the mean and variance over everything except the batch axis, then shifts to zero mean and scales to unit variance. The eps is hardcoded at 1e-8 - there's a commented-out epsilon input in the source, so the author clearly thought about exposing it and then didn't. It doesn't matter much; on real latents you won't notice the difference.
One detail worth knowing: the whole thing runs in float32 and casts back to whatever dtype your latent was. That's the _float wrapper every normalize node in this pack uses, and it's there for a reason - fp16 latents blow up on the variance math (the KB's troubleshooting notes call out fp16 overflow as a recurring ComfyUI pain point). If your latent arrives as fp16, the node does the math safely and hands you back fp16.
The inputs, such as they are
There are none. Literally. info_schema lists no required or optional inputs - the node takes no axis, no eps, no toggle. You wire in a latent, you get an op out, that's the whole UI. That's refreshing and also a hint about how this pack works.
The one thing to understand before you use it
Every LatentOperation* node in hnmr293/ComfyUI-latent-ops outputs an op of type LATENT_OPERATION - a deferred Python callable, not an applied latent. This pack is a toolbox of operation builders; it doesn't ship the "apply" node that runs them against a latent. The author (hnmr293, the same person behind sd-webui-cutoff and llul) clearly built it for his own pipelines, which means you either feed the op into something that consumes LATENT_OPERATION - Sonar's SonarApplyLatentOperationCFG is the best-known external consumer - or write your own tiny apply node. If you plug op straight into a VAE Decode, ComfyUI will (correctly) refuse with a type mismatch. You have been warned; this catches everyone the first time.
Install
Standard stuff. ComfyUI Manager → "Install Custom Nodes" → search ComfyUI-latent-ops and click install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/hnmr293/ComfyUI-latent-ops
Restart ComfyUI. There's no requirements.txt and nothing gets downloaded - every node in the pack is plain PyTorch, which you already have. No models, no weights, no post-install ceremony. Everything lands under the hnmr/latent_ops category.
When it's worth it
LayerNorm is the polite middle child of the normalization family in this pack: Normalize z-scores the whole tensor at once, NormalizeAlongAxis does one axis, NormalizeMinMax squashes into 0–1 - and LayerNorm normalizes per sample across all non-batch dims. That makes it the sensible thing to reach for when you're mixing latents from different sources (say, interpolating or feeding one model's latent into another workflow) and you want each one on the same statistical footing before you blend. For a beginner it's a safe-ish "fix my distribution" button: it won't invert your image or clamp everything to a tiny range like some of the others can. Just remember you still need the apply step, and keep an eye on your fp16 - actually, don't, the node already does.
Inputs (0)
No inputs
Outputs (1)
| Name | Type | Description |
|---|---|---|
| op | LATENT_OPERATION | — |