Nodes/OmniNodes/Latent Histogram πŸ“Š
ComfyUI Node

Latent Histogram πŸ“Š

Read Your Latent's Distribution Before the VAE Tells You Something's Wrong

By TensorVizionΒ·Created 3 months agoΒ·Updated about 8 hours agoΒ· 0
Latent Histogram πŸ“Š
  • latent
  • histogram_image
  • outlier_percent
  • summary
β—„modeβ–Ύβ–Ί
β—„num_bins48β–Ί
β—„outlier_std_threshold3.0β–Ί
β—„chart_width512β–Ί
β—„chart_height256β–Ί

A single number - mean, std, outlier count - can lie about a latent. Two very different latents can have identical means and standard deviations: one healthy, one with a split personality. Latent Histogram shows you the actual shape of the value distribution, bucketed into a chart you can look at, which is how you catch the bimodal mess or the heavy-tailed corruption that a point statistic just averages away. It's the distribution chart to Latent Visualizer's eyeball preview, and the two together are how you actually see inside a latent without decoding it.

How it works

It bins every value in the latent (pooled across the whole batch) into num_bins buckets and renders a histogram image. Two modes:

  • per_channel - a small-multiple chart, one histogram per channel. The useful one: it shows you which channel is misbehaving.
  • combined - everything pooled into one chart. Coarser, but fine for a quick sanity check.

It also computes an outlier_percent float: the fraction of values more than outlier_std_threshold standard deviations from the mean. The pack's own framing is a good rule of thumb - a healthy latent from a normal sampling run is usually in the low single digits. If you're suddenly seeing 15%, something upstream pushed values out of range: a bad merge, an over-strength noise injection, a channel mixer cranked too hard. That number is your canary.

Inputs and outputs

  • mode - per_channel or combined.
  • num_bins (8–256, default 48) - resolution of the chart. More bins, finer detail, noisier at low values.
  • outlier_std_threshold (default 3) - defines what "outlier" means.
  • chart_width / chart_height - output image size. 512Γ—256 is a fine default.

Outputs: histogram_image (wire into a Preview node), outlier_percent (a real FLOAT you can gate on), and summary.

Where it fits

This is a QC and debugging node. The genuinely useful pattern: put it after a KSampler in a workflow you're iterating on, and glance at the chart before you waste a VAE decode. When you're merging models or testing a new LoRA at weird strengths, the histogram catches the "distribution has left the building" failure faster than your eyes catch the resulting garbage image.

One thing to know before you compare numbers across nodes in this pack: Latent Histogram computes its outlier stat with mean/std, while the pack's Latent QC Gate uses median/MAD for its automated check. They're deliberately not the same statistic - the chart is for you to read, the gate is engineered to resist being fooled by a large bad batch. Don't expect the two numbers to match exactly.

Install

Pure NumPy/PyTorch, nothing extra to install:

cd ComfyUI/custom_nodes
git clone https://github.com/TensorVizion/OmniNodes

Restart, find it under TensorVizion/Latent (or install via ComfyUI Manager, search "OmniNodes"). Confirm registration with the [OmniNodes] βœ… Loaded terminal line.

Troubleshooting

  • The chart is a single spike at zero. Your latent is near-blank - the QC Gate's near-blank check exists precisely for this. Something upstream failed.
  • outlier_percent is high but the image looks fine. Your threshold is set tight. Nudge outlier_std_threshold up to 4 before panicking.
  • All channels look identical in per_channel mode. That's suspicious - healthy latents have distinct channel distributions. Check that you're not looking at a degenerate latent or a bug in whatever built it.

It won't fix anything by itself. What it gives you is the ability to see a latent's health in two seconds, and for a pack built around latent diagnostics, that's the foundation the other nodes build on.

CategoryTensorVizion/Latent

Inputs (6)

NameTypeDefaultDescription
latentLATENTβ€”
modeCOMBO2 options: per_channel, combined
num_binsINT488–256β€”
outlier_std_thresholdFLOAT3.00.5–10β€”
chart_widthINT512128–2048β€”
chart_heightINT25664–1024β€”

Outputs (3)

NameTypeDescription
histogram_imageIMAGEβ€”
outlier_percentFLOATβ€”
summarySTRINGβ€”