Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

Conversation

@Warvito
Copy link
Collaborator

@Warvito Warvito commented Jan 5, 2023

Fix #162

Signed-off-by: Walter Hugo Lopez Pinaya [email protected]

…ger than num_train_timesteps

Signed-off-by: Walter Hugo Lopez Pinaya <[email protected]>
Signed-off-by: Walter Hugo Lopez Pinaya <[email protected]>
Copy link
Member

@ericspod ericspod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me, I don't see what the issue is with num_inference_step being a power of 3 but it's something you encountered clearly.

step_ratio = self.num_train_timesteps // self.num_inference_steps
# creates integer timesteps by multiplying by ratio
# casting to int to avoid issues when num_inference_step is power of 3
timesteps = (np.arange(0, num_inference_steps) * step_ratio).round()[::-1].copy().astype(np.int64)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think copy is needed here, the array is fresh and round should also return a fresh one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, again it was from the base implementation (huggingface/diffusers#724), but I think here it is safe to remove (for example PNDM already does not use it)

@Warvito
Copy link
Collaborator Author

Warvito commented Jan 5, 2023

Looks fine to me, I don't see what the issue is with num_inference_step being a power of 3 but it's something you encountered clearly.

Thanks, Eric! The "power of 3" is one point that we found in the reference code and we kept to avoid problems (discussed here huggingface/diffusers#466)

Signed-off-by: Walter Hugo Lopez Pinaya <[email protected]>
@Warvito Warvito merged commit 19abdc3 into main Jan 5, 2023
@Warvito Warvito deleted the 162-wrong-number-of-timesteps-when-num_inference_steps-is-not-a-divisor-of-num_train_timesteps branch January 5, 2023 20:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong number of timesteps when num_inference_steps is not a divisor of num_train_timesteps

3 participants