ComfyUI Node

RF Inversion

The boring node that makes training-free style transfer work at all

By BigStationW·Created 3 months ago·Updated 2 months ago· 133
RF Inversion
  • model
  • reference_latent
  • ref_conditioning
  • model
  • rf_inversion
rf_moderf_gamma
gamma0.50
pmi_alpha0.00
otip_strength0.35
otip_clip_norm20.00
verbosefalse

This is the half of Untwisting RoPE that looks like nothing's happening - and the one that's doing the hard math. RF Inversion builds the noisy trajectory of your reference image so that at every denoising step the patched model can see a noise-matched version of the reference, not a clean one. Try feeding Untwisting RoPE a plain latent and you'll get mush: at high noise levels, a clean reference image is information the model was never trained to mix with. The inversion fixes that by walking the reference backward along the same ODE path the sampler will walk forward.

Think of the pack as a handshake. RF Inversion is the left hand: it prepares the reference data. Untwisting RoPE is the right: it patches the attention and RoPE modules to actually use it. This node's job ends the moment you wire its outputs.

How it works

It's a rectified-flow inversion. The node solves an ODE from the clean reference latent toward noise, using a solver you pick. That's the rf_mode dropdown, and it gives you seven choices: linear (no model calls - effectively random noise), rf_gamma (Euler), rf_gamma_rk2 (Runge–Kutta midpoint), rf_solver_2 (RF-Solver / RF-Edit), endpoint_heun, fireflow, and flowturbo_pc. Then three dials tune the path. gamma (default 0.5) blends between pure model velocity and a straight prior path. pmi_alpha adds Proximal-Mean Inversion - a running mean over steps that smooths velocity estimation - off at 0. And otip_strength (default 0.35, so on out of the box) nudges the trajectory toward a better transport direction for editing; otip_clip_norm caps how far that correction can push.

The neat engineering bit: all of this gets stuffed into a normal LATENT. The node's description spells it out - "Stores RF inversion settings/reference data in a normal LATENT and captures the sampler sigma schedule internally. No SIGMAS input is required." You don't build a separate sigma schedule or pass it around; the sampler's schedule is grabbed at runtime.

Inputs and outputs

The ones you actually set:

  • reference_latent - your reference image VAE-encoded. Must match the target resolution, or Untwisting RoPE throws a spatial mismatch error.
  • ref_conditioning - counterintuitively, the docs recommend putting your target text conditioning here. The reference conditioning gets merged with the target later; it just works better that way.
  • rf_mode - the solver. Default is rf_gamma; if your reference is very detailed, rf_solver_2 or fireflow buy a more faithful path at some speed cost.
  • gamma, pmi_alpha, otip_strength, otip_clip_norm - the path-tuning dials above. Leave them alone until you know what you're changing.
  • verbose - turns on logging so you can see the trajectory being built. Great for diagnosing.

Two outputs: model (a pass-through you feed to Untwisting RoPE) and rf_inversion (the LATENT you feed to its rf_inversion input). Both go to the same place, effectively.

Installing

Same pack as the patcher: ComfyUI Manager → search "ComfyUi-Untwisting-RoPE", or git clone https://github.com/BigStationW/ComfyUi-Untwisting-RoPE into ComfyUI/custom_nodes and restart. No requirements, no model downloads - this node is pure Python on top of ComfyUI's own machinery.

Gotchas

The classic failure is resolution: encode the reference at a different size than your output and the whole chain dies with a shape error. Rescale first. And remember the settings travel inside the LATENT object - if you reroute, crop, or batch-modify that latent before it hits Untwisting RoPE, you're silently dropping the inversion data. Keep the wire direct, and if a workflow gives you nonsense, check whether your sampler and the node's internal schedule are actually in sync.

Categorymodel_patches/Untwisting RoPE

Inputs (9)

NameTypeDefaultDescription
modelMODEL
reference_latentLATENT
ref_conditioningCONDITIONING
rf_modeCOMBOrf_gammaSelects the ODE solver used to build the noisy reference trajectory. Set otip_strength > 0 to add OTIP transport guidance to the selected solver.
gammaFLOAT0.500–1Blends weight between model velocity and prior velocity (0 = pure prior / straight path, 1 = pure model).
pmi_alphaFLOAT0.000–1Proximal-Mean Inversion: 0 disables PMI, 1.0 matches the official radius. Applies to RF gamma, RK2, and FireFlow.
otip_strengthFLOAT0.350–1Optimal Transport for Rectified Flow Image Editing. 0 disables it.
otip_clip_normFLOAT20.000–100OTIP Clipping threshold for the closed-form Wasserstein-2 transport direction.
verboseBOOLEANfalseEnable verbose logging.

Outputs (2)

NameTypeDescription
modelMODEL
rf_inversionLATENT