mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-04-23 03:00:31 -04:00
* fix(flux2): Fix image quality degradation at resolutions > 1024x1024 This commit addresses severe quality degradation and artifacts when generating images larger than 1024x1024 with FLUX.2 Klein models. Root causes fixed: 1. Dynamic max_image_seq_len in scheduler (flux2_denoise.py) - Previously hardcoded to 4096 (1024x1024 only) - Now dynamically calculated based on actual resolution - Allows proper schedule shifting at all resolutions 2. Smoothed mu calculation discontinuity (sampling_utils.py) - Eliminated 40-50% mu value drop at seq_len 4300 threshold - Implemented smooth cosine interpolation (4096-4500 transition zone) - Gradual blend between low-res and high-res formulas Impact: - FLUX.2 Klein 9B: Major quality improvement at high resolutions - FLUX.2 Klein 4B: Improved quality at high resolutions - Baseline 1024x1024: Unchanged (no regression) - All generation modes: T2I and Kontext (reference images) Fixes: Community-reported quality degradation issue See: Discord discussions in #garbage-bin and #devchat Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix(flux2): Fix high-resolution quality degradation for FLUX.2 Klein Fixes grid/diamond artifacts and color loss at resolutions > 1024x1024. Root causes identified and fixed: - BN normalization was incorrectly applied to random noise input (diffusers only normalizes image latents from VAE.encode) - BN denormalization must be applied to output before VAE decode - mu parameter was resolution-dependent causing over-shifted schedules at high resolutions (now fixed to 2.02, matching ComfyUI) Changes: - Remove BN normalization on noise input (not needed for N(0,1) noise) - Preserve BN denormalization on denoised output (required for VAE) - Fix mu to constant 2.02 for all resolutions (matches ComfyUI) Tested at 2048x2048 with FLUX.2 Klein 4B * Chore Ruff --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com> Co-authored-by: Jonathan <34005131+JPPhoto@users.noreply.github.com>