kohya-ss / kohya-ss/sd-scripts

`fix_noise_scheduler_betas_for_zero_terminal_snr` should come before `prepare_scheduler_for_custom_training`

Open
#1,263 13 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
7.2k
Forks
1.2k
Avg merge
11m
Merged PRs (30d)
2

Description

I think the correct implementation should be like this.
```python
noise_scheduler = DDPMScheduler(
beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", num_train_timesteps=1000, clip_sample=False
)
if args.zero_terminal_snr:
custom_train_functions.fix_noise_scheduler_betas_for_zero_terminal_snr(noise_scheduler)
prepare_scheduler_for_custom_training(noise_scheduler, accelerator.device)
```
The current implementation calculates `noise_scheduler.all_snr` before even fixing the betas in the scheduler. This would make `apply_snr_weight` use the wrong SNR when training zero terminal SNR models with min SNR gamma.

Contributor guide

No contributing guide indexed for this repository

Research direction

Locate the training entry point that constructs DDPMScheduler and calls fix_noise_scheduler_betas_for_zero_terminal_snr and prepare_scheduler_for_custom_training. Trace when all_snr is calculated, then verify the zero-terminal-SNR path prepares the scheduler in the intended order so apply_snr_weight uses updated SNR values.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.