Skip to content

schedulers/flow_match_euler_discrete: fix double-shift bug by storing sigma_min/sigma_max before shift is applied#13724

Closed
Dev-X25874 wants to merge 1 commit into
huggingface:mainfrom
Dev-X25874:fix/flow-match-euler-double-shift-13243
Closed

schedulers/flow_match_euler_discrete: fix double-shift bug by storing sigma_min/sigma_max before shift is applied#13724
Dev-X25874 wants to merge 1 commit into
huggingface:mainfrom
Dev-X25874:fix/flow-match-euler-double-shift-13243

Conversation

@Dev-X25874
Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #13243

FlowMatchEulerDiscreteScheduler.__init__ was storing sigma_min and sigma_max after the shift formula had already been applied to sigmas:

sigmas = shift * sigmas / (1 + (shift - 1) * sigmas)  # shift applied here
...
self.sigma_min = self.sigmas[-1].item()  # already-shifted value stored
self.sigma_max = self.sigmas[0].item()  # already-shifted value stored

Then in set_timesteps, when no custom sigmas/timesteps are provided, the scheduler reconstructs a linspace from sigma_maxsigma_min (the shifted values), divides back by num_train_timesteps, and applies the shift formula a second time — resulting in a doubly-shifted sigma schedule that diverges from what the model was trained with.

This PR moves the sigma_min/sigma_max assignment to before the shift is applied, so set_timesteps always starts from the correct unshifted linear range and applies the shift exactly once.

The fix is surgical: self.sigmas and self.timesteps stored in __init__ are unchanged. Only the two boundary reference scalars are corrected. Users passing custom sigmas or timesteps directly to set_timesteps are entirely unaffected.

Before submitting

Who can review?

@yiyixuxu

@github-actions github-actions Bot added size/S PR with diff < 50 LOC fixes-issue schedulers and removed fixes-issue labels May 12, 2026
@Dev-X25874 Dev-X25874 closed this May 12, 2026
@Dev-X25874 Dev-X25874 deleted the fix/flow-match-euler-double-shift-13243 branch May 12, 2026 03:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

schedulers size/S PR with diff < 50 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] FlowMatchEulerDiscreteScheduler.__init__ computes sigma_min/sigma_max after shift, causing duplicate shift in set_timesteps

1 participant