[None][fix] Fix scheduler off-by-one in FLUX pipelines at high resolutions#13091
Conversation
…tions Add set_begin_index(0) after set_timesteps in FLUX.1 and FLUX.2 pipelines to match upstream diffusers behavior. Without this, when the dynamic shift parameter mu is large (which happens at high resolutions like 6400x6400 / 160K+ tokens), all scheduler timesteps collapse to the same value. The scheduler's index_for_timestep then picks index 1 instead of 0 for the first step, causing an IndexError on the final step when it tries to access sigmas[num_steps + 1]. Signed-off-by: Kanghwan Jang <861393+karljang@users.noreply.github.com>
📝 WalkthroughWalkthroughTwo Flux pipeline implementations now explicitly set the scheduler's begin index to 0 immediately after retrieving timesteps, ensuring consistent scheduler state initialization at the start of pipeline execution. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
/bot run --disable-fail-fast |
|
PR_Github #43870 [ run ] triggered by Bot. Commit: |
|
PR_Github #43870 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #43951 [ run ] triggered by Bot. Commit: |
|
PR_Github #43951 [ run ] completed with state |
Summary
set_begin_index(0)afterset_timestepsin FLUX.1 and FLUX.2 pipelines to match upstream diffusers behaviorIndexErrorwhen running FLUX at high resolutions (e.g. 6400×6400 / 160K+ tokens) with few inference stepsRoot Cause
FLUX uses dynamic timestep shifting (
mu) that scales linearly with sequence length. At high resolutions (160K+ tokens),mubecomes large enough (~27.5) that all scheduler sigmas collapse to the same value (1.0) and all timesteps become identical (1000.0).Without
set_begin_index(0), the scheduler's_init_step_indexcallsindex_for_timestep(1000.0), finds all timesteps matching, and picks index 1 (not 0). After N steps,step_indexreachesN+1, causing an out-of-bounds access onself.sigmas[step_index + 1].The upstream diffusers
FluxPipelineavoids this by callingself.scheduler.set_begin_index(0)before the denoise loop (diffuserspipeline_flux.py:936), which forces_init_step_indexto use index 0.Test Plan
🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes