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

Bug Report: Illegal timesteps #126

Open
LazyChild opened this issue Apr 28, 2024 · 0 comments
Open

Bug Report: Illegal timesteps #126

LazyChild opened this issue Apr 28, 2024 · 0 comments

Comments

@LazyChild
Copy link

Branch: main
Bug description: In lines 674-676 of train_sketch.py, when calculating the timesteps variable, it may generate an illegal timesteps = 1000, causing an assertion error when running the training script. The specific reason for the error is that the numbers generated by torch.rand() fall within the range [0, 1), and after cubing, values within [0,1) will decrease. Due to machine truncation, they are considered to be 0, leading to an illegal result while executing
timesteps = (1 - timesteps**3) * noise_scheduler.config.num_train_timesteps
resulting in program crash.

Here is a simple reproduction:
image

The following is the error line, located in the scheduling_ddpm.py file within the diffusers library. Accessing alphas_cumprod[1000] causes an index out of bounds error, as alphas_cumprod[] is a tensor of length 1000, leading to a program crash.
image

Solution:
Replace timesteps = (1 - timesteps**3) * noise_scheduler.config.num_train_timesteps with timesteps = (1 - timesteps**3) * (noise_scheduler.config.num_train_timesteps - 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant