Nodes/ComfyUI-BFSNodes/LTXV Latent Diff Metrics
ComfyUI Node

LTXV Latent Diff Metrics

Compare two latents before you spend a VAE decode on either

By alisson-anjos·Created 5 months ago·Updated 10 days ago· 100
LTXV Latent Diff Metrics
  • latent_a
  • latent_b
  • metrics
  • latent_a
  • mse
  • psnr
  • l1
  • cosine
labelA vs B
print_consoletrue
compare_noise_maskfalse

This is the latent-space sibling of LTXVImageDiffMetrics in the same pack, and the reason it exists separately matters: you don't have to decode a latent to know whether two sampling runs diverged. If you're debugging why a conditioning change on LTXVEditAnythingLoopingSampler isn't producing the effect you expect, comparing latents directly - before spending a VAE decode on either - is both faster and closer to where the actual difference (or lack of one) originates.

The four metrics, and the one unique to this node

LTXVLatentDiffMetrics reports MSE, PSNR, and L1 the same way its image counterpart does, plus a fourth: cosine similarity. That's the one worth understanding on its own terms, because it measures something genuinely different from the other three. MSE, PSNR, and L1 all care about magnitude - how far apart two tensors are in absolute terms. Cosine similarity cares about direction - whether two latents are pointing the same way in their vector space, regardless of scale. Two latents can have a fairly high MSE (a real numeric difference) while still being highly cosine-similar (structurally the same content, just shifted in intensity) - which is exactly the kind of distinction that's useful when you're trying to tell "the sampler produced a genuinely different image" apart from "the sampler produced the same image with a slightly different global scale," two failure modes that look identical if you only check one metric.

The noise-mask option

There's a fourth optional input worth flagging: compare_noise_mask. If your latent has an associated noise mask (from an inpainting-style workflow, for instance), enabling this restricts the diff stats to just the noisy region of latent_a rather than the full latent - useful when you only care whether the edited region changed as expected and don't want a large, unchanged background dragging your metrics toward "everything looks the same."

Inputs and outputs

Required: latent_a, latent_b. Optional: label (default "A vs B"), print_console (on by default), and compare_noise_mask (off by default). Outputs: metrics (a combined string), latent_a passed through unchanged so you can continue piping it downstream without a separate branch, and the four raw floats mse, psnr, l1, cosine for anything that wants to gate or plot on them programmatically.

Getting it installed

Through ComfyUI Manager, search "ComfyUI-BFSNodes." Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/alisson-anjos/ComfyUI-BFSNodes.git
cd ComfyUI-BFSNodes
pip install -r requirements.txt

Restart ComfyUI. No model or extra downloads needed - this is a pure tensor-comparison utility that works on any two matching-shape latents, LTXV-produced or otherwise.

How to actually use it

Wire it in between two branches of a comparison test - say, the same seed and prompt sampled with enable_role_embedding on versus off - rather than leaving it in a production graph permanently; it's a debugging tool, and print_console spamming your log on every run gets old fast once you've answered the question you were asking. If latent_a and latent_b come from different resolutions or frame counts, expect a shape mismatch error rather than a meaningful comparison - match your latent dimensions before wiring this in, the same caveat as its image-space counterpart.

CategoryLTXV/EditAnything

Inputs (5)

NameTypeDefaultDescription
latent_aLATENT
latent_bLATENT
labeloptSTRINGA vs B
print_consoleoptBOOLEANtrue
compare_noise_maskoptBOOLEANfalseIf True, also reports diff stats restricted to the noisy region of latent_a (where noise_mask > 0).

Outputs (6)

NameTypeDescription
metricsSTRING
latent_aLATENT
mseFLOAT
psnrFLOAT
l1FLOAT
cosineFLOAT