Skip to content

[Bugfix] Fix Flux2 Dev Guidance#2433

Merged
SamitHuang merged 2 commits intovllm-project:mainfrom
alex-jw-brooks:flux2_guidance
Apr 3, 2026
Merged

[Bugfix] Fix Flux2 Dev Guidance#2433
SamitHuang merged 2 commits intovllm-project:mainfrom
alex-jw-brooks:flux2_guidance

Conversation

@alex-jw-brooks
Copy link
Copy Markdown
Contributor

Purpose

Flux2 dev is currently not passing guidance through correctly; regardless of the sampling params, the guidance tensor passed to the transformer is hardcoded to None.

This PR creates the guidance tensor and passes it through to the timestep guidance embeddings (original pipeline for reference here).

Test Result

To validate, you can run an example like this:

from vllm_omni.inputs.data import OmniDiffusionSamplingParams
from vllm_omni.entrypoints.omni import Omni

MODEL = "black-forest-labs/FLUX.2-dev"

PROMPT = "A white cat sitting on a black table near a windows with visible sunlight."
SEED = 42
NUM_STEPS = 4

def generate_with_guidance(omni: Omni, guidance_scale: float, output_path: str):
    """Generate image with specific guidance_scale using existing Omni instance."""
    outputs = omni.generate(
        prompts=PROMPT,
        sampling_params_list=OmniDiffusionSamplingParams(
            seed=SEED,
            height=1024,
            width=1024,
            num_inference_steps=NUM_STEPS,
            guidance_scale=guidance_scale
        )
    )

    image = outputs[0].request_output.images[0]
    image.save(output_path)
    return image


if __name__ == "__main__":
    omni = Omni(
        model=MODEL,
        dtype="bfloat16",
        enable_cpu_offload=True,
    )

    img_low = generate_with_guidance(omni, 1.0, "guidance_1.0.png")
    img_mid = generate_with_guidance(omni, 4.0, "guidance_4.0.png")

In the current code, the result will be the same for both since the guidance isn't used, but we should see a poor result for guidance 1.0 and a pretty good one for 4.0.

Signed-off-by: Alex Brooks <albrooks@redhat.com>
Copy link
Copy Markdown
Collaborator

@lishunyang12 lishunyang12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, one nit.

Comment thread vllm_omni/diffusion/models/flux2/pipeline_flux2.py Outdated
Signed-off-by: Alex Brooks <albrooks@redhat.com>
@gcanlin gcanlin added the ready label to trigger buildkite CI label Apr 3, 2026
@gcanlin
Copy link
Copy Markdown
Collaborator

gcanlin commented Apr 3, 2026

Could you please paste the generated image before and after this PR?

Copy link
Copy Markdown
Collaborator

@SamitHuang SamitHuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SamitHuang SamitHuang merged commit 10db95f into vllm-project:main Apr 3, 2026
8 checks passed
@alex-jw-brooks
Copy link
Copy Markdown
Contributor Author

alex-jw-brooks commented Apr 3, 2026

@gcanlin sure, with the example code, no matter what value you pass for guidance, you'll always get the same image since it's unused.
guidance_4 0_bug_case

With the fix, we should see the guidance affect the result, so giving something like guidance 1.0 should be much worse than guidance 4.0 for example, which is closer to what is recommended for this model.
guidance_1 0 guidance_4 0
(left is guidance 1.0, right is 4.0, with otherwise identical configurations)

linyueqian pushed a commit to JuanPZuluaga/vllm-omni that referenced this pull request Apr 3, 2026
Signed-off-by: Alex Brooks <albrooks@redhat.com>
Signed-off-by: JuanPZuluaga <juanz9312@gmal.com>
skf-1999 pushed a commit to Semmer2/vllm-omni that referenced this pull request Apr 7, 2026
Signed-off-by: Alex Brooks <albrooks@redhat.com>
vraiti pushed a commit to vraiti/vllm-omni that referenced this pull request Apr 9, 2026
Signed-off-by: Alex Brooks <albrooks@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready label to trigger buildkite CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants