Skip to content
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

sd3推理优化——避免同步 #695

Merged
merged 2 commits into from
Sep 4, 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
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from ..utils.paddle_utils import randn_tensor
from .scheduling_utils import SchedulerMixin


logger = logging.get_logger(__name__) # pylint: disable=invalid-name


Expand Down Expand Up @@ -245,12 +244,13 @@ def step(
sample = sample.cast(paddle.float32)

sigma = self.sigmas[self.step_index]
# NOTE:(changwenbin & zhoukangkang) when s_churn == 0.0,not need to compute gamma, Can avoid cuda synchronization
if s_churn == 0.0:
gamma = 0.0
else:
gamma = min(s_churn / (len(self.sigmas) - 1), 2**0.5 - 1) if s_tmin <= sigma <= s_tmax else 0.0

gamma = min(s_churn / (len(self.sigmas) - 1), 2**0.5 - 1) if s_tmin <= sigma <= s_tmax else 0.0

noise = randn_tensor(
model_output.shape, dtype=model_output.dtype, generator=generator
)
noise = randn_tensor(model_output.shape, dtype=model_output.dtype, generator=generator)

eps = noise * s_noise
sigma_hat = sigma * (gamma + 1)
Expand Down Expand Up @@ -283,4 +283,4 @@ def step(
return FlowMatchEulerDiscreteSchedulerOutput(prev_sample=prev_sample)

def __len__(self):
return self.config.num_train_timesteps
return self.config.num_train_timesteps