Skip to content

Add set_shift to FlowMatchEulerDiscreteScheduler #10269

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

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/diffusers/schedulers/scheduling_flow_match_euler_discrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,19 @@ def __init__(
self._step_index = None
self._begin_index = None

self._shift = shift

self.sigmas = sigmas.to("cpu") # to avoid too much CPU/GPU communication
self.sigma_min = self.sigmas[-1].item()
self.sigma_max = self.sigmas[0].item()

@property
def shift(self):
"""
The value used for shifting.
"""
return self._shift

@property
def step_index(self):
"""
Expand All @@ -128,6 +137,9 @@ def set_begin_index(self, begin_index: int = 0):
"""
self._begin_index = begin_index

def set_shift(self, shift: float):
self._shift = shift

def scale_noise(
self,
sample: torch.FloatTensor,
Expand Down Expand Up @@ -236,7 +248,7 @@ def set_timesteps(
if self.config.use_dynamic_shifting:
sigmas = self.time_shift(mu, 1.0, sigmas)
else:
sigmas = self.config.shift * sigmas / (1 + (self.config.shift - 1) * sigmas)
sigmas = self.shift * sigmas / (1 + (self.shift - 1) * sigmas)

if self.config.shift_terminal:
sigmas = self.stretch_shift_to_terminal(sigmas)
Expand Down
Loading