-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Add stochastic sampling to FlowMatchEulerDiscreteScheduler #11369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This PR adds stochastic sampling to FlowMatchEulerDiscreteScheduler based on Lightricks/LTX-Video@b1aeddd ltx_video/schedulers/rf.py
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
@bot /style |
Style fixes have been applied. View the workflow run here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @apolinario
dt = sigma_next - sigma | ||
|
||
prev_sample = sample + dt * model_output | ||
# Determine whether to use stochastic sampling for this step | ||
use_stochastic = stochastic_sampling if stochastic_sampling is not None else self.config.stochastic_sampling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think just have this in config is enough no?
@bot /style |
Style fixes have been applied. View the workflow run here. |
@@ -378,6 +381,7 @@ def step( | |||
s_noise: float = 1.0, | |||
generator: Optional[torch.Generator] = None, | |||
per_token_timesteps: Optional[torch.Tensor] = None, | |||
stochastic_sampling: Optional[bool] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stochastic_sampling: Optional[bool] = None, |
stochastic_sampling (`bool`, *optional*): | ||
Whether to use stochastic sampling. If None, defaults to the value set in the scheduler's config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stochastic_sampling (`bool`, *optional*): | |
Whether to use stochastic sampling. If None, defaults to the value set in the scheduler's config. |
|
||
current_sigma = per_token_sigmas[..., None] | ||
next_sigma = lower_sigmas[..., None] | ||
dt = next_sigma - current_sigma # Equivalent to sigma_next - sigma |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apolinario
here it seems to reversed, no?
before:
dt = (per_token_sigmas - lower_sigmas)[..., None]
now:
dt = ower_sigmas - per_token_sigmas
What does this PR do?
This PR adds stochastic sampling to FlowMatchEulerDiscreteScheduler based on Lightricks/LTX-Video@b1aeddd
ltx_video/schedulers/rf.py
, which was added with th release of 0.9.6-distilled. I decoupled the next and current sigma to try to get closer to therf.py
implementation of the stochastic sampling, but a second pair of eyes on this would be great.To try it:
Who can review?
@yiyixuxu