Qwen Rectified Flow Inverter
Flow-Model Editing Without the Random-Noise Lottery
- model
- latent_image
- positive
- LATENT
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_amplificationmultiplies every predicted velocity by(1 + amp)- positive pushes harder into noise, negative damps it.velocity_perturb_strengthadds 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 aVAE Encodenode.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 thedenoiseyou want downstream.steps(default 20) - the integration budget; effective steps areint(steps × inversion_strength).velocity_perturb_strength(default 0) - leave at 0 for faithful re-noising; raise it when you want variety.internal_precision-bfloat16by default;force_float32is the "make it stable" switch.normalize_output- keep itenable. 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 Nin the console - that's the pack's own error message. Bumpinternal_precisiontoforce_float32and dial backvelocity_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.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | UNet to integrate during the rectified flow inversion. | |
| latent_image | LATENT | Latent to be inverted toward the clean state. | |
| positive | CONDITIONING | Positive prompt conditioning applied during inversion. | |
| seed | INT | 00–18446744073709550000 | Seed for the random velocity perturbation. |
| steps | INT | 201–1000 | Number of integration steps available for the inverter. |
| inversion_strength | FLOAT | 0.500–1 | Fraction of the schedule to walk backward during inversion. |
| velocity_amplification | FLOAT | 0.00-0.9–2 | Deterministically amplifies (>0) or dampens (<0) the predicted velocity at each step. |
| velocity_perturb_strength | FLOAT | 0.000–5 | Adds seeded random noise to the velocity. >1.0 will heavily randomize the path. |
| internal_precision | COMBO | bfloat16 | Autocast precision used while running the inverter UNet. |
| normalize_output | COMBO | enable | Crucial for high inversion strengths. Rescales the output latent to a standard distribution (mean=0, std=1) to prevent the sampler from collapsing. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |