stable-diffusion icon indicating copy to clipboard operation
stable-diffusion copied to clipboard

Why `make_beta_schedule` does not return linear schedule?

Open yutoe05 opened this issue 2 years ago • 4 comments

It seems that the beta schedule returned by make_beta_schedule("linear",...) is not linear but quadratic. Instead, the returned beta is linear when schedule == "sqrt_linear". Why is it implemented in this way?

https://github.com/CompVis/stable-diffusion/blob/69ae4b35e0a0f6ee1af8bb9a5d0016ccb27e36dc/ldm/modules/diffusionmodules/util.py#L21-L43

yutoe05 avatar Sep 23 '22 06:09 yutoe05

Hi @yutoe05 Have you come across any explanations regarding this matter? I revisited the LDM paper and searched, but unfortunately, I haven't found any clarifications on the topic.

wenhao728 avatar Feb 16 '24 15:02 wenhao728

Hi wenhao728.

Unfortunately, I couldn't find any explanations. Anyway, it seems they use linspace()**2 as default.

yutoe05 avatar Feb 26 '24 14:02 yutoe05

Hi @yutoe05, For the fomula of generating x_{t} from x_{t-1}, the coefficient before noise is sqrt_beta_t. So I guess torch.linspace(linear_start ** 0.5, linear_end ** 0.5, n_timestep, dtype=torch.float64) ** 2 means add noise linearly.

newbie2niubility avatar Mar 04 '24 09:03 newbie2niubility

Hi @newbie2niubility, I see. As you said, while originally in DDPM, the "noise schedule" is used with respect to the variance, it might be used with respect to the standard deviation of noise in latent diffusion. Thank you.

yutoe05 avatar Mar 13 '24 08:03 yutoe05