Nodes/ComfyUI Qwen Rectified Flow Tools/Qwen Rectified Flow Inverter
ComfyUI Node

Qwen Rectified Flow Inverter

Flow-Model Editing Without the Random-Noise Lottery

By ttulttul·Created 12 months ago·Updated 9 months ago· 7
Qwen Rectified Flow Inverter
  • model
  • latent_image
  • positive
  • LATENT
seed0
steps20
inversion_strength0.50
velocity_amplification0.00
velocity_perturb_strength0.00
internal_precisionbfloat16
normalize_outputenable

The name says "inverter," and that's the trap - people read it as DDIM inversion, the thing that walks a generated image back to its own noise so you can edit and regenerate it. This node doesn't do that. It walks the other way. Give it a clean, VAE-encoded latent and it runs the rectified-flow integration forward along the schedule, stopping partway, so your image arrives at the target noise level the model's way - with model-consistent noise instead of the random Gaussian you'd normally slam on top for img2img. It's the difference between saying "here's noise" and "here's the noise this image would have had."

Why that distinction matters: Qwen-Image, Flux, Wan, HunyuanVideo - everything modern is flow-matching. Flow models predict a velocity along a near-straight line from noise to image, which is why they only need a handful of steps and why Karras schedules quietly stopped working. And it means the old img2img recipe (random noise + denoise) leaves structure on the table. Random Gaussian at the right sigma is what a sampler technically expects, but it knows nothing about your image. Let the model walk your latent along its own velocity field and the noise lands correlated with your content - more faithful edits, less washed-out rebuilds. That's the whole pitch of this pack, and QwenRectifiedFlowInverter is the base node.

How it works

Under the hood it reaches into model.model.diffusion_model, loads it to the GPU, and Euler-integrates x += v·dt from t=0 up to inversion_strength, pulling the prompt embedding from positive[0][0] as context. Two knobs bend that path:

  • velocity_amplification multiplies every predicted velocity by (1 + amp) - positive pushes harder into noise, negative damps it.
  • velocity_perturb_strength adds seeded noise to the velocity, scaled by the velocity's own standard deviation. Above 1.0 the path is heavily randomized and results turn "creative."

Everything runs under torch.no_grad() with autocast precision, there's a progress bar, and it auto-handles 4D vs 5D (video) latents by unsqueezing the shape.

The inputs that matter

Most of the list you'll leave alone. These are the ones a beginner actually sets:

  • latent_image - your VAE-encoded image, typically straight out of a VAE Encode node.
  • inversion_strength (0–1, default 0.5) - how far up the schedule to walk. 0 is a no-op passthrough. Whatever you set here is the denoise you want downstream.
  • steps (default 20) - the integration budget; effective steps are int(steps × inversion_strength).
  • velocity_perturb_strength (default 0) - leave at 0 for faithful re-noising; raise it when you want variety.
  • internal_precision - bfloat16 by default; force_float32 is the "make it stable" switch.
  • normalize_output - keep it enable. It rescales each latent to mean 0 / std 1 so the sampler doesn't collapse at high strengths, which the author is blunt about calling crucial.

The output is a single LATENT. Wire it into a sampler with denoise ≈ inversion_strength and that's the whole workflow.

Install

Nothing special - this is one of the friendlier packs in that regard. ComfyUI Manager → Custom Nodes Manager → search "Qwen Rectified Flow Tools" (or "FlowMatching-Inverter"), hit install, restart. Or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/ttulttul/ComfyUI-FlowMatching-Inverter
# then restart ComfyUI

No model downloads, no extra Python dependencies - requirements.txt only lists pytest and torch for the test suite; everything else comes from ComfyUI itself. You're feeding it the flow checkpoint you already run. The author, ttulttul (who also makes the ComfyUI-Iterative-Mixer sampler pack), suggests pairing this with Skoogeer-Noise for forward-diffusion and conditioning helper nodes, but the inverter works standalone.

Where people get burned

  • NaN detected at step N in the console - that's the pack's own error message. Bump internal_precision to force_float32 and dial back velocity_amplification / velocity_perturb_strength. The README says it in exactly those words.
  • Feeding it an SDXL or SD 1.5 checkpoint. Those are epsilon-prediction models, not flow models; the rectified-flow integration is meaningless to them. This pack targets flow checkpoints: Qwen-Image, Flux, Wan, HunyuanVideo.
  • Mismatching the denoise. Walk to 0.5 but sample with denoise 1.0 and you're double-noising - the result is mush. The strength you invert to is the denoise you sample with.
  • Expecting exact reconstruction. This is re-noising, not invert-the-generator. Structure survives, but you're getting a fresh generation seeded by your image, not a copy of it.
CategoryQwen/Sampling

Inputs (10)

NameTypeDefaultDescription
modelMODELUNet to integrate during the rectified flow inversion.
latent_imageLATENTLatent to be inverted toward the clean state.
positiveCONDITIONINGPositive prompt conditioning applied during inversion.
seedINT00–18446744073709550000Seed for the random velocity perturbation.
stepsINT201–1000Number of integration steps available for the inverter.
inversion_strengthFLOAT0.500–1Fraction of the schedule to walk backward during inversion.
velocity_amplificationFLOAT0.00-0.9–2Deterministically amplifies (>0) or dampens (<0) the predicted velocity at each step.
velocity_perturb_strengthFLOAT0.000–5Adds seeded random noise to the velocity. >1.0 will heavily randomize the path.
internal_precisionCOMBObfloat16Autocast precision used while running the inverter UNet.
normalize_outputCOMBOenableCrucial for high inversion strengths. Rescales the output latent to a standard distribution (mean=0, std=1) to prevent the sampler from collapsing.

Outputs (1)

NameTypeDescription
LATENTLATENT