Nodes/comfyui-lrw-nodes/Pullback Metric (LRW)
ComfyUI Node

Pullback Metric (LRW)

Where LRW's real geometry actually comes from

By lajjadred·Created 3 months ago·Updated 3 months ago· 12
Pullback Metric (LRW)
  • latent
  • vae
  • metric
  • latent
regularization0.0000

Every geodesic, every transported vector, every "curvature" in this pack is only as real as the METRIC feeding it. Pullback Metric is the node that builds that metric from your VAE's decoder. It's the mathematical heart of the whole image-model side of comfyui-lrw-nodes - and, honestly, it's also the part you're most likely to stub your toe on.

What it's actually computing

The name sounds like a wall of math, but the picture is simple. Your VAE compresses an image into a latent point, and the decoder maps that point back to pixels. The pullback metric G(z) = JᵀJ is just a way of asking: "if I nudge this latent in any direction, how much do the decoded pixels change?" The answer is a matrix at every latent point, and that matrix is the notion of distance and curvature LRW uses everywhere else.

The node takes your latent, flattens it, and wraps vae.decode in a PullbackMetric object with a regularization term (default 1e-5) that keeps the geometry invertible. It returns the metric plus your latent passed through untouched, so you can keep the graph linear.

Inputs and outputs

  • latent - a latent from VAEEncode. The metric is anchored to this latent's shape, so this isn't optional; LRW needs to know the dimensionality it's operating in.
  • vae - the model's VAE.
  • regularization - leave at 1e-5 unless a downstream solver is unstable; nudge it up a bit then.

Outputs are metric (a METRIC, feed it to the geodesic/transport/trajectory/curvature nodes) and latent (passthrough).

Wait - isn't this the same as the VAE Decoder Bridge?

Functionally, yes. LRW_VAEDecoderBridge in lrw/core and this node in lrw/metric both build a PullbackMetric from a VAE and both pass your latent through. The bridge flattens the decoded output to a flat vector before handing it to LRW; this one returns the raw decode. For practical purposes you grab whichever your workflow template uses and never think about it again. If anything, Pullback Metric is the "proper" one and the bridge is the convenience wrapper that sits nicely after CheckpointLoader.

The catch you need to plan around

This is the expensive, finicky path. The metric lives in a space with D = C×H×W dimensions, and computing it involves the decoder Jacobian. On SD/SDXL-class latents it's workable; on anything bigger it's slow and VRAM-hungry. That's the whole reason the pack's lrw/wan branch exists: WAN's VAE decoder isn't vmap-safe, so those nodes deliberately skip the pullback metric entirely and use a cheap spherical approximation instead. If you're here to make WAN video, this is the wrong node - go read LRW_WanTemporalMetric. If you're here to play with real Riemannian geometry on image models, this is the right foundation.

Install & gotchas

Search comfyui-lrw-nodes in ComfyUI Manager, or git clone https://github.com/lajjadred/comfyui-lrw-nodes into ComfyUI/custom_nodes, pip install -r requirements.txt, restart. The dependency that actually matters is latent-riemannian-world >= 0.3.0 - the author's own package, without which the import fails at load. Early versions of the pack had a registration bug that showed nodes as broken/UNKNOWN until the author pushed a fix; if you hit that, git pull and a full restart clear it, and make sure you don't have two copies of the pack installed. The pack is BSL-1.1 licensed, which is source-available, not classic open source.

Categorylrw/metric

Inputs (3)

NameTypeDefaultDescription
latentLATENT
vaeVAE
regularizationFLOAT0.00000–1

Outputs (2)

NameTypeDescription
metricMETRIC
latentLATENT