Skip to page content
SAVRN
Search Plan a project

Open-weight model · Text to image

Rectified-CFGpp

by Shreshth shreshthsaini/Rectified-CFGpp

Rectified-CFGpp is an open-weight model for text to image from Shreshth, released under MIT License. Its published files total 233.1 KB.

Diffusers pipelines for Rectified-CFG++, a training-free guidance method for rectified-flow models (NeurIPS 2025). This repo has no weights. It holds pipeline code that you load on top of an existing checkpoint with custompipeline.

Parameters—
Context—
Weights233.1 KB
Licensemit
AccessOpen weights
Monthly Downloads—

Model Card

By Shreshth, published under mit, revision 4ed3d82861be.

Diffusers pipelines for Rectified-CFG++, a training-free guidance method for rectified-flow models (NeurIPS 2025). This repo has no weights. It holds pipeline code that you load on top of an existing checkpoint with custompipeline. Classifier-free guidance (CFG) extrapolates from the unconditional velocity toward the conditional one at every ODE step. On rectified-flow models this extrapolation pushes samples off the learned data manifold, and at high guidance scales the images show over-saturated colours and broken structure. Rectified-CFG++ replaces that extrapolation with a predictor-corrector update: 1. Predictor: take a step along the conditional velocity from the current point. 2.…

Read Shreshth's full model card

Rectified-CFG++ for Flow Based Models

Diffusers pipelines for Rectified-CFG++, a training-free guidance method for rectified-flow models (NeurIPS 2025).

  • Paper: https://arxiv.org/abs/2510.07631
  • Code: https://github.com/shreshthsaini/Rectified-CFGpp
  • Project page: https://shreshthsaini.github.io/Rectified-CFGpp/
  • Authors: Shreshth Saini, Shashank Gupta, Alan C. Bovik (The University of Texas at Austin)

This repo has no weights. It holds pipeline code that you load on top of an existing checkpoint with custom_pipeline.

What the method does

Classifier-free guidance (CFG) extrapolates from the unconditional velocity toward the conditional one at every ODE step. On rectified-flow models this extrapolation pushes samples off the learned data manifold, and at high guidance scales the images show over-saturated colours and broken structure.

Rectified-CFG++ replaces that extrapolation with a predictor-corrector update:

  1. Predictor: take a step along the conditional velocity from the current point.
  2. Corrector: evaluate the conditional and unconditional velocities at the predicted point, and add their scaled difference to the conditional velocity at the current point.

The update stays close to the conditional flow, so prompt alignment holds at high guidance scales without those artifacts. No training or fine-tuning is involved, and the method applies to any rectified-flow backbone.

Each step costs three model evaluations (one conditional pass at the current point, then one conditional and one unconditional pass at the predicted point), against two for standard CFG.

Files

Backbone File Pipeline class Guidance argument
Stable Diffusion 3 / 3.5 pipeline.py StableDiffusion3RectifiedCFGPlusPlusPipeline guidance_scale (default 4.5)
Flux (FLUX.1-dev, FLUX.1-schnell) pipeline_flux_rectified_cfgpp.py FluxRectifiedCFGPlusPlusPipeline true_cfg_scale with a negative_prompt (an empty string works). guidance_scale stays the distilled guidance embedding.
Lumina-Image-2.0 pipeline_lumina2_rectified_cfgpp.py Lumina2RectifiedCFGPlusPlusPipeline guidance_scale (default 4.0)
Qwen-Image pipeline_qwenimage_rectified_cfgpp.py QwenImageRectifiedCFGPlusPlusPipeline true_cfg_scale (default 4.0) with a negative_prompt
Wan 2.1 / 2.2 (video) pipeline_wan_rectified_cfgpp.py WanRectifiedCFGPlusPlusPipeline guidance_scale (default 5.0), and guidance_scale_2 for Wan 2.2 two-stage checkpoints

Every pipeline keeps the arguments of its upstream diffusers counterpart and adds one: sigma_noise (default 0.005), the standard deviation of the Gaussian noise added to the predicted point before the corrector evaluation. Set it to 0 to turn the noise off. With guidance off (guidance_scale <= 1, or true_cfg_scale <= 1 for Flux and Qwen-Image) the pipelines run plain conditional sampling.

Usage

Install the dependencies:

pip install -U diffusers transformers accelerate sentencepiece protobuf

diffusers runs the pipeline file as Python code, so recent versions require trust_remote_code=True. Read the file first if you want to see what it does.

Stable Diffusion 3.5

pipeline.py at the root of this repo is the SD3 / SD3.5 pipeline, so the repo id is enough:

import torch
from diffusers import DiffusionPipeline

pipe = DiffusionPipeline.from_pretrained(
    "stabilityai/stable-diffusion-3.5-large",
    custom_pipeline="shreshthsaini/Rectified-CFGpp",
    trust_remote_code=True,
    torch_dtype=torch.bfloat16,
).to("cuda")

image = pipe(
    "A magical forest at twilight with glowing fireflies",
    negative_prompt="",
    guidance_scale=4.5,
    num_inference_steps=28,
    sigma_noise=0.005,
    height=1024,
    width=1024,
    generator=torch.Generator("cuda").manual_seed(42),
).images[0]
image.save("rectified_cfgpp_sd35.png")

Flux, Lumina 2, Qwen-Image, Wan

custom_pipeline with a repo id only reads pipeline.py. For the other backbones, download the file and pass its local path:

import torch
from diffusers import DiffusionPipeline
from huggingface_hub import hf_hub_download

path = hf_hub_download("shreshthsaini/Rectified-CFGpp", "pipeline_flux_rectified_cfgpp.py")

pipe = DiffusionPipeline.from_pretrained(
    "black-forest-labs/FLUX.1-dev",
    custom_pipeline=path,
    trust_remote_code=True,
    torch_dtype=torch.bfloat16,
).to("cuda")

image = pipe(
    "A red fox standing on a mossy log in a misty pine forest, morning light, photograph",
    negative_prompt="",
    true_cfg_scale=4.5,
    guidance_scale=3.5,
    num_inference_steps=28,
).images[0]
image.save("rectified_cfgpp_flux.png")

Swap the file name and the base checkpoint for the other backbones:

File Example checkpoint Example call arguments
pipeline_lumina2_rectified_cfgpp.py Alpha-VLLM/Lumina-Image-2.0 guidance_scale=4.0, num_inference_steps=50
pipeline_qwenimage_rectified_cfgpp.py Qwen/Qwen-Image negative_prompt=" ", true_cfg_scale=4.0, num_inference_steps=50
pipeline_wan_rectified_cfgpp.py Wan-AI/Wan2.1-T2V-1.3B-Diffusers negative_prompt="blurry, low quality", height=480, width=832, num_frames=81, guidance_scale=5.0, num_inference_steps=50

The predictor takes a flow-matching Euler step, so the pipelines expect FlowMatchEulerDiscreteScheduler. Wan checkpoints ship with a multistep scheduler. Replace it after loading:

from diffusers import FlowMatchEulerDiscreteScheduler

pipe.scheduler = FlowMatchEulerDiscreteScheduler.from_config(pipe.scheduler.config, shift=5.0)

The Wan pipeline returns video frames in .frames[0]. Save them with diffusers.utils.export_to_video(frames, "out.mp4", fps=16).

Check the setup on CPU

This runs in a few seconds without a GPU. It uses a tiny random checkpoint, so the image is noise. It only confirms that the pipeline loads and samples.

import torch
from diffusers import DiffusionPipeline

pipe = DiffusionPipeline.from_pretrained(
    "hf-internal-testing/tiny-sd35-pipe",
    custom_pipeline="shreshthsaini/Rectified-CFGpp",
    trust_remote_code=True,
)
image = pipe(
    "a photo of a cat",
    guidance_scale=4.5,
    num_inference_steps=2,
    height=64,
    width=64,
    generator=torch.Generator().manual_seed(0),
).images[0]
print(type(pipe).__name__, image.size)
# StableDiffusion3RectifiedCFGPlusPlusPipeline (64, 64)

Recommended settings

The official demo script uses these values with stabilityai/stable-diffusion-3.5-large:

Setting Value
Guidance scale 4.5
Inference steps 28
sigma_noise 0.005
Resolution 1024 x 1024
dtype torch.bfloat16

The reference implementation on GitHub names the guidance argument true_cfg. The SD3 pipeline here uses the standard diffusers name, guidance_scale, for the same quantity.

What was tested

Loading and sampling were tested on CPU with diffusers 0.41.0, torch 2.14.1 and transformers 5.19.0, two inference steps per run, against these tiny random checkpoints:

Pipeline Checkpoint Load path
SD3 hf-internal-testing/tiny-sd3-pipe repo id
SD3.5 hf-internal-testing/tiny-sd35-pipe repo id
Flux hf-internal-testing/tiny-flux-pipe hf_hub_download + local path
Lumina 2 hf-internal-testing/tiny-lumina2-pipe hf_hub_download + local path
Qwen-Image hf-internal-testing/tiny-qwenimage-pipe hf_hub_download + local path
Wan hf-internal-testing/tiny-wan-pipe hf_hub_download + local path

These runs check that the code loads, runs, returns finite outputs and responds to the guidance scale. They say nothing about image quality. The full-size examples above follow the same load paths but were not run as part of this check. For the experiments in the paper, use the GitHub repo.

Related

The same pipelines are proposed for the diffusers community folder in huggingface/diffusers#14726. That pull request was open, not merged, as of October 2026.

Citation

@inproceedings{saini2025rectifiedcfgpp,
  title     = {Rectified-CFG++ for Flow Based Models},
  author    = {Shreshth Saini and Shashank Gupta and Alan C. Bovik},
  booktitle = {Advances in Neural Information Processing Systems},
  year      = {2025}
}

License

MIT, see LICENSE. The pipeline files are adapted from diffusers and keep its Apache-2.0 file headers.

Identity and Version

Repository
shreshthsaini/Rectified-CFGpp
Publisher
Shreshth
Task
Text to image
Modality
Image
Library
diffusers
Parameters
Not stated by the source
Languages
wan
Revision
4ed3d82861be9fe951238397c75e2421292b2620
First published
2026-10-13
Last updated
2026-10-13

Files and Weights

8 files, 233.1 KB in total.

Configuration5 files · 221.3 KB
Documentation2 files · 10.2 KB
Repository1 file · 1.5 KB
Every file
FileTypeSizeSHA-256
pipeline.pyConfiguration60.7 KB —
pipeline_flux_rectified_cfgpp.pyConfiguration49.8 KB —
pipeline_lumina2_rectified_cfgpp.pyConfiguration38.9 KB —
pipeline_qwenimage_rectified_cfgpp.pyConfiguration38.0 KB —
pipeline_wan_rectified_cfgpp.pyConfiguration34.0 KB —
LICENSEDocumentation1.1 KB —
README.mdDocumentation9.1 KB —
.gitattributesRepository1.5 KB —

License and Download

License
mit
Access
Open weights, no gate
Download from Shreshth

Released by Shreshth through its official repository on Hugging Face. Read the license.

Built From

  • Described by arXiv:2510.07631

Questions About Rectified-CFGpp

Can I use Rectified-CFGpp commercially?

Yes. Rectified-CFGpp is released under MIT License. The MIT License is a short permissive license. It permits commercial use, modification and redistribution, provided the copyright notice and permission notice are included.

Similar Models

GGUF, Safetensors, and MLX quantized formats of Qwen/Qwen-Image-2.1 for local image generation using the original upstream base weights. Q4KM is recommended for the best balance of size and quality for GGUF. INT8 ConvRot and NVFP4 offer high performance on supported GPUs, while MLX formats are optimized for Apple Silicon. Companion model files packaged for ComfyUI: Use the model with ComfyUI and ComfyUI-GGUF. All required companion files (GGUF transformer, text encoder, and VAE) are hosted directly in this repository. Download the files and place them in their respective ComfyUI directories: 1. Install ComfyUI-GGUF: Use the maintained fork with native Qwen-Image 2.1 support by cloning…

Open weights other gguf

GGUF quantizations of Qwen/Qwen-Image-2.1 for local image generation using the original upstream base weights. Q4KM is recommended for the best balance of size and quality. Companion model files packaged for ComfyUI: Use the model with ComfyUI and ComfyUI-GGUF. All required companion files (GGUF transformer, text encoder, and VAE) are hosted directly in this repository. Download the files and place them in their respective ComfyUI directories: 1. Install ComfyUI-GGUF: Use the maintained fork with native Qwen-Image 2.1 support by cloning leejet/ComfyUI-GGUF into your custom nodes: (Note: If you have the older city96/ComfyUI-GGUF installed and encounter an Unknown model architecture! error…

Open weights other gguf

Model · Text to image

Qwen-Image-2.1-GGUF

Unsloth AI

This is a GGUF quantized version of Qwen-Image-2.1. unsloth/Qwen-Image-2.1-GGUF uses Unsloth Dynamic 2.0 methodology for SOTA performance. - Important layers are upcasted to higher precision, per tensor, from a measured sensitivity scan. - Run these with Unsloth Desktop, stable-diffusion.cpp and more. A GGUF is the denoiser only, so it needs the VAE and the Qwen3-VL text encoder alongside it. See below for image editing operating inside of Unsloth Desktop: Rendered with the Q4KM denoiser and the Q4KM text encoder, 1024x1024, 20 steps, cfg 6.0, euler. We are excited to open-source Qwen-Image-2.1, a unified text-to-image generation and image editing model in the Qwen family. With just 7B…

Open weights other

Model · Text to image

Z-Image-Turbo-GGUF

Unsloth AI

Welcome to the official repository for the Z-Image(造相)project! Z-Image is a powerful and highly efficient image generation model with 6B parameters. Currently there are three variants: - Z-Image-Turbo – A distilled version of Z-Image that matches or exceeds leading competitors with only 8 NFEs (Number of Function Evaluations). It offers sub-second inference latency on enterprise-grade H800 GPUs and fits comfortably within 16G VRAM consumer devices. It excels in photorealistic image generation, bilingual text rendering (English & Chinese), and robust instruction adherence. - Z-Image-Base – The non-distilled foundation model. By releasing this checkpoint, we aim to unlock the full potential…

Open weights apache-2.0 ggml

Model · Text to image

Juggernaut-XL-v9

RunDiffusion

The SDXL ecosystem is the single most mature corner of open image generation, and v9 is its most refined photorealism checkpoint. Choose Juggernaut XL v9 when you want: - Photorealism that holds up under scrutiny — skin texture, micro-contrast, and natural lighting that translates from concept to print. - Reasonable hardware — runs comfortably on 8 GB of VRAM, unlike newer DiT-based models that demand 16+ GB. - The full SDXL toolbox — drop-in compatibility with the thousands of SDXL ControlNets, IP-Adapter variants, AnimateDiff, regional prompting tools, and LoRAs already in your workflow. - Battle-tested reliability — 26+ months in production, used in agencies, studios, and shipping…

Open weights creativeml-openrail-m diffusers

Model · Text to image

Qwen-Image-Lightning

Lightx2v

Please refer to Qwen-Image-Lightning github to learn how to use the models. make sure to install diffusers from main (pip install git+https://github.com/huggingface/diffusers.git)

Open weights apache-2.0 diffusers