Skip to content

fix(flux2): apply BN normalization to latents for inpainting#8868

Merged
lstein merged 2 commits intoinvoke-ai:mainfrom
Pfannkuchensack:fix/flux2-inpainting-bn-normalization
Feb 20, 2026
Merged

fix(flux2): apply BN normalization to latents for inpainting#8868
lstein merged 2 commits intoinvoke-ai:mainfrom
Pfannkuchensack:fix/flux2-inpainting-bn-normalization

Conversation

@Pfannkuchensack
Copy link
Copy Markdown
Collaborator

Summary

The FLUX.2 Klein transformer operates in BN-normalized latent space, but init_latents from VAE encode were not being normalized before being passed to the InpaintExtension. This caused a scale mismatch when merging intermediate_latents (normalized) with noised_init_latents (unnormalized), resulting in visible artifacts at mask blur boundaries.

Now normalize:

  • init_latents_packed before passing to InpaintExtension
  • noise_packed for correct interpolation in normalized space
  • x (starting latents) for img2img/inpainting workflows

Related Issues / Discussions

Reported issue: Strange artifacts appearing on mask blur regions when using FLUX.2 Klein for inpainting, particularly visible when regenerating over the same region multiple times.

QA Instructions

  1. Load a FLUX.2 Klein model
  2. Create an inpainting workflow with mask blur enabled
  3. Generate multiple times over the same masked region
  4. Verify that the artifacts/seams at the mask boundary are no longer visible

Merge Plan

Standard merge, no special considerations needed.

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • Changes to a redux slice have a corresponding migration
  • Documentation added / updated (if applicable)
  • Updated What's New copy (if doing a release after this PR)

The FLUX.2 Klein transformer operates in BN-normalized latent space,
but init_latents from VAE encode were not being normalized before
being passed to the InpaintExtension. This caused a scale mismatch
when merging intermediate_latents (normalized) with noised_init_latents
(unnormalized), resulting in visible artifacts at mask blur boundaries.

Now normalize:
- init_latents_packed before passing to InpaintExtension
- noise_packed for correct interpolation in normalized space
- x (starting latents) for img2img/inpainting workflows

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions github-actions bot added python PRs that change python files invocations PRs that change invocations labels Feb 10, 2026
@Pfannkuchensack Pfannkuchensack marked this pull request as ready for review February 10, 2026 19:53
@JPPhoto JPPhoto added the v6.12.0 Intended for 6.12.0 release label Feb 10, 2026
@DustyShoe
Copy link
Copy Markdown
Collaborator

I have tested this PR and it fixes all concerns i had regarding Flux.2 Klein inpainting.

@lstein lstein merged commit 467ae66 into invoke-ai:main Feb 20, 2026
13 checks passed
@Pfannkuchensack Pfannkuchensack deleted the fix/flux2-inpainting-bn-normalization branch February 20, 2026 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invocations PRs that change invocations python PRs that change python files v6.12.0 Intended for 6.12.0 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants