Skip to content

fix(flux): tighten check_inputs validation#13955

Open
akshan-main wants to merge 1 commit into
huggingface:mainfrom
akshan-main:fix-flux-validation
Open

fix(flux): tighten check_inputs validation#13955
akshan-main wants to merge 1 commit into
huggingface:mainfrom
akshan-main:fix-flux-validation

Conversation

@akshan-main

@akshan-main akshan-main commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Addresses part of the flux review (#13584) - three input-validation gaps in the flux pipelines:

  • Issue 3: FluxPipeline / FluxKontextPipeline accepted negative_prompt_embeds with a different shape than prompt_embeds. Added the shape check the img2img/inpaint variants already have (propagated to kontext via # Copied from).
  • Issue 4: FluxControlNetImg2ImgPipeline checked height % self.vae_scale_factor * 2, which parses as (height % vae_scale_factor) * 2, so invalid sizes like 72 passed. Added the parentheses to match every other flux pipeline.
  • Issue 5: FluxPriorReduxPipeline only validated scale length for list images and ignored pooled_prompt_embeds_scale. Now computes the image batch size for tensors too and validates both scales.

Verified each finding's repro now raises/flags, and that matching/valid inputs still pass.

Before submitting

Who can review?

@hlky @sayakpaul @yiyixuxu

@github-actions github-actions Bot added size/S PR with diff < 50 LOC pipelines labels Jun 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi @akshan-main, thanks for the PR! It does not appear to link an issue it fixes. If this PR addresses an existing issue, please add a closing keyword (e.g. Fixes #1234) to the PR description so the issue is linked. See the contribution guide for more details. If this PR intentionally does not fix a tracked issue, a maintainer can add the no-issue-needed label to silence this reminder.

@sayakpaul sayakpaul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Left some comments.

raise ValueError(f"The value of strength should in [0.0, 1.0] but is {strength}")

if height % self.vae_scale_factor * 2 != 0 or width % self.vae_scale_factor * 2 != 0:
if height % (self.vae_scale_factor * 2) != 0 or width % (self.vae_scale_factor * 2) != 0:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What value is this adding though?

Comment on lines +494 to +501
if prompt_embeds is not None and negative_prompt_embeds is not None:
if prompt_embeds.shape != negative_prompt_embeds.shape:
raise ValueError(
"`prompt_embeds` and `negative_prompt_embeds` must have the same shape when passed directly, but"
f" got: `prompt_embeds` {prompt_embeds.shape} != `negative_prompt_embeds`"
f" {negative_prompt_embeds.shape}."
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this should also be checked when do_true_cfg is True? Otherwise, it's not used right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pipelines size/S PR with diff < 50 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants