Skip to content

Commit f55ba34

Browse files
committed
fix timestep max for flow match sdxl
1 parent 9ea865b commit f55ba34

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

library/train_util.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6483,10 +6483,10 @@ def get_noise_noisy_latents_and_timesteps(
64836483
timesteps = fixed_timesteps
64846484
if flow_model_enabled:
64856485
# We need to recover sigmas (float 0.0 to 1.0) from the discrete timesteps
6486-
timestep_max = noise_scheduler.config.num_train_timesteps - 1
6487-
sigmas = timesteps.float() / timestep_max
6486+
timestep_max = noise_scheduler.config.num_train_timesteps
6487+
sigmas = timesteps.float() / (timestep_max - 1)
64886488
elif flow_model_enabled:
6489-
timestep_max = noise_scheduler.config.num_train_timesteps - 1
6489+
timestep_max = noise_scheduler.config.num_train_timesteps
64906490
distribution = getattr(args, "flow_timestep_distribution", "logit_normal")
64916491
if distribution == "logit_normal":
64926492
logits = torch.normal(
@@ -6524,7 +6524,7 @@ def get_noise_noisy_latents_and_timesteps(
65246524
t_ref = sigmas
65256525
sigmas = ratios * t_ref / (1 + (ratios - 1) * t_ref)
65266526

6527-
timesteps = torch.clamp((sigmas * timestep_max).long(), 0, timestep_max)
6527+
timesteps = torch.clamp((sigmas * timestep_max).long(), 0, timestep_max - 1)
65286528
elif args.timestep_distribution == "logit_normal":
65296529
logits = torch.normal(
65306530
mean=float(args.logit_normal_mean),

0 commit comments

Comments
 (0)