Skip to content

Commit 7b61e9e

Browse files
committed
Fix issues found in review (pt 2)
1 parent 740ec1d commit 7b61e9e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

library/train_util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5875,7 +5875,7 @@ def get_huber_threshold(args, timesteps: torch.Tensor, noise_scheduler) -> torch
58755875
alpha = -math.log(args.huber_c) / noise_scheduler.config.num_train_timesteps
58765876
result = torch.exp(-alpha * timesteps) * args.huber_scale
58775877
elif args.huber_schedule == "snr":
5878-
if not hasattr(noise_scheduler, "alphas_cumprod"):
5878+
if noise_scheduler is None or not hasattr(noise_scheduler, "alphas_cumprod"):
58795879
raise NotImplementedError("Huber schedule 'snr' is not supported with the current model.")
58805880
alphas_cumprod = torch.index_select(noise_scheduler.alphas_cumprod, 0, timesteps.cpu())
58815881
sigmas = ((1.0 - alphas_cumprod) / alphas_cumprod) ** 0.5

sd3_train.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ def grad_hook(parameter: torch.Tensor):
845845
# )
846846
# calculate loss
847847
loss = train_util.conditional_loss(
848-
args, model_pred.float(), target.float(), timesteps, "none", noise_scheduler
848+
args, model_pred.float(), target.float(), timesteps, "none", None
849849
)
850850
if args.masked_loss or ("alpha_masks" in batch and batch["alpha_masks"] is not None):
851851
loss = apply_masked_loss(loss, batch)

0 commit comments

Comments
 (0)