Skip to content

fix(flux2): support Heun scheduler for FLUX.2 Klein models#8794

Merged
lstein merged 3 commits intoinvoke-ai:mainfrom
Pfannkuchensack:fix/flux2-klein-heun-scheduler
Feb 1, 2026
Merged

fix(flux2): support Heun scheduler for FLUX.2 Klein models#8794
lstein merged 3 commits intoinvoke-ai:mainfrom
Pfannkuchensack:fix/flux2-klein-heun-scheduler

Conversation

@Pfannkuchensack
Copy link
Copy Markdown
Collaborator

Summary

FlowMatchHeunDiscreteScheduler does not support dynamic shifting parameters (use_dynamic_shifting, base_shift, max_shift, etc.) or sigmas/mu in set_timesteps. This caused FLUX.2 Klein to fail when using Heun scheduler.

  • Create Heun scheduler with only num_train_timesteps and shift parameters
  • Use num_inference_steps instead of sigmas for Heun's set_timesteps call
  • Euler and LCM schedulers continue to use full dynamic shifting support

Related Issues / Discussions

None

QA Instructions

  1. Load a FLUX.2 Klein model
  2. Generate an image using the Heun scheduler - should now work without errors
  3. Verify Euler and LCM schedulers still work correctly

Merge Plan

None - straightforward fix, can be merged directly.

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)

FlowMatchHeunDiscreteScheduler does not support dynamic shifting parameters
(use_dynamic_shifting, base_shift, max_shift, etc.) or sigmas/mu in set_timesteps.
This caused FLUX.2 Klein to fail when using Heun scheduler.

- Create Heun scheduler with only num_train_timesteps and shift parameters
- Use num_inference_steps instead of sigmas for Heun's set_timesteps call
- Euler and LCM schedulers continue to use full dynamic shifting support
@github-actions github-actions bot added python PRs that change python files invocations PRs that change invocations backend PRs that change backend files labels Jan 27, 2026
The previous hasattr check for state_in_first_order failed because
the attribute doesn't exist before set_timesteps() is called. Now
using inspect.signature to check for sigmas parameter support,
matching the FLUX1 implementation.
@Pfannkuchensack Pfannkuchensack marked this pull request as ready for review January 28, 2026 01:47
@Pfannkuchensack
Copy link
Copy Markdown
Collaborator Author

image Heun works fine now.

@lstein lstein added the v6.11.0 Intended for release 6.11.0 label Jan 29, 2026
Copy link
Copy Markdown
Collaborator

@lstein lstein left a comment

Choose a reason for hiding this comment

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

It's working for me.

@lstein lstein added v6.12.0 Intended for 6.12.0 release and removed v6.11.0 Intended for release 6.11.0 labels Jan 30, 2026
@lstein lstein merged commit 33779f3 into invoke-ai:main Feb 1, 2026
13 checks passed
@lstein lstein moved this from 6.12.x to 6.11.1 in Invoke - Community Roadmap Feb 2, 2026
dunkeroni pushed a commit to dunkeroni/InvokeAI that referenced this pull request Feb 2, 2026
…#8794)

* fix(flux2): support Heun scheduler for FLUX.2 Klein models

FlowMatchHeunDiscreteScheduler does not support dynamic shifting parameters
(use_dynamic_shifting, base_shift, max_shift, etc.) or sigmas/mu in set_timesteps.
This caused FLUX.2 Klein to fail when using Heun scheduler.

- Create Heun scheduler with only num_train_timesteps and shift parameters
- Use num_inference_steps instead of sigmas for Heun's set_timesteps call
- Euler and LCM schedulers continue to use full dynamic shifting support

* fix(flux2): fix Heun scheduler detection using inspect.signature

The previous hasattr check for state_in_first_order failed because
the attribute doesn't exist before set_timesteps() is called. Now
using inspect.signature to check for sigmas parameter support,
matching the FLUX1 implementation.

---------

Co-authored-by: Jonathan <34005131+JPPhoto@users.noreply.github.com>
@lstein lstein added 6.11.1 and removed v6.12.0 Intended for 6.12.0 release labels Feb 4, 2026
lstein pushed a commit that referenced this pull request Feb 6, 2026
* fix(flux2): support Heun scheduler for FLUX.2 Klein models

FlowMatchHeunDiscreteScheduler does not support dynamic shifting parameters
(use_dynamic_shifting, base_shift, max_shift, etc.) or sigmas/mu in set_timesteps.
This caused FLUX.2 Klein to fail when using Heun scheduler.

- Create Heun scheduler with only num_train_timesteps and shift parameters
- Use num_inference_steps instead of sigmas for Heun's set_timesteps call
- Euler and LCM schedulers continue to use full dynamic shifting support

* fix(flux2): fix Heun scheduler detection using inspect.signature

The previous hasattr check for state_in_first_order failed because
the attribute doesn't exist before set_timesteps() is called. Now
using inspect.signature to check for sigmas parameter support,
matching the FLUX1 implementation.

---------

Co-authored-by: Jonathan <34005131+JPPhoto@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.11.1 backend PRs that change backend files invocations PRs that change invocations python PRs that change python files

Projects

Status: 6.11.1

Development

Successfully merging this pull request may close these issues.

3 participants